mirror of
https://github.com/log4js-node/log4js-node.git
synced 2025-12-08 19:26:01 +00:00
Merge pull request #648 from tmihalcin/logger-initial-configuration
fix: deferred logger configuration.
This commit is contained in:
commit
796e3bd731
@ -163,6 +163,10 @@ function isMaster() {
|
||||
* @return {Logger} instance of logger for the category
|
||||
*/
|
||||
function getLogger(category) {
|
||||
if (!enabled) {
|
||||
configure(process.env.LOG4JS_CONFIG || defaultConfig);
|
||||
}
|
||||
|
||||
const cat = category || 'default';
|
||||
debug(`creating logger as ${isMaster() ? 'master' : 'worker'}`);
|
||||
return new Logger((isMaster() ? sendLogEventToAppender : workerDispatch), cat);
|
||||
@ -285,5 +289,3 @@ const log4js = {
|
||||
};
|
||||
|
||||
module.exports = log4js;
|
||||
// set ourselves up
|
||||
configure(process.env.LOG4JS_CONFIG || defaultConfig);
|
||||
|
||||
@ -37,7 +37,7 @@ test('log4js configure', (batch) => {
|
||||
}
|
||||
};
|
||||
|
||||
sandbox.require(
|
||||
const log4js = sandbox.require(
|
||||
'../../lib/log4js',
|
||||
{
|
||||
requires: {
|
||||
@ -46,6 +46,8 @@ test('log4js configure', (batch) => {
|
||||
}
|
||||
);
|
||||
|
||||
log4js.getLogger('test-logger');
|
||||
|
||||
delete process.env.LOG4JS_CONFIG;
|
||||
|
||||
t.equal(fileRead, 1, 'should load the specified local config file');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user