diff --git a/src/LoggerClient.ts b/src/LoggerClient.ts index e2a6992..c0ba04f 100644 --- a/src/LoggerClient.ts +++ b/src/LoggerClient.ts @@ -45,9 +45,9 @@ class LoggerClient implements Logger if (typeof this.#_logLevelMapping[type] === 'undefined') throw new Error(`Missing logLevelMapping for type ${type}`); Object.defineProperty(this, type, { - value: (msg: string, o: WriteOptions) => + value: (msg: string, o?: WriteOptions) => { - const { labels = [], ...writeOpts } = o; + const { labels = [], ...writeOpts } = o ?? {}; this.#transport(msg, { ...writeOpts, type, labels: [ ...this.#labels, ...labels ] }); } }); diff --git a/src/MasterLogger.ts b/src/MasterLogger.ts index c2a998c..24f44c1 100644 --- a/src/MasterLogger.ts +++ b/src/MasterLogger.ts @@ -85,7 +85,7 @@ class MasterLogger implements Logger if (typeof this.#_logLevelMapping[type] === 'undefined') throw new Error(`Missing logLevelMapping for type ${type}`); Object.defineProperty(this, type, { - value: (msg: string, opts: WriteOptions) => this.write(type, msg, opts) + value: (msg: string, opts?: WriteOptions) => this.write(type, msg, opts) }); } this.#colours = { ...Defaults.Colours, ...customColours };