Skip to content

Commit

Permalink
fix: Order of static keys to ensure default namespace key is availabl…
Browse files Browse the repository at this point in the history
…e when creating the default logger
  • Loading branch information
nklomp committed Jun 13, 2024
1 parent eae66f2 commit dc56df2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion packages/ssi-types/__tests__/logging.test.ts
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
2 changes: 1 addition & 1 deletion packages/ssi-types/src/logging/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export function logOptions(opts?: SimpleLogOptions): Required<SimpleLogOptions>
}

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<string, Required<SimpleLogOptions>> = new Map()
private readonly loggers: WeakMap<Required<SimpleLogOptions>, ISimpleLogger<any>> = new WeakMap()

Expand Down

0 comments on commit dc56df2

Please sign in to comment.