nice-simple-logger
Advanced tools
Comparing version 0.0.2 to 0.0.3
34
index.js
@@ -58,4 +58,10 @@ "use strict"; | ||
options = options || {}; | ||
options = _.defaults(options || {}, { | ||
logLevel: 255, | ||
logstash: false, | ||
ttyColors: true | ||
}); | ||
options.logLevel = process.env.NSL_LEVEL ? parseInt(process.env.NSL_LEVEL) : options.logLevel; | ||
if(options.logstash){ | ||
@@ -91,3 +97,3 @@ options.logstash.port = options.logstash.port || 9999; | ||
if(isatty){ | ||
if(isatty && options.ttyColors){ | ||
level = colored(level, levels[level]); | ||
@@ -112,3 +118,8 @@ ts = colored(ts, 'grey'); | ||
/* jshint bitwise: false */ | ||
log: function() { | ||
if(!(options.logLevel & 4)){ | ||
return; | ||
} | ||
log.apply(null, ['INFO'].concat(Array.prototype.slice.call(arguments))); | ||
@@ -118,8 +129,13 @@ }, | ||
debug: function() { | ||
if(options.debug){ | ||
log.apply(null, ['DEBUG'].concat(Array.prototype.slice.call(arguments))); | ||
if(!(options.logLevel & 16)){ | ||
return; | ||
} | ||
log.apply(null, ['DEBUG'].concat(Array.prototype.slice.call(arguments))); | ||
}, | ||
error: function error () { | ||
if(!(options.logLevel & 1)){ | ||
return; | ||
} | ||
// capture error() call location | ||
@@ -148,2 +164,5 @@ var stackErr = new Error(); | ||
warn: function() { | ||
if(!(options.logLevel & 2)){ | ||
return; | ||
} | ||
log.apply(null, ['WARN'].concat(Array.prototype.slice.call(arguments))); | ||
@@ -153,2 +172,5 @@ }, | ||
warning: function() { | ||
if(!(options.logLevel & 2)){ | ||
return; | ||
} | ||
log.apply(null, ['WARN'].concat(Array.prototype.slice.call(arguments))); | ||
@@ -158,2 +180,6 @@ }, | ||
expressLogger: function (options) { | ||
if(!(options.logLevel & 8)){ | ||
return; | ||
} | ||
if ('object' == typeof options) { | ||
@@ -160,0 +186,0 @@ options = options || {}; |
@@ -9,3 +9,3 @@ { | ||
}, | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"main": "./index.js", | ||
@@ -12,0 +12,0 @@ "keywords": ["logger", "log"], |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
11378
7
172
2