aurelia-logging
Advanced tools
Comparing version 1.0.0 to 1.1.0
{ | ||
"name": "aurelia-logging", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A minimal but effective logging mechanism with support for log levels and pluggable log appenders.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
var path = require('path'); | ||
var fs = require('fs'); | ||
var appRoot = 'src/'; | ||
var pkg = JSON.parse(fs.readFileSync('./package.json', 'utf-8')); | ||
module.exports = { | ||
root: appRoot, | ||
source: appRoot + '**/*.js', | ||
html: appRoot + '**/*.html', | ||
style: 'styles/**/*.css', | ||
output: 'dist/', | ||
doc:'./doc', | ||
e2eSpecsSrc: 'test/e2e/src/*.js', | ||
e2eSpecsDist: 'test/e2e/dist/', | ||
packageName: pkg.name | ||
};var path = require('path'); | ||
var fs = require('fs'); | ||
// hide warning // | ||
@@ -21,0 +5,0 @@ var emitter = require('events'); |
@@ -22,3 +22,2 @@ define(['exports'], function (exports) { | ||
var loggers = {}; | ||
var currentLevel = logLevel.none; | ||
var appenders = []; | ||
@@ -42,3 +41,3 @@ var slice = Array.prototype.slice; | ||
function debug() { | ||
if (currentLevel < 4) { | ||
if (this.level < 4) { | ||
return; | ||
@@ -51,3 +50,3 @@ } | ||
function info() { | ||
if (currentLevel < 3) { | ||
if (this.level < 3) { | ||
return; | ||
@@ -60,3 +59,3 @@ } | ||
function warn() { | ||
if (currentLevel < 2) { | ||
if (this.level < 2) { | ||
return; | ||
@@ -69,3 +68,3 @@ } | ||
function error() { | ||
if (currentLevel < 1) { | ||
if (this.level < 1) { | ||
return; | ||
@@ -109,3 +108,5 @@ } | ||
function setLevel(level) { | ||
currentLevel = level; | ||
for (var key in loggers) { | ||
loggers[key].setLevel(level); | ||
} | ||
} | ||
@@ -117,2 +118,4 @@ | ||
this.level = logLevel.none; | ||
if (key !== loggerConstructionKey) { | ||
@@ -133,4 +136,8 @@ throw new Error('Cannot instantiate "Logger". Use "getLogger" instead.'); | ||
Logger.prototype.setLevel = function setLevel(level) { | ||
this.level = level; | ||
}; | ||
return Logger; | ||
}(); | ||
}); |
@@ -100,3 +100,3 @@ | ||
/** | ||
* Sets the level of logging for the application loggers. | ||
* Sets the level of logging for ALL the application loggers. | ||
* | ||
@@ -118,2 +118,7 @@ * @param level Matches a value of logLevel specifying the level of logging. | ||
/** | ||
* The logging severity level for this logger | ||
*/ | ||
level: number; | ||
/** | ||
* You cannot instantiate the logger directly - you must use the getLogger method instead. | ||
@@ -154,2 +159,9 @@ */ | ||
error(message: string, ...rest: any[]): void; | ||
/** | ||
* Sets the level of logging this logger | ||
* | ||
* @param level Matches a value of logLevel specifying the level of logging. | ||
*/ | ||
setLevel(level: LogLevel): void; | ||
} |
@@ -40,3 +40,2 @@ | ||
let loggers = {}; | ||
let currentLevel = logLevel.none; | ||
let appenders = []; | ||
@@ -60,3 +59,3 @@ let slice = Array.prototype.slice; | ||
function debug() { | ||
if (currentLevel < 4) { | ||
if (this.level < 4) { | ||
return; | ||
@@ -69,3 +68,3 @@ } | ||
function info() { | ||
if (currentLevel < 3) { | ||
if (this.level < 3) { | ||
return; | ||
@@ -78,3 +77,3 @@ } | ||
function warn() { | ||
if (currentLevel < 2) { | ||
if (this.level < 2) { | ||
return; | ||
@@ -87,3 +86,3 @@ } | ||
function error() { | ||
if (currentLevel < 1) { | ||
if (this.level < 1) { | ||
return; | ||
@@ -175,3 +174,3 @@ } | ||
/** | ||
* Sets the level of logging for the application loggers. | ||
* Sets the level of logging for ALL the application loggers. | ||
* | ||
@@ -181,3 +180,5 @@ * @param level Matches a value of logLevel specifying the level of logging. | ||
export function setLevel(level: number): void { | ||
currentLevel = level; | ||
for (let key in loggers) { | ||
loggers[key].setLevel(level); | ||
} | ||
} | ||
@@ -195,2 +196,7 @@ | ||
/** | ||
* The logging severity level for this logger | ||
*/ | ||
level: number = logLevel.none; | ||
/** | ||
* You cannot instantiate the logger directly - you must use the getLogger method instead. | ||
@@ -237,2 +243,11 @@ */ | ||
error(message: string, ...rest: any[]): void {} | ||
/** | ||
* Sets the level of logging this logger | ||
* | ||
* @param level Matches a value of logLevel specifying the level of logging. | ||
*/ | ||
setLevel(level: LogLevel): void { | ||
this.level = level; | ||
} | ||
} |
@@ -21,3 +21,2 @@ 'use strict'; | ||
var loggers = {}; | ||
var currentLevel = logLevel.none; | ||
var appenders = []; | ||
@@ -41,3 +40,3 @@ var slice = Array.prototype.slice; | ||
function debug() { | ||
if (currentLevel < 4) { | ||
if (this.level < 4) { | ||
return; | ||
@@ -50,3 +49,3 @@ } | ||
function info() { | ||
if (currentLevel < 3) { | ||
if (this.level < 3) { | ||
return; | ||
@@ -59,3 +58,3 @@ } | ||
function warn() { | ||
if (currentLevel < 2) { | ||
if (this.level < 2) { | ||
return; | ||
@@ -68,3 +67,3 @@ } | ||
function error() { | ||
if (currentLevel < 1) { | ||
if (this.level < 1) { | ||
return; | ||
@@ -108,3 +107,5 @@ } | ||
function setLevel(level) { | ||
currentLevel = level; | ||
for (var key in loggers) { | ||
loggers[key].setLevel(level); | ||
} | ||
} | ||
@@ -116,2 +117,4 @@ | ||
this.level = logLevel.none; | ||
if (key !== loggerConstructionKey) { | ||
@@ -132,3 +135,7 @@ throw new Error('Cannot instantiate "Logger". Use "getLogger" instead.'); | ||
Logger.prototype.setLevel = function setLevel(level) { | ||
this.level = level; | ||
}; | ||
return Logger; | ||
}(); |
@@ -11,3 +11,2 @@ | ||
let loggers = {}; | ||
let currentLevel = logLevel.none; | ||
let appenders = []; | ||
@@ -31,3 +30,3 @@ let slice = Array.prototype.slice; | ||
function debug() { | ||
if (currentLevel < 4) { | ||
if (this.level < 4) { | ||
return; | ||
@@ -40,3 +39,3 @@ } | ||
function info() { | ||
if (currentLevel < 3) { | ||
if (this.level < 3) { | ||
return; | ||
@@ -49,3 +48,3 @@ } | ||
function warn() { | ||
if (currentLevel < 2) { | ||
if (this.level < 2) { | ||
return; | ||
@@ -58,3 +57,3 @@ } | ||
function error() { | ||
if (currentLevel < 1) { | ||
if (this.level < 1) { | ||
return; | ||
@@ -98,3 +97,5 @@ } | ||
export function setLevel(level) { | ||
currentLevel = level; | ||
for (let key in loggers) { | ||
loggers[key].setLevel(level); | ||
} | ||
} | ||
@@ -104,2 +105,4 @@ | ||
constructor(id, key) { | ||
this.level = logLevel.none; | ||
if (key !== loggerConstructionKey) { | ||
@@ -119,2 +122,6 @@ throw new Error('Cannot instantiate "Logger". Use "getLogger" instead.'); | ||
error(message, ...rest) {} | ||
setLevel(level) { | ||
this.level = level; | ||
} | ||
}; |
@@ -12,3 +12,2 @@ | ||
var loggers = {}; | ||
var currentLevel = logLevel.none; | ||
var appenders = []; | ||
@@ -32,3 +31,3 @@ var slice = Array.prototype.slice; | ||
function debug() { | ||
if (currentLevel < 4) { | ||
if (this.level < 4) { | ||
return; | ||
@@ -41,3 +40,3 @@ } | ||
function info() { | ||
if (currentLevel < 3) { | ||
if (this.level < 3) { | ||
return; | ||
@@ -50,3 +49,3 @@ } | ||
function warn() { | ||
if (currentLevel < 2) { | ||
if (this.level < 2) { | ||
return; | ||
@@ -59,3 +58,3 @@ } | ||
function error() { | ||
if (currentLevel < 1) { | ||
if (this.level < 1) { | ||
return; | ||
@@ -99,3 +98,5 @@ } | ||
export function setLevel(level) { | ||
currentLevel = level; | ||
for (var key in loggers) { | ||
loggers[key].setLevel(level); | ||
} | ||
} | ||
@@ -107,2 +108,4 @@ | ||
this.level = logLevel.none; | ||
if (key !== loggerConstructionKey) { | ||
@@ -123,3 +126,7 @@ throw new Error('Cannot instantiate "Logger". Use "getLogger" instead.'); | ||
Logger.prototype.setLevel = function setLevel(level) { | ||
this.level = level; | ||
}; | ||
return Logger; | ||
}(); |
@@ -6,3 +6,3 @@ 'use strict'; | ||
var logLevel, loggers, currentLevel, appenders, slice, loggerConstructionKey, Logger; | ||
var logLevel, loggers, appenders, slice, loggerConstructionKey, Logger; | ||
@@ -25,3 +25,3 @@ | ||
function debug() { | ||
if (currentLevel < 4) { | ||
if (this.level < 4) { | ||
return; | ||
@@ -34,3 +34,3 @@ } | ||
function info() { | ||
if (currentLevel < 3) { | ||
if (this.level < 3) { | ||
return; | ||
@@ -43,3 +43,3 @@ } | ||
function warn() { | ||
if (currentLevel < 2) { | ||
if (this.level < 2) { | ||
return; | ||
@@ -52,3 +52,3 @@ } | ||
function error() { | ||
if (currentLevel < 1) { | ||
if (this.level < 1) { | ||
return; | ||
@@ -96,3 +96,5 @@ } | ||
function setLevel(level) { | ||
currentLevel = level; | ||
for (var key in loggers) { | ||
loggers[key].setLevel(level); | ||
} | ||
} | ||
@@ -116,3 +118,2 @@ | ||
loggers = {}; | ||
currentLevel = logLevel.none; | ||
appenders = []; | ||
@@ -126,2 +127,4 @@ slice = Array.prototype.slice; | ||
this.level = logLevel.none; | ||
if (key !== loggerConstructionKey) { | ||
@@ -142,2 +145,6 @@ throw new Error('Cannot instantiate "Logger". Use "getLogger" instead.'); | ||
Logger.prototype.setLevel = function setLevel(level) { | ||
this.level = level; | ||
}; | ||
return Logger; | ||
@@ -144,0 +151,0 @@ }()); |
@@ -1,1 +0,1 @@ | ||
{"name":"aurelia-logging","children":[{"id":25,"name":"Logger","kind":128,"kindString":"Class","flags":{"isExported":true},"comment":{"shortText":"A logger logs messages to a set of appenders, depending on the log level that is set."},"children":[{"id":27,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"comment":{"shortText":"You cannot instantiate the logger directly - you must use the getLogger method instead."},"signatures":[{"id":28,"name":"new Logger","kind":16384,"kindString":"Constructor signature","flags":{},"comment":{"shortText":"You cannot instantiate the logger directly - you must use the getLogger method instead."},"parameters":[{"id":29,"name":"id","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"string"}},{"id":30,"name":"key","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"Object"}}],"type":{"type":"reference","name":"Logger","id":25}}]},{"id":26,"name":"id","kind":1024,"kindString":"Property","flags":{"isExported":true},"comment":{"shortText":"The id that the logger was created with."},"type":{"type":"instrinct","name":"string"}},{"id":31,"name":"debug","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":32,"name":"debug","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Logs a debug message."},"parameters":[{"id":33,"name":"message","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The message to log."},"type":{"type":"instrinct","name":"string"}},{"id":34,"name":"rest","kind":32768,"kindString":"Parameter","flags":{"isRest":true},"comment":{"text":"The data to log.\n"},"type":{"type":"instrinct","isArray":true,"name":"any"}}],"type":{"type":"instrinct","name":"void"}}]},{"id":43,"name":"error","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":44,"name":"error","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Logs an error."},"parameters":[{"id":45,"name":"message","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The message to log."},"type":{"type":"instrinct","name":"string"}},{"id":46,"name":"rest","kind":32768,"kindString":"Parameter","flags":{"isRest":true},"comment":{"text":"The data to log.\n"},"type":{"type":"instrinct","isArray":true,"name":"any"}}],"type":{"type":"instrinct","name":"void"}}]},{"id":35,"name":"info","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":36,"name":"info","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Logs info."},"parameters":[{"id":37,"name":"message","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The message to log."},"type":{"type":"instrinct","name":"string"}},{"id":38,"name":"rest","kind":32768,"kindString":"Parameter","flags":{"isRest":true},"comment":{"text":"The data to log.\n"},"type":{"type":"instrinct","isArray":true,"name":"any"}}],"type":{"type":"instrinct","name":"void"}}]},{"id":39,"name":"warn","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":40,"name":"warn","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Logs a warning."},"parameters":[{"id":41,"name":"message","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The message to log."},"type":{"type":"instrinct","name":"string"}},{"id":42,"name":"rest","kind":32768,"kindString":"Parameter","flags":{"isRest":true},"comment":{"text":"The data to log.\n"},"type":{"type":"instrinct","isArray":true,"name":"any"}}],"type":{"type":"instrinct","name":"void"}}]}],"groups":[{"title":"Constructors","kind":512,"children":[27]},{"title":"Properties","kind":1024,"children":[26]},{"title":"Methods","kind":2048,"children":[31,43,35,39]}]},{"id":8,"name":"Appender","kind":256,"kindString":"Interface","flags":{"isExported":true},"comment":{"shortText":"Implemented by classes which wish to append log data to a target data store."},"children":[{"id":9,"name":"debug","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":10,"name":"debug","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Appends a debug log."},"parameters":[{"id":11,"name":"logger","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The source logger."},"type":{"type":"reference","name":"Logger","id":25}},{"id":12,"name":"rest","kind":32768,"kindString":"Parameter","flags":{"isRest":true},"comment":{"text":"The data to log.\n"},"type":{"type":"instrinct","isArray":true,"name":"any"}}],"type":{"type":"instrinct","name":"void"}}]},{"id":21,"name":"error","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":22,"name":"error","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Appends an error log."},"parameters":[{"id":23,"name":"logger","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The source logger."},"type":{"type":"reference","name":"Logger","id":25}},{"id":24,"name":"rest","kind":32768,"kindString":"Parameter","flags":{"isRest":true},"comment":{"text":"The data to log.\n"},"type":{"type":"instrinct","isArray":true,"name":"any"}}],"type":{"type":"instrinct","name":"void"}}]},{"id":13,"name":"info","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":14,"name":"info","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Appends an info log."},"parameters":[{"id":15,"name":"logger","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The source logger."},"type":{"type":"reference","name":"Logger","id":25}},{"id":16,"name":"rest","kind":32768,"kindString":"Parameter","flags":{"isRest":true},"comment":{"text":"The data to log.\n"},"type":{"type":"instrinct","isArray":true,"name":"any"}}],"type":{"type":"instrinct","name":"void"}}]},{"id":17,"name":"warn","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":18,"name":"warn","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Appends a warning log."},"parameters":[{"id":19,"name":"logger","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The source logger."},"type":{"type":"reference","name":"Logger","id":25}},{"id":20,"name":"rest","kind":32768,"kindString":"Parameter","flags":{"isRest":true},"comment":{"text":"The data to log.\n"},"type":{"type":"instrinct","isArray":true,"name":"any"}}],"type":{"type":"instrinct","name":"void"}}]}],"groups":[{"title":"Methods","kind":2048,"children":[9,21,13,17]}]},{"id":2,"name":"LogLevel","kind":256,"kindString":"Interface","flags":{"isExported":true},"comment":{"shortText":"Specifies the available logging levels."},"children":[{"id":7,"name":"debug","kind":1024,"kindString":"Property","flags":{"isExported":true},"comment":{"shortText":"Log all messages."},"type":{"type":"instrinct","name":"number"}},{"id":4,"name":"error","kind":1024,"kindString":"Property","flags":{"isExported":true},"comment":{"shortText":"Log only error messages."},"type":{"type":"instrinct","name":"number"}},{"id":6,"name":"info","kind":1024,"kindString":"Property","flags":{"isExported":true},"comment":{"shortText":"Log informational messages or above."},"type":{"type":"instrinct","name":"number"}},{"id":3,"name":"none","kind":1024,"kindString":"Property","flags":{"isExported":true},"comment":{"shortText":"No logging."},"type":{"type":"instrinct","name":"number"}},{"id":5,"name":"warn","kind":1024,"kindString":"Property","flags":{"isExported":true},"comment":{"shortText":"Log warnings messages or above."},"type":{"type":"instrinct","name":"number"}}],"groups":[{"title":"Properties","kind":1024,"children":[7,4,6,3,5]}]},{"id":47,"name":"logLevel","kind":32,"kindString":"Variable","flags":{"isExported":true},"comment":{"shortText":"Specifies the available logging levels."},"type":{"type":"reference","name":"LogLevel","id":2}},{"id":51,"name":"addAppender","kind":64,"kindString":"Function","flags":{"isExported":true},"signatures":[{"id":52,"name":"addAppender","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Adds an appender capable of processing logs and channeling them to an output."},"parameters":[{"id":53,"name":"appender","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"An appender instance to begin processing logs with.\n"},"type":{"type":"reference","name":"Appender","id":8}}],"type":{"type":"instrinct","name":"void"}}]},{"id":48,"name":"getLogger","kind":64,"kindString":"Function","flags":{"isExported":true},"signatures":[{"id":49,"name":"getLogger","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Gets the instance of a logger associated with a particular id (or creates one if it doesn't already exist).","returns":"The instance of the logger, or creates a new logger if none exists for that id.\n"},"parameters":[{"id":50,"name":"id","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The id of the logger you wish to get an instance of."},"type":{"type":"instrinct","name":"string"}}],"type":{"type":"reference","name":"Logger","id":25}}]},{"id":54,"name":"setLevel","kind":64,"kindString":"Function","flags":{"isExported":true},"signatures":[{"id":55,"name":"setLevel","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Sets the level of logging for the application loggers."},"parameters":[{"id":56,"name":"level","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"Matches a value of logLevel specifying the level of logging.\n"},"type":{"type":"instrinct","name":"number"}}],"type":{"type":"instrinct","name":"void"}}]}],"groups":[{"title":"Classes","kind":128,"children":[25]},{"title":"Interfaces","kind":256,"children":[8,2]},{"title":"Variables","kind":32,"children":[47]},{"title":"Functions","kind":64,"children":[51,48,54]}]} | ||
{"name":"aurelia-logging","children":[{"id":25,"name":"Logger","kind":128,"kindString":"Class","flags":{"isExported":true},"comment":{"shortText":"A logger logs messages to a set of appenders, depending on the log level that is set."},"children":[{"id":28,"name":"constructor","kind":512,"kindString":"Constructor","flags":{"isExported":true},"comment":{"shortText":"You cannot instantiate the logger directly - you must use the getLogger method instead."},"signatures":[{"id":29,"name":"new Logger","kind":16384,"kindString":"Constructor signature","flags":{},"comment":{"shortText":"You cannot instantiate the logger directly - you must use the getLogger method instead."},"parameters":[{"id":30,"name":"id","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"instrinct","name":"string"}},{"id":31,"name":"key","kind":32768,"kindString":"Parameter","flags":{},"type":{"type":"reference","name":"Object"}}],"type":{"type":"reference","name":"Logger","id":25}}]},{"id":26,"name":"id","kind":1024,"kindString":"Property","flags":{"isExported":true},"comment":{"shortText":"The id that the logger was created with."},"type":{"type":"instrinct","name":"string"}},{"id":27,"name":"level","kind":1024,"kindString":"Property","flags":{"isExported":true},"comment":{"shortText":"The logging severity level for this logger"},"type":{"type":"instrinct","name":"number"}},{"id":32,"name":"debug","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":33,"name":"debug","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Logs a debug message."},"parameters":[{"id":34,"name":"message","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The message to log."},"type":{"type":"instrinct","name":"string"}},{"id":35,"name":"rest","kind":32768,"kindString":"Parameter","flags":{"isRest":true},"comment":{"text":"The data to log.\n"},"type":{"type":"instrinct","isArray":true,"name":"any"}}],"type":{"type":"instrinct","name":"void"}}]},{"id":44,"name":"error","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":45,"name":"error","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Logs an error."},"parameters":[{"id":46,"name":"message","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The message to log."},"type":{"type":"instrinct","name":"string"}},{"id":47,"name":"rest","kind":32768,"kindString":"Parameter","flags":{"isRest":true},"comment":{"text":"The data to log.\n"},"type":{"type":"instrinct","isArray":true,"name":"any"}}],"type":{"type":"instrinct","name":"void"}}]},{"id":36,"name":"info","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":37,"name":"info","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Logs info."},"parameters":[{"id":38,"name":"message","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The message to log."},"type":{"type":"instrinct","name":"string"}},{"id":39,"name":"rest","kind":32768,"kindString":"Parameter","flags":{"isRest":true},"comment":{"text":"The data to log.\n"},"type":{"type":"instrinct","isArray":true,"name":"any"}}],"type":{"type":"instrinct","name":"void"}}]},{"id":48,"name":"setLevel","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":49,"name":"setLevel","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Sets the level of logging this logger"},"parameters":[{"id":50,"name":"level","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"Matches a value of logLevel specifying the level of logging.\n"},"type":{"type":"reference","name":"LogLevel","id":2}}],"type":{"type":"instrinct","name":"void"}}]},{"id":40,"name":"warn","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":41,"name":"warn","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Logs a warning."},"parameters":[{"id":42,"name":"message","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The message to log."},"type":{"type":"instrinct","name":"string"}},{"id":43,"name":"rest","kind":32768,"kindString":"Parameter","flags":{"isRest":true},"comment":{"text":"The data to log.\n"},"type":{"type":"instrinct","isArray":true,"name":"any"}}],"type":{"type":"instrinct","name":"void"}}]}],"groups":[{"title":"Constructors","kind":512,"children":[28]},{"title":"Properties","kind":1024,"children":[26,27]},{"title":"Methods","kind":2048,"children":[32,44,36,48,40]}]},{"id":8,"name":"Appender","kind":256,"kindString":"Interface","flags":{"isExported":true},"comment":{"shortText":"Implemented by classes which wish to append log data to a target data store."},"children":[{"id":9,"name":"debug","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":10,"name":"debug","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Appends a debug log."},"parameters":[{"id":11,"name":"logger","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The source logger."},"type":{"type":"reference","name":"Logger","id":25}},{"id":12,"name":"rest","kind":32768,"kindString":"Parameter","flags":{"isRest":true},"comment":{"text":"The data to log.\n"},"type":{"type":"instrinct","isArray":true,"name":"any"}}],"type":{"type":"instrinct","name":"void"}}]},{"id":21,"name":"error","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":22,"name":"error","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Appends an error log."},"parameters":[{"id":23,"name":"logger","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The source logger."},"type":{"type":"reference","name":"Logger","id":25}},{"id":24,"name":"rest","kind":32768,"kindString":"Parameter","flags":{"isRest":true},"comment":{"text":"The data to log.\n"},"type":{"type":"instrinct","isArray":true,"name":"any"}}],"type":{"type":"instrinct","name":"void"}}]},{"id":13,"name":"info","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":14,"name":"info","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Appends an info log."},"parameters":[{"id":15,"name":"logger","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The source logger."},"type":{"type":"reference","name":"Logger","id":25}},{"id":16,"name":"rest","kind":32768,"kindString":"Parameter","flags":{"isRest":true},"comment":{"text":"The data to log.\n"},"type":{"type":"instrinct","isArray":true,"name":"any"}}],"type":{"type":"instrinct","name":"void"}}]},{"id":17,"name":"warn","kind":2048,"kindString":"Method","flags":{"isExported":true},"signatures":[{"id":18,"name":"warn","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Appends a warning log."},"parameters":[{"id":19,"name":"logger","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The source logger."},"type":{"type":"reference","name":"Logger","id":25}},{"id":20,"name":"rest","kind":32768,"kindString":"Parameter","flags":{"isRest":true},"comment":{"text":"The data to log.\n"},"type":{"type":"instrinct","isArray":true,"name":"any"}}],"type":{"type":"instrinct","name":"void"}}]}],"groups":[{"title":"Methods","kind":2048,"children":[9,21,13,17]}]},{"id":2,"name":"LogLevel","kind":256,"kindString":"Interface","flags":{"isExported":true},"comment":{"shortText":"Specifies the available logging levels."},"children":[{"id":7,"name":"debug","kind":1024,"kindString":"Property","flags":{"isExported":true},"comment":{"shortText":"Log all messages."},"type":{"type":"instrinct","name":"number"}},{"id":4,"name":"error","kind":1024,"kindString":"Property","flags":{"isExported":true},"comment":{"shortText":"Log only error messages."},"type":{"type":"instrinct","name":"number"}},{"id":6,"name":"info","kind":1024,"kindString":"Property","flags":{"isExported":true},"comment":{"shortText":"Log informational messages or above."},"type":{"type":"instrinct","name":"number"}},{"id":3,"name":"none","kind":1024,"kindString":"Property","flags":{"isExported":true},"comment":{"shortText":"No logging."},"type":{"type":"instrinct","name":"number"}},{"id":5,"name":"warn","kind":1024,"kindString":"Property","flags":{"isExported":true},"comment":{"shortText":"Log warnings messages or above."},"type":{"type":"instrinct","name":"number"}}],"groups":[{"title":"Properties","kind":1024,"children":[7,4,6,3,5]}]},{"id":51,"name":"logLevel","kind":32,"kindString":"Variable","flags":{"isExported":true},"comment":{"shortText":"Specifies the available logging levels."},"type":{"type":"reference","name":"LogLevel","id":2}},{"id":55,"name":"addAppender","kind":64,"kindString":"Function","flags":{"isExported":true},"signatures":[{"id":56,"name":"addAppender","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Adds an appender capable of processing logs and channeling them to an output."},"parameters":[{"id":57,"name":"appender","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"An appender instance to begin processing logs with.\n"},"type":{"type":"reference","name":"Appender","id":8}}],"type":{"type":"instrinct","name":"void"}}]},{"id":52,"name":"getLogger","kind":64,"kindString":"Function","flags":{"isExported":true},"signatures":[{"id":53,"name":"getLogger","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Gets the instance of a logger associated with a particular id (or creates one if it doesn't already exist).","returns":"The instance of the logger, or creates a new logger if none exists for that id.\n"},"parameters":[{"id":54,"name":"id","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"The id of the logger you wish to get an instance of."},"type":{"type":"instrinct","name":"string"}}],"type":{"type":"reference","name":"Logger","id":25}}]},{"id":58,"name":"setLevel","kind":64,"kindString":"Function","flags":{"isExported":true},"signatures":[{"id":59,"name":"setLevel","kind":4096,"kindString":"Call signature","flags":{},"comment":{"shortText":"Sets the level of logging for ALL the application loggers."},"parameters":[{"id":60,"name":"level","kind":32768,"kindString":"Parameter","flags":{},"comment":{"text":"Matches a value of logLevel specifying the level of logging.\n"},"type":{"type":"instrinct","name":"number"}}],"type":{"type":"instrinct","name":"void"}}]}],"groups":[{"title":"Classes","kind":128,"children":[25]},{"title":"Interfaces","kind":256,"children":[8,2]},{"title":"Variables","kind":32,"children":[51]},{"title":"Functions","kind":64,"children":[55,52,58]}]} |
@@ -0,1 +1,7 @@ | ||
# 1.1.0 | ||
### Features | ||
* Individual loggers now have a `level` property that can be used to override the default log level. | ||
<a name="1.0.0"></a> | ||
@@ -2,0 +8,0 @@ # [1.0.0](https://github.com/aurelia/logging/compare/1.0.0-rc.1.0.1...v1.0.0) (2016-07-27) |
@@ -9,4 +9,4 @@ <!-- | ||
Durandal Inc. offers paid support agreements. Further information regarding paid support | ||
may be obtained by emailing support@durandal.io | ||
Blue Spire offers paid support agreements. Further information regarding paid support | ||
may be obtained by emailing support@bluespire.com | ||
@@ -13,0 +13,0 @@ Future support requests submitted here will be closed. |
{ | ||
"name": "aurelia-logging", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A minimal but effective logging mechanism with support for log levels and pluggable log appenders.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -10,3 +10,3 @@ # aurelia-logging | ||
> To keep up to date on [Aurelia](http://www.aurelia.io/), please visit and subscribe to [the official blog](http://blog.durandal.io/) and [our email list](http://durandal.us10.list-manage1.com/subscribe?u=dae7661a3872ee02b519f6f29&id=3de6801ccc). We also invite you to [follow us on twitter](https://twitter.com/aureliaeffect). If you have questions, please [join our community on Gitter](https://gitter.im/aurelia/discuss). If you would like to have deeper insight into our development process, please install the [ZenHub](https://zenhub.io) Chrome or Firefox Extension and visit any of our repository's boards. You can get an overview of all Aurelia work by visiting [the framework board](https://github.com/aurelia/framework#boards). | ||
> To keep up to date on [Aurelia](http://www.aurelia.io/), please visit and subscribe to [the official blog](http://blog.aurelia.io/) and [our email list](http://eepurl.com/ces50j). We also invite you to [follow us on twitter](https://twitter.com/aureliaeffect). If you have questions, please [join our community on Gitter](https://gitter.im/aurelia/discuss) or use [stack overflow](http://stackoverflow.com/search?q=aurelia). Documentation can be found [in our developer hub](http://aurelia.io/hub.html). If you would like to have deeper insight into our development process, please install the [ZenHub](https://zenhub.io) Chrome or Firefox Extension and visit any of our repository's boards. | ||
@@ -13,0 +13,0 @@ ## Platform Support |
@@ -39,3 +39,2 @@ /** | ||
let loggers = {}; | ||
let currentLevel = logLevel.none; | ||
let appenders = []; | ||
@@ -59,3 +58,3 @@ let slice = Array.prototype.slice; | ||
function debug() { | ||
if (currentLevel < 4) { | ||
if (this.level < 4) { | ||
return; | ||
@@ -68,3 +67,3 @@ } | ||
function info() { | ||
if (currentLevel < 3) { | ||
if (this.level < 3) { | ||
return; | ||
@@ -77,3 +76,3 @@ } | ||
function warn() { | ||
if (currentLevel < 2) { | ||
if (this.level < 2) { | ||
return; | ||
@@ -86,3 +85,3 @@ } | ||
function error() { | ||
if (currentLevel < 1) { | ||
if (this.level < 1) { | ||
return; | ||
@@ -174,3 +173,3 @@ } | ||
/** | ||
* Sets the level of logging for the application loggers. | ||
* Sets the level of logging for ALL the application loggers. | ||
* | ||
@@ -180,3 +179,5 @@ * @param level Matches a value of logLevel specifying the level of logging. | ||
export function setLevel(level: number): void { | ||
currentLevel = level; | ||
for (let key in loggers) { | ||
loggers[key].setLevel(level); | ||
} | ||
} | ||
@@ -194,2 +195,7 @@ | ||
/** | ||
* The logging severity level for this logger | ||
*/ | ||
level: number = logLevel.none; | ||
/** | ||
* You cannot instantiate the logger directly - you must use the getLogger method instead. | ||
@@ -236,2 +242,11 @@ */ | ||
error(message: string, ...rest: any[]): void {} | ||
/** | ||
* Sets the level of logging this logger | ||
* | ||
* @param level Matches a value of logLevel specifying the level of logging. | ||
*/ | ||
setLevel(level: LogLevel): void { | ||
this.level = level; | ||
} | ||
} |
@@ -8,2 +8,6 @@ import * as LogManager from '../src/index'; | ||
}); | ||
it('should default to logLevel none', () => { | ||
var logger = LogManager.getLogger('test2'); | ||
expect(logger.level).toBe(LogManager.logLevel.none); | ||
}); | ||
}); | ||
@@ -134,2 +138,52 @@ | ||
}); | ||
describe('setting logLevel per individual logger instance', () => | ||
{ | ||
it('should not log if specific logger logLevel is none', () => { | ||
// get a new logger we can squelch individually | ||
let logger2 = LogManager.getLogger('test2'); | ||
// sets log level for ALL loggers to debug | ||
LogManager.setLevel(LogManager.logLevel.debug); | ||
// set logger-specific level - turning off logging for the logger2 source | ||
logger2.setLevel(LogManager.logLevel.none); | ||
logger.debug('foo'); // this should log | ||
logger2.debug('foo'); // this should not | ||
expect(testAppender.debug.calls.count()).toBe(1); | ||
}); | ||
it('can log at different levels for different loggers', () => { | ||
var logger2 = LogManager.getLogger('test2'); | ||
logger.setLevel(LogManager.logLevel.error); | ||
logger2.setLevel(LogManager.logLevel.debug); | ||
logger.debug('foo'); | ||
logger.info('for'); | ||
logger.error('foo'); | ||
logger.warn('foo'); | ||
logger2.debug('foo'); | ||
expect(testAppender.debug.calls.count()).toBe(1); | ||
expect(testAppender.debug.calls.argsFor(0)).toEqual([jasmine.objectContaining({ id: 'test2'}), 'foo']); | ||
expect(testAppender.error.calls.count()).toBe(1); | ||
expect(testAppender.error.calls.argsFor(0)).toEqual([jasmine.objectContaining({ id: 'test'}), 'foo']); | ||
}); | ||
it('setting LogManager log level resets any logger-specific levels', () => { | ||
var logger2 = LogManager.getLogger('test2'); | ||
logger.setLevel(LogManager.logLevel.warn); | ||
logger2.setLevel(LogManager.logLevel.debug); | ||
// this overrides the individual log levels set above | ||
LogManager.setLevel(LogManager.logLevel.error); | ||
expect(logger2.level).toBe(LogManager.logLevel.error); | ||
expect(logger.level).toBe(LogManager.logLevel.error); | ||
}); | ||
}); | ||
}); |
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
141904
2130
2