@hmcts/nodejs-logging
Advanced tools
Comparing version 1.1.2 to 1.2.0
@@ -6,4 +6,2 @@ const _ = require('lodash'); | ||
let singleton = Symbol(); | ||
let singletonEnforcer = Symbol(); | ||
let userConfig = {}; | ||
@@ -17,6 +15,3 @@ | ||
constructor(enforcer) { | ||
if (enforcer != singletonEnforcer) { | ||
throw new Error('Cannot construct Logger singleton, use the static getLogger() function'); | ||
} | ||
constructor() { | ||
} | ||
@@ -65,9 +60,7 @@ | ||
static getLogger(name) { | ||
if (!this[singleton]) { | ||
this[singleton] = new Logger(singletonEnforcer); | ||
} | ||
this[singleton].logger = logging.log4js.getLogger(name); | ||
this[singleton].logger.setLevel(logging.currentLevel); | ||
const logger = new Logger(); | ||
logger.logger = logging.log4js.getLogger(name); | ||
logger.logger.setLevel(logging.currentLevel); | ||
return this[singleton]; | ||
return logger; | ||
} | ||
@@ -74,0 +67,0 @@ |
{ | ||
"name": "@hmcts/nodejs-logging", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "Logger.js", |
@@ -285,16 +285,10 @@ 'use strict' | ||
it('should only create a single instance', () => { | ||
expect(loggerInstance1).to.deep.equal(loggerInstance2); | ||
expect(loggerInstance2).to.deep.equal(loggerInstance3); | ||
expect(loggerInstance3).to.deep.equal(loggerInstance1); | ||
it('should create multiple instances', () => { | ||
expect(loggerInstance1).to.not.equal(loggerInstance2); | ||
expect(loggerInstance2).to.not.equal(loggerInstance3); | ||
expect(loggerInstance3).to.not.equal(loggerInstance1); | ||
}); | ||
it('should throw an Error', () => { | ||
expect(() => { | ||
new Logger(); | ||
}).to.throw(Error, 'Cannot construct Logger singleton, use the static getLogger() function'); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27302
595