think-logger3
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "think-logger3", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "logger for ThinkJS 3.x", | ||
@@ -5,0 +5,0 @@ "main": "./src", |
@@ -43,3 +43,3 @@ const log4js = require('log4js'); | ||
*/ | ||
isCluster(config) { | ||
isCluster(config, clusterMode) { | ||
let lConfig = Object.assign({}, config); | ||
@@ -59,3 +59,6 @@ let appenders = config.appenders; | ||
//Master process | ||
if( !Object.keys(cluster.workers).length ) { | ||
if(typeof(clusterMode) === 'undefined') { | ||
clusterMode = Object.keys(cluster.workers).length; | ||
} | ||
if(!clusterMode) { | ||
return config; | ||
@@ -62,0 +65,0 @@ } |
const Base = require('./base'); | ||
module.exports = class DateFileLogger extends Base { | ||
constructor(config) { | ||
constructor(config, clusterMode) { | ||
super(config); | ||
@@ -19,3 +19,3 @@ | ||
//check cluster mode | ||
config = this.isCluster(config); | ||
config = this.isCluster(config, clusterMode); | ||
@@ -22,0 +22,0 @@ this._logger = this.getLogger(config); |
const Base = require('./base'); | ||
module.exports = class FileLogger extends Base { | ||
constructor(config) { | ||
constructor(config, clusterMode) { | ||
super(config); | ||
@@ -18,3 +18,3 @@ | ||
//check cluster mode | ||
config = this.isCluster(config); | ||
config = this.isCluster(config, clusterMode); | ||
@@ -21,0 +21,0 @@ this._logger = this.getLogger(config); |
@@ -7,7 +7,7 @@ const assert = require('assert'); | ||
class Logger { | ||
constructor(config) { | ||
constructor(config, clusterMode) { | ||
let handle = config.handle; | ||
delete config.handle; | ||
this._logger = new handle(config); | ||
this._logger = new handle(config, clusterMode); | ||
['debug', 'info', 'warn', 'error'].forEach(level => { | ||
@@ -14,0 +14,0 @@ assert(this._logger[level], `adapter function ${level} not exist!`); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
135119
674