From dc56df22045944f48a2f7c32b04d099ac7b231e9 Mon Sep 17 00:00:00 2001 From: Niels Klomp Date: Thu, 13 Jun 2024 21:06:46 +0200 Subject: [PATCH] fix: Order of static keys to ensure default namespace key is available when creating the default logger --- packages/ssi-types/__tests__/logging.test.ts | 9 ++++++++- packages/ssi-types/src/logging/index.ts | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/ssi-types/__tests__/logging.test.ts b/packages/ssi-types/__tests__/logging.test.ts index 9b0d750d2..3a04a41cc 100644 --- a/packages/ssi-types/__tests__/logging.test.ts +++ b/packages/ssi-types/__tests__/logging.test.ts @@ -1,6 +1,13 @@ -import { Loggers, LogMethod } from '../src' +import {Loggers, LogMethod} from '../src' describe('Simple logging', () => { + + it('Should be able to log without providing options for a new namespace', () => { + Loggers.DEFAULT.get(''+ Date.now()) + .log('Random test') + }) + + it('Should perform a debug package log', () => { Loggers.DEFAULT.options('debug_pkg', { methods: [LogMethod.DEBUG_PKG] }) .get('debug_pkg') diff --git a/packages/ssi-types/src/logging/index.ts b/packages/ssi-types/src/logging/index.ts index 961b265e6..8f9007b36 100644 --- a/packages/ssi-types/src/logging/index.ts +++ b/packages/ssi-types/src/logging/index.ts @@ -46,8 +46,8 @@ export function logOptions(opts?: SimpleLogOptions): Required } export class Loggers { - public static readonly DEFAULT: Loggers = new Loggers({ defaultLogLevel: LogLevel.INFO, methods: [LogMethod.DEBUG_PKG, LogMethod.EVENT] }) private static readonly DEFAULT_KEY = '__DEFAULT__' + public static readonly DEFAULT: Loggers = new Loggers({ defaultLogLevel: LogLevel.INFO, methods: [LogMethod.DEBUG_PKG, LogMethod.EVENT] }) private readonly namespaceOptions: Map> = new Map() private readonly loggers: WeakMap, ISimpleLogger> = new WeakMap()