Comparing version 0.3.5 to 0.3.6
@@ -86,2 +86,13 @@ ##Logging. | ||
#### `.timer()` | ||
The comb logger also has a `timer()` method that will append a duration to the end of your log message | ||
``` | ||
var timer = LOGGER.timer(); | ||
setTimeout(function(){ | ||
timer.info("HELLO TIMERS!!!"); //HELLO TIMERS!!! [Duration: 5000ms] | ||
}, 5000); | ||
``` | ||
####Appenders | ||
@@ -88,0 +99,0 @@ |
@@ -0,1 +1,5 @@ | ||
# 0.3.6 | ||
* Added new `timer` function to comb.logger. | ||
# 0.3.5 | ||
@@ -2,0 +6,0 @@ |
@@ -15,2 +15,3 @@ var os = require("os"), | ||
configurators = require("./config"); | ||
var rootTree; | ||
@@ -321,2 +322,46 @@ var LoggerTree = define.define(null, { | ||
/** | ||
* Create a timer that can be used to log statements with a duration at the send. | ||
* | ||
* ``` | ||
* var timer = LOGGER.timer(); | ||
* setTimeout(function(){ | ||
* timer.info("HELLO TIMERS!!!"); //HELLO TIMERS!!! [Duration: 5000ms] | ||
* }, 5000); | ||
* ``` | ||
* | ||
* @param timerFormat | ||
* @returns {{info: Function, debug: Function, error: Function, warn: Function, trace: Function, fatal: Function, end: Function}} | ||
*/ | ||
timer: function (timerFormat) { | ||
timerFormat = timerFormat || " [Duration: %dms]"; | ||
function timerLog(level, start) { | ||
return function (message) { | ||
var args = argsToArray(arguments, 1); | ||
message += timerFormat; | ||
args.push(new Date() - start); | ||
self.log.apply(self, [level, message].concat(args)); | ||
return ret; | ||
}; | ||
} | ||
var start = new Date(), | ||
self = this, | ||
ret = { | ||
info: timerLog(Level.INFO, start), | ||
debug: timerLog(Level.DEBUG, start), | ||
error: timerLog(Level.ERROR, start), | ||
warn: timerLog(Level.WARN, start), | ||
trace: timerLog(Level.TRACE, start), | ||
fatal: timerLog(Level.FATAL, start), | ||
log: function (level) { | ||
return timerLog(level, start).apply(this, argsToArray(arguments, 1)); | ||
}, | ||
end: function () { | ||
start = self = null; | ||
} | ||
}; | ||
return ret; | ||
}, | ||
/** | ||
* Creates a log event to be passed to appenders | ||
@@ -323,0 +368,0 @@ * |
{ | ||
"name": "comb", | ||
"description": "A framework for node", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"keywords": ["OO", "Object Oriented", "Collections", "Tree", "HashTable", "Pool", "Logging", "Promise", "Promises", "Proxy"], | ||
@@ -6,0 +6,0 @@ "repository": { |
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
2962230
12031