Skip to content

Commit

Permalink
feat: do not dedup loggers with same name
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Oct 26, 2023
1 parent b45abe1 commit b62c896
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "reggol",
"description": "Logger for professionals",
"version": "1.6.0",
"version": "1.6.1",
"sideEffects": false,
"main": "lib/node.js",
"types": "index.d.ts",
Expand Down
4 changes: 0 additions & 4 deletions src/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ class Logger {

// global registry
static formatters: Record<string, Logger.Formatter> = Object.create(null)
static instances: Record<string, Logger> = Object.create(null)

static format(name: string, formatter: Logger.Formatter) {
this.formatters[name] = formatter
Expand Down Expand Up @@ -132,9 +131,6 @@ class Logger {
}

constructor(public name: string, public meta?: any) {
if (name in Logger.instances) return Logger.instances[name]

Logger.instances[name] = this
this.createMethod('success', Logger.SUCCESS)
this.createMethod('error', Logger.ERROR)
this.createMethod('info', Logger.INFO)
Expand Down
1 change: 0 additions & 1 deletion tests/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ describe('Logger API', () => {
it('basic support', () => {
logger = new Logger('test').extend('logger')
expect(logger.name).to.equal('test:logger')
expect(logger).to.equal(new Logger('test:logger'))
logger = new Logger('test')
})

Expand Down

0 comments on commit b62c896

Please sign in to comment.