Skip to content

Commit 2831af2

Browse files
authored
chore: Add ability to set core crypto log level [WPB-21565] (#19758)
1 parent 17e2ef0 commit 2831af2

File tree

4 files changed

+65
-11
lines changed

4 files changed

+65
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"@wireapp/avs": "10.2.17",
1717
"@wireapp/avs-debugger": "0.0.7",
1818
"@wireapp/commons": "5.4.9",
19-
"@wireapp/core": "46.45.2",
19+
"@wireapp/core": "46.46.0",
2020
"@wireapp/kalium-backup": "0.0.4",
2121
"@wireapp/promise-queue": "2.4.9",
2222
"@wireapp/react-ui-kit": "9.69.0",

src/script/components/ConfigToolbar/ConfigToolbar.tsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {Button, Input, Switch} from '@wireapp/react-ui-kit';
2727
import {ConversationState} from 'Repositories/conversation/ConversationState';
2828
import {Config, Configuration} from 'src/script/Config';
2929
import {useClickOutside} from 'src/script/hooks/useClickOutside';
30+
import {CoreCryptoLogLevel} from 'Util/DebugUtil';
3031

3132
import {wrapperStyles} from './ConfigToolbar.styles';
3233

@@ -42,6 +43,7 @@ export function ConfigToolbar() {
4243
const wrapperRef = useRef(null);
4344
const [avsDebuggerEnabled, setAvsDebuggerEnabled] = useState(!!window.wire?.app?.debug?.isEnabledAvsDebugger());
4445
const [avsRustSftEnabled, setAvsRustSftEnabled] = useState(!!window.wire?.app?.debug?.isEnabledAvsRustSFT());
46+
const [coreCryptoLevel, setCoreCryptoLevel] = useState<CoreCryptoLogLevel>(CoreCryptoLogLevel.Info);
4547

4648
// Toggle config tool on 'cmd/ctrl + shift + 2'
4749
useEffect(() => {
@@ -237,6 +239,41 @@ export function ConfigToolbar() {
237239
);
238240
};
239241

242+
const renderCoreCryptoLogLevelSelect = () => {
243+
const options: Array<{label: string; value: CoreCryptoLogLevel}> = [
244+
{label: 'Off', value: CoreCryptoLogLevel.Off},
245+
{label: 'Trace', value: CoreCryptoLogLevel.Trace},
246+
{label: 'Debug', value: CoreCryptoLogLevel.Debug},
247+
{label: 'Info', value: CoreCryptoLogLevel.Info},
248+
{label: 'Warn', value: CoreCryptoLogLevel.Warn},
249+
{label: 'Error', value: CoreCryptoLogLevel.Error},
250+
];
251+
252+
return (
253+
<div style={{marginBottom: '10px'}}>
254+
<label htmlFor="core-crypto-loglevel" style={{display: 'block', fontWeight: 'bold'}}>
255+
CORE CRYPTO LOG LEVEL
256+
</label>
257+
<select
258+
id="core-crypto-loglevel"
259+
value={coreCryptoLevel}
260+
onChange={event => {
261+
const val = Number(event.currentTarget.value) as CoreCryptoLogLevel;
262+
setCoreCryptoLevel(val);
263+
void window.wire?.app?.debug?.setCoreCryptoMaxLogLevel(val);
264+
}}
265+
style={{padding: '6px 8px'}}
266+
>
267+
{options.map(option => (
268+
<option key={option.value} value={option.value}>
269+
{option.label}
270+
</option>
271+
))}
272+
</select>
273+
</div>
274+
);
275+
};
276+
240277
const resetMLSConversation = async () => {
241278
setIsResettingMLSConversation(true);
242279
try {
@@ -285,6 +322,10 @@ export function ConfigToolbar() {
285322

286323
<hr />
287324

325+
<div>{renderCoreCryptoLogLevelSelect()}</div>
326+
327+
<hr />
328+
288329
<h3>Message Automation</h3>
289330
<Input
290331
type="text"

src/script/util/DebugUtil.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ import {APIClient} from '../service/APIClientSingleton';
7070
import {Core} from '../service/CoreSingleton';
7171
import {ViewModelRepositories} from '../view_model/MainViewModel';
7272

73+
export enum CoreCryptoLogLevel {
74+
Off = 1,
75+
Trace = 2,
76+
Debug = 3,
77+
Info = 4,
78+
Warn = 5,
79+
Error = 6,
80+
}
81+
7382
export class DebugUtil {
7483
private readonly logger: Logger;
7584
private readonly callingRepository: CallingRepository;
@@ -270,6 +279,10 @@ export class DebugUtil {
270279
this.propertiesRepository.savePreference(PROPERTIES_TYPE.CALL.ENABLE_PRESS_SPACE_TO_UNMUTE, false);
271280
}
272281

282+
async setCoreCryptoMaxLogLevel(level: CoreCryptoLogLevel) {
283+
return this.core.setMaxCoreCryptoLogLevel(level);
284+
}
285+
273286
async resetMLSConversation() {
274287
return (this.core.service?.conversation as any).resetMLSConversation(
275288
this.conversationState.activeConversation()?.qualifiedId,

yarn.lock

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8598,9 +8598,9 @@ __metadata:
85988598
languageName: node
85998599
linkType: hard
86008600

8601-
"@wireapp/api-client@npm:^27.88.0":
8602-
version: 27.88.0
8603-
resolution: "@wireapp/api-client@npm:27.88.0"
8601+
"@wireapp/api-client@npm:^27.89.0":
8602+
version: 27.89.0
8603+
resolution: "@wireapp/api-client@npm:27.89.0"
86048604
dependencies:
86058605
"@aws-sdk/client-s3": "npm:3.908.0"
86068606
"@aws-sdk/lib-storage": "npm:3.908.0"
@@ -8619,7 +8619,7 @@ __metadata:
86198619
uuid: "npm:11.1.0"
86208620
ws: "npm:8.18.1"
86218621
zod: "npm:3.24.2"
8622-
checksum: 10/e47475c5e833120919fc411be0592b5ac0dfeab6884731cafd232f2e3d2559e84bedbe87ce2bffcc1dc7baf63e1b8db29fb0911360a70aef5f074c5e0fd9ada5
8622+
checksum: 10/bc6a6d578b46cddb051ff97da1256d6466bfa24f4a3d7afa2e0b7d0899e45c6a084a83da306cf63ed0a3f20e5f5bd3dde136fc086ad90ea90151bdc91aebfd85
86238623
languageName: node
86248624
linkType: hard
86258625

@@ -8684,11 +8684,11 @@ __metadata:
86848684
languageName: node
86858685
linkType: hard
86868686

8687-
"@wireapp/core@npm:46.45.2":
8688-
version: 46.45.2
8689-
resolution: "@wireapp/core@npm:46.45.2"
8687+
"@wireapp/core@npm:46.46.0":
8688+
version: 46.46.0
8689+
resolution: "@wireapp/core@npm:46.46.0"
86908690
dependencies:
8691-
"@wireapp/api-client": "npm:^27.88.0"
8691+
"@wireapp/api-client": "npm:^27.89.0"
86928692
"@wireapp/commons": "npm:^5.4.9"
86938693
"@wireapp/core-crypto": "npm:9.1.2"
86948694
"@wireapp/cryptobox": "npm:12.8.0"
@@ -8706,7 +8706,7 @@ __metadata:
87068706
long: "npm:^5.2.0"
87078707
uuid: "npm:9.0.1"
87088708
zod: "npm:3.24.2"
8709-
checksum: 10/7f71be7d1a70bb05ac25510f9186cb1c180521831ed1359ead126929f6a19f61ff8a25633134c730450bf6b2bac9965d2aa6b57fc7a52942044406812719833e
8709+
checksum: 10/ce543416fad1667434c12ff3f6e8af12a9bc305277b12c156f5f80538d03c10b44f4de7ab548b5b8b58abb2618028dffefa813bcc8e07d4bea4dfceb7bfa4085
87108710
languageName: node
87118711
linkType: hard
87128712

@@ -22653,7 +22653,7 @@ __metadata:
2265322653
"@wireapp/avs-debugger": "npm:0.0.7"
2265422654
"@wireapp/commons": "npm:5.4.9"
2265522655
"@wireapp/copy-config": "npm:2.3.4"
22656-
"@wireapp/core": "npm:46.45.2"
22656+
"@wireapp/core": "npm:46.46.0"
2265722657
"@wireapp/eslint-config": "npm:3.0.7"
2265822658
"@wireapp/kalium-backup": "npm:0.0.4"
2265922659
"@wireapp/prettier-config": "npm:0.6.9"

0 commit comments

Comments
 (0)