Splunk.Logger
Splunk.Logger
A controllable logging module.
log
Splunk.Logger.log
method
Log to the console (equivalent to console.log
)
Source (lib/log.js:85)
log: function() {
if (process.env.LOG_LEVEL >= levels.ALL) {
_log.apply(null, arguments);
}
},
error
Splunk.Logger.error
method
Log error to the console (equivalent to console.error
)
Source (lib/log.js:96)
error: function() {
if (process.env.LOG_LEVEL >= levels.ERROR) {
_error.apply(null, arguments);
}
},
warn
Splunk.Logger.warn
method
Log warning to the console (equivalent to console.warn
)
Source (lib/log.js:107)
warn: function() {
if (process.env.LOG_LEVEL >= levels.WARN) {
_warn.apply(null, arguments);
}
},
info
Splunk.Logger.info
method
Log info to the console (equivalent to console.info
)
Source (lib/log.js:118)
info: function() {
if (process.env.LOG_LEVEL >= levels.INFO) {
_info.apply(null, arguments);
}
},
setLevel
Splunk.Logger.setLevel
method
Params
- level - String,Number
A string (
ALL
|INFO
|WARN
|ERROR
|NONE
) or number representing the log level
Set the global logging level
Example
Splunk.Logger.setLevel("WARN");
Splunk.Logger.setLevel(0); // equivalent to NONE
Source (lib/log.js:136)
setLevel: function(level) {
if (utils.isString(level)) {
if (levels.hasOwnProperty(level)) {
process.env.LOG_LEVEL = levels[level];
}
else {
process.env.LOG_LEVEL = levels["ERROR"];
}
}
else if (utils.isNumber(level)) {
process.env.LOG_LEVEL = level;
}
else {
process.env.LOG_LEVEL = levels["ERROR"];
}
},