Comparing version 0.3.0 to 0.3.1
@@ -111,3 +111,4 @@ /** | ||
Logger.prototype.registerWatcher = function(watcher) { | ||
this.on('', watcher); | ||
var rootLogger = Logger.getSingleton(); | ||
rootLogger.on(this.name, watcher); | ||
}; | ||
@@ -127,24 +128,20 @@ | ||
// | ||
// * If message is loggable emit on global key from rootLogger. | ||
// * If not rootLogger emit LEVEL event on instance and bubble up to and | ||
// including rootLogger. | ||
// * If not rootLogger emit Logger NAME event on instance and bubble up to and | ||
// including rootLogger. | ||
// | ||
// | ||
if (this.isLoggable(level)) { | ||
rootLogger.emit('', logRecord); | ||
// * Emit on global key from rootLogger. | ||
// * Emit a LEVEL event on the rootLogger | ||
// * For each name in the ancestor chain, emit an event of that name. | ||
if (!this.isLoggable(level)) { | ||
return | ||
} | ||
if (this.name) { | ||
var name; | ||
var logger = this; | ||
rootLogger.emit(level, logRecord); | ||
while (logger && rootLogger !== logger) { | ||
name = logger.name | ||
rootLogger.emit('', logRecord); | ||
rootLogger.emit(level, logRecord); | ||
var logger = this; | ||
while (logger && rootLogger !== logger) { | ||
var name = logger.name | ||
if (name) { | ||
rootLogger.emit(name, logRecord); | ||
logger = logger.getParent(); | ||
} | ||
logger = logger.getParent(); | ||
} | ||
}; | ||
@@ -151,0 +148,0 @@ |
@@ -13,3 +13,7 @@ | ||
this.date = new Date; | ||
this.message = this.getFormattedMessage(); | ||
this._formattedMessage = null; | ||
Object.defineProperty(this, 'message', { | ||
get: this.getFormattedMessage.bind(this) | ||
}); | ||
} | ||
@@ -27,4 +31,11 @@ | ||
LogRecord.prototype.getFormattedMessage = function () { | ||
if (!this._formattedMessage) { | ||
this._formattedMessage = this._getFormattedMessage() | ||
} | ||
return this._formattedMessage | ||
} | ||
LogRecord.prototype.getFormattedMessage = function () { | ||
LogRecord.prototype._getFormattedMessage = function () { | ||
var args = this.rawArgs.map(function(a) { | ||
@@ -31,0 +42,0 @@ switch (typeof a) { |
{ | ||
"name" : "logg", | ||
"version" : "0.3.0", | ||
"version" : "0.3.1", | ||
"description" : "Logging library that allows for hierarchical loggers, multiple log levels, and flexible watching of log records.", | ||
@@ -17,3 +17,9 @@ "keywords" : ["log", "logging", "logger", "hierarchical", "handler", "watcher"], | ||
"main" : "./lib/logg.js", | ||
"directories": {"lib": "./lib"} | ||
"directories": {"lib": "./lib"}, | ||
"devDependencies": { | ||
"nodeunit": "0.9.0" | ||
}, | ||
"scripts": { | ||
"test": "./node_modules/.bin/nodeunit lib/*_test.js" | ||
} | ||
} |
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
25911
10
573
1