Skip to content

Commit

Permalink
Send worker loglevel in init message (#1045)
Browse files Browse the repository at this point in the history
* Send worker loglevel in init message

* Create two-snails-lick.md

* remove unused loglvlmessage
  • Loading branch information
lukasIO authored Feb 23, 2024
1 parent 565e401 commit c8faee3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/two-snails-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

Send worker loglevel in init message
3 changes: 2 additions & 1 deletion src/e2ee/E2eeManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EventEmitter } from 'events';
import type TypedEventEmitter from 'typed-emitter';
import log from '../logger';
import log, { LogLevel, workerLogger } from '../logger';
import { Encryption_Type, TrackInfo } from '../proto/livekit_models_pb';
import type RTCEngine from '../room/RTCEngine';
import type Room from '../room/Room';
Expand Down Expand Up @@ -68,6 +68,7 @@ export class E2EEManager extends (EventEmitter as new () => TypedEventEmitter<E2
kind: 'init',
data: {
keyProviderOptions: this.keyProvider.getOptions(),
loglevel: workerLogger.getLevel() as LogLevel,
},
};
if (this.worker) {
Expand Down
2 changes: 2 additions & 0 deletions src/e2ee/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { LogLevel } from '../logger';
import type { VideoCodec } from '../room/track/options';
import type { BaseKeyProvider } from './KeyProvider';

Expand All @@ -10,6 +11,7 @@ export interface InitMessage extends BaseMessage {
kind: 'init';
data: {
keyProviderOptions: KeyProviderOptions;
loglevel: LogLevel;
};
}

Expand Down
1 change: 1 addition & 0 deletions src/e2ee/worker/e2ee.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ onmessage = (ev) => {

switch (kind) {
case 'init':
workerLogger.setLevel(data.loglevel);
workerLogger.info('worker initialized');
keyProviderOptions = data.keyProviderOptions;
useSharedKey = !!data.keyProviderOptions.sharedKey;
Expand Down
2 changes: 2 additions & 0 deletions src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export type StructuredLogger = {
warn: (msg: string, context?: object) => void;
error: (msg: string, context?: object) => void;
setDefaultLevel: (level: log.LogLevelDesc) => void;
setLevel: (level: log.LogLevelDesc) => void;
getLevel: () => number;
};

let livekitLogger = log.getLogger('livekit');
Expand Down

0 comments on commit c8faee3

Please sign in to comment.