Comparing version 0.1.2 to 0.1.3
@@ -0,1 +1,13 @@ | ||
#0.1.3/2012-08-16 | ||
* new array methods | ||
* sort | ||
* min | ||
* max | ||
* difference | ||
* avg | ||
* Logging changes | ||
* Added `comb.logger` as shortcut to get a logger | ||
* Changed appenders to register themselves for dynamic appender creation | ||
* Updated docs | ||
#0.1.2/2012-07-17 | ||
@@ -2,0 +14,0 @@ * Bug fixes |
@@ -1,2 +0,2 @@ | ||
var obj = require("./object"), misc = require("./misc"), number = require("./number.js"); | ||
var obj = require("./object"), misc = require("./misc"), string = require("./string"), isString = string.isString, number = require("./number.js"); | ||
@@ -7,3 +7,3 @@ | ||
var isArray = exports.isArray = function (obj) { | ||
return obj && obj instanceof Array; | ||
return Array.isArray(obj); | ||
}; | ||
@@ -46,2 +46,42 @@ | ||
var _sort = (function () { | ||
var isAll = function (arr, test) { | ||
return arr.every(test); | ||
}; | ||
var defaultCmp = function (a, b) { | ||
return a - b; | ||
}; | ||
return function _sort(arr, property) { | ||
var ret = []; | ||
if (isArray(arr)) { | ||
ret = arr.slice(); | ||
if (property) { | ||
if (typeof property == "function") { | ||
ret.sort(property); | ||
} else { | ||
ret.sort(function (a, b) { | ||
var aProp = a[property], bProp = b[property]; | ||
if (isString(aProp) && isString(bProp)) { | ||
return aProp > bProp ? 1 : aProp < bProp ? -1 : 0; | ||
} else { | ||
return aProp - bProp; | ||
} | ||
}); | ||
} | ||
} else { | ||
if (isAll(ret, isString)) { | ||
ret.sort(); | ||
} else { | ||
ret.sort(defaultCmp); | ||
} | ||
} | ||
} | ||
return ret; | ||
}; | ||
})(); | ||
var comb = exports, array; | ||
@@ -116,4 +156,104 @@ /** | ||
/** | ||
* Averages an array of numbers. | ||
* @example | ||
* | ||
* comb.array.avg([1,2,3]); //2 | ||
* | ||
* @param {Number[]} array - an array of numbers | ||
* @return {Number} the average of all the numbers in the array. | ||
* @throws {Error} if the array is not all numbers. | ||
*/ | ||
avg:function (arr) { | ||
arr = arr || []; | ||
if (arr.length) { | ||
var sum = array.sum(arr); | ||
if (number.isNumber(sum)) { | ||
return sum / arr.length; | ||
} else { | ||
throw new Error("Cannot average an array of non numbers."); | ||
} | ||
} else { | ||
return 0; | ||
} | ||
}, | ||
/** | ||
* Allows the sorting of an array based on a property name instead. This can also | ||
* act as a sort that does not change the original array. | ||
* | ||
* <b>NOTE:</b> this does not change the original array! | ||
* | ||
* @example | ||
* comb.array.sort([{a : 1}, {a : 2}, {a : -2}], "a"); //[{a : -2}, {a : 1}, {a : 2}]; | ||
* @param {Array} arr the array to sort | ||
* @param {String|Function} cmp the property to sort on. Or a function used to compare. | ||
* @return {Array} a copy of the original array that is sorted. | ||
*/ | ||
sort:function (arr, cmp) { | ||
return _sort(arr, cmp); | ||
}, | ||
/** | ||
* Finds that min value of an array. If a second argument is provided and it is a function | ||
* it will be used as a comparator function. If the second argument is a string then it will be used | ||
* as a property look up on each item. | ||
* | ||
* @example | ||
* comb.array.max([{a : 1}, {a : 2}, {a : -2}], "a"); //{a : -2} | ||
* comb.array.max([{a : 1}, {a : 2}, {a : -2}], function(a,b){ | ||
* return a.a - b.a | ||
* }); //{a : -2} | ||
* | ||
* @param {Array} arr the array to find the min value on | ||
* @param {String|Function} cmp the property to sort on. Or a function used to compare. | ||
* @return {*} | ||
*/ | ||
min:function (arr, cmp) { | ||
return _sort(arr, cmp)[0]; | ||
}, | ||
/** | ||
* Finds that max value of an array. If a second argument is provided and it is a function | ||
* it will be used as a comparator function. If the second argument is a string then it will be used | ||
* as a property look up on each item. | ||
* | ||
* @example | ||
* comb.array.max([{a : 1}, {a : 2}, {a : -2}], "a"); //{a : 2} | ||
* comb.array.max([{a : 1}, {a : 2}, {a : -2}], function(a,b){ | ||
* return a.a - b.a | ||
* }); //{a : 2} | ||
* | ||
* @param arr the array to find the max value on | ||
* @param {String|Function} cmp the property to sort on. Or a function used to compare. | ||
* @return {*} the maximum value of the array based on the provided cmp. | ||
*/ | ||
max:function (arr, cmp) { | ||
return _sort(arr, cmp)[arr.length - 1]; | ||
}, | ||
/** | ||
* Finds the difference of the two arrays. | ||
* | ||
* @example | ||
* | ||
* comb.array.difference([1,2,3], [2,3]); //[1] | ||
* comb.array.difference(["a","b",3], [3]); //["a","b"] | ||
* | ||
* @param {Array} arr1 the array we are subtracting from | ||
* @param {Array} arr2 the array we are subtracting from arr1 | ||
* @return {*} the difference of the arrays. | ||
*/ | ||
difference:function (arr1, arr2) { | ||
var ret = arr1, args = array.flatten(misc.argsToArray(arguments).slice(1)); | ||
if (isArray(arr1)) { | ||
ret = arr1.filter(function (a) { | ||
return args.indexOf(a) === -1; | ||
}); | ||
} | ||
return ret; | ||
}, | ||
/** | ||
* Removes duplicates from an array | ||
@@ -131,3 +271,3 @@ * | ||
var ret = arr.reduce(function (a, b) { | ||
if (a.indexOf(b) == -1) { | ||
if (a.indexOf(b) === -1) { | ||
return a.concat(b); | ||
@@ -142,2 +282,6 @@ } else { | ||
unique:function (arr) { | ||
return array.removeDuplicates(arr); | ||
}, | ||
/** | ||
@@ -526,4 +670,5 @@ * Rotates an array the number of specified positions | ||
}; | ||
} | ||
; | ||
array = comb.array; | ||
array = comb.array; |
var define = require("../../define.js").define, base = require("../../base"), Level = require("../level"); | ||
var APPENDER_TYPES = {}; | ||
/** | ||
@@ -108,4 +111,58 @@ * @class Base class for all appenders | ||
} | ||
}, | ||
"static":{ | ||
/**@lends comb.logging.appenders.Appender*/ | ||
/** | ||
* Register an appender so it can be used with {@link comb.logging.PropertyConfigurator} | ||
* | ||
* @example | ||
* | ||
* var Appender = comb.logging.appenders.Appender; | ||
* comb.define(Appender, { | ||
* instance : { | ||
* append : function(event){ | ||
* //log the message | ||
* } | ||
* } | ||
* }).registerType("MyAppender").as(module); | ||
* | ||
* @param {String} type the identifier for your appender type. | ||
* @return returns the Appender class for chaining. | ||
*/ | ||
registerType:function (type) { | ||
if (base.isString(type)) { | ||
APPENDER_TYPES[type.toLowerCase()] = this; | ||
} | ||
return this; | ||
}, | ||
/** | ||
* Acts as a factory for appenders. | ||
* | ||
* @example | ||
* | ||
* var logging = comb.logging, | ||
* Logger = logging.Logger, | ||
* Appender = logging.appenders.Appender; | ||
* | ||
* var logger = comb.logging.Logger.getLogger("my.logger"); | ||
* logger.addAppender(Appender.createAppender("consoleAppender")); | ||
* | ||
* @param {String} type the type of appender to create. | ||
* @param {Object} [options={}] additional options to pass to the appender. | ||
* @return {comb.logging.appenders.Appender} an appender to add to a logger. | ||
*/ | ||
createAppender:function (type, options) { | ||
var caseType = type.toLowerCase(); | ||
if (caseType in APPENDER_TYPES) { | ||
return new APPENDER_TYPES[caseType](options); | ||
} else { | ||
throw new Error(type + " appender is not registered!"); | ||
} | ||
} | ||
} | ||
}).as(module); |
@@ -10,29 +10,29 @@ var define = require("../../define.js").define, base = require("../../base"), string = base.string, style = string.style, format = string.format, Appender = require("./appender"), Level = require("../level"); | ||
*/ | ||
exports = module.exports = define(Appender, { | ||
instance : { | ||
define(Appender, { | ||
instance:{ | ||
constructor : function(options){ | ||
options = options || {}; | ||
!options.name && (options.name = "consoleAppender"); | ||
this._super(arguments, [options]); | ||
}, | ||
constructor:function (options) { | ||
options = options || {}; | ||
!options.name && (options.name = "consoleAppender"); | ||
this._super(arguments, [options]); | ||
}, | ||
append : function(event) { | ||
if (this._canAppend(event)) { | ||
var message = format(this.__pattern, event); | ||
var level = event.level; | ||
if (Level.ERROR.equals(level) || Level.FATAL.equals(level)) { | ||
console.log(style(message, "red")); | ||
} else if(Level.WARN.equals(level)){ | ||
console.log(style(message, "yellow")); | ||
}else if (Level.DEBUG.equals(level)) { | ||
console.log(style(message, "magenta")); | ||
} else if (Level.TRACE.equals(level)) { | ||
console.log(style(message, "cyan")); | ||
} else { | ||
console.log(message); | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
append:function (event) { | ||
if (this._canAppend(event)) { | ||
var message = format(this.__pattern, event); | ||
var level = event.level; | ||
if (Level.ERROR.equals(level) || Level.FATAL.equals(level)) { | ||
console.log(style(message, "red")); | ||
} else if (Level.WARN.equals(level)) { | ||
console.log(style(message, "yellow")); | ||
} else if (Level.DEBUG.equals(level)) { | ||
console.log(style(message, "magenta")); | ||
} else if (Level.TRACE.equals(level)) { | ||
console.log(style(message, "cyan")); | ||
} else { | ||
console.log(message); | ||
} | ||
} | ||
} | ||
} | ||
}).registerType("ConsoleAppender").as(module); |
@@ -14,3 +14,2 @@ var define = require("../../define.js").define, | ||
/** | ||
@@ -51,3 +50,3 @@ * @class Appends messages to a file. | ||
*/ | ||
exports = module.exports = define(Appender, { | ||
define(Appender, { | ||
instance:{ | ||
@@ -64,3 +63,2 @@ | ||
this.__pattern += "\n"; | ||
process.setMaxListeners(-1) | ||
base.listenForExit(base.hitch(this, "__onExit")); | ||
@@ -70,3 +68,2 @@ }, | ||
__onExit:function () { | ||
@@ -90,2 +87,2 @@ var ret = new Promise(); | ||
} | ||
}); | ||
}).registerType("FileAppender").as(module); |
/**@ignore*/ | ||
exports.Appender = require("./appender"), | ||
exports.Appender = require("./appender"); | ||
/**@ignore*/ | ||
exports.ConsoleAppender = require("./consoleAppender"), | ||
exports.ConsoleAppender = require("./consoleAppender"); | ||
/**@ignore*/ | ||
exports.FileAppender = require("./fileAppender"), | ||
exports.FileAppender = require("./fileAppender"); | ||
/**@ignore*/ | ||
exports.JSONAppender = require("./jsonAppender"), | ||
exports.JSONAppender = require("./jsonAppender"); | ||
/**@ignore*/ | ||
exports.RollingFileAppender = require("./rollingFileAppender"); | ||
@@ -85,2 +85,2 @@ var define = require("../../define.js").define, | ||
} | ||
}).as(module); | ||
}).registerType("JSONAppender").as(module); |
var define = require("../../define.js").define, | ||
promise = require("../../promise"), | ||
Promise = promise.Promise, | ||
PromiseList = promise.PromiseList, | ||
base = require("../../base"), | ||
hitch = base.hitch, | ||
string = base.string, | ||
escape = base.regexp.escapeString, | ||
style = string.style, | ||
format = string.format, | ||
FileAppender = require("./fileAppender"), | ||
Level = require("../level"), | ||
fs = require("fs"), | ||
path = require("path"); | ||
promise = require("../../promise"), | ||
Promise = promise.Promise, | ||
PromiseList = promise.PromiseList, | ||
base = require("../../base"), | ||
hitch = base.hitch, | ||
string = base.string, | ||
escape = base.regexp.escapeString, | ||
style = string.style, | ||
format = string.format, | ||
FileAppender = require("./fileAppender"), | ||
Level = require("../level"), | ||
fs = require("fs"), | ||
path = require("path"); | ||
var conversion = { | ||
MB : 1048576, | ||
KB : 1024, | ||
GB : 1073741824 | ||
MB:1048576, | ||
KB:1024, | ||
GB:1073741824 | ||
}; | ||
var DEFAULT_SIZE = "10MB"; | ||
var convertToBytes = function(str) { | ||
var convertToBytes = function (str) { | ||
var ret = DEFAULT_SIZE; | ||
@@ -78,126 +78,135 @@ var match = str.match(/(\d+)(MB|KB|GB)$/); | ||
*/ | ||
exports = module.exports = define(FileAppender, { | ||
instance : { | ||
define(FileAppender, { | ||
instance:{ | ||
constructor : function(options) { | ||
options = options || {}; | ||
this.maxSize = options.maxSize || DEFAULT_SIZE; | ||
!options.name && (options.name = "rollingFileAppender"); | ||
this.maxBackupIndex = options.maxBackupIndex || 10; | ||
this.__queue = []; | ||
this.__inRollover = false; | ||
this._super([options]); | ||
fs.watchFile(this.__file, hitch(this, "__checkFile")); | ||
fs.stat(this.__file, hitch(this, function(err, stat) { | ||
this.__checkFile(stat); | ||
})); | ||
}, | ||
__watching:false, | ||
__checkFile : function(stats) { | ||
var ret = new Promise(); | ||
if (!this.__inRollover) { | ||
if (stats.size >= this.maxSize) { | ||
if (this.maxBackupIndex > 0) { | ||
this.__inRollover = true; | ||
this.__onExit().chain(hitch(this, "__rollover")).then(hitch(this, function() { | ||
var ws = fs.createWriteStream(this.__file, { flags: "w", encoding: this.__encoding}); | ||
ws.on("open", hitch(this, function() { | ||
this.__writeStream = ws; | ||
this.__inRollover = false; | ||
this.__checkQueue(); | ||
ret.callback(); | ||
})); | ||
}), hitch(ret, "errback", new Error("comb.logging.appenders.RollingFileAppender : error rolling over files"))); | ||
} else { | ||
this.__writeStream = fs.createWriteStream(this.__file, { flags: "w", encoding: this.__encoding}); | ||
constructor:function (options) { | ||
options = options || {}; | ||
this.maxSize = options.maxSize || DEFAULT_SIZE; | ||
!options.name && (options.name = "rollingFileAppender"); | ||
this.maxBackupIndex = options.maxBackupIndex || 10; | ||
this.__queue = []; | ||
this.__inRollover = false; | ||
this._super([options]); | ||
}, | ||
__startCheck:function () { | ||
if (!this.__watching) { | ||
this.__watching = true; | ||
fs.watchFile(this.__file, hitch(this, "__checkFile")); | ||
fs.stat(this.__file, hitch(this, function (err, stat) { | ||
this.__checkFile(stat); | ||
})); | ||
} | ||
}, | ||
__checkFile:function (stats) { | ||
var ret = new Promise(); | ||
if (!this.__inRollover) { | ||
if (stats.size >= this.maxSize) { | ||
if (this.maxBackupIndex > 0) { | ||
this.__inRollover = true; | ||
this.__onExit().chain(hitch(this, "__rollover")).then(hitch(this, function () { | ||
var ws = fs.createWriteStream(this.__file, { flags:"w", encoding:this.__encoding}); | ||
ws.on("open", hitch(this, function () { | ||
this.__writeStream = ws; | ||
this.__inRollover = false; | ||
this.__checkQueue(); | ||
ret.callback(); | ||
} | ||
} else { | ||
ret.callback(); | ||
} | ||
})); | ||
}), hitch(ret, "errback", new Error("comb.logging.appenders.RollingFileAppender : error rolling over files"))); | ||
} else { | ||
this.__writeStream = fs.createWriteStream(this.__file, { flags:"w", encoding:this.__encoding}); | ||
ret.callback(); | ||
} | ||
return ret; | ||
}, | ||
} else { | ||
ret.callback(); | ||
} | ||
} else { | ||
ret.callback(); | ||
} | ||
return ret; | ||
}, | ||
append : function(event) { | ||
if (this._canAppend(event)) { | ||
var ws = this.__writeStream; | ||
if (!this.__inRollover && ws && ws.writable) { | ||
this._super(arguments); | ||
append:function (event) { | ||
if (this._canAppend(event)) { | ||
!this.__watching && this.__startCheck(); | ||
var ws = this.__writeStream; | ||
if (!this.__inRollover && ws && ws.writable) { | ||
this._super(arguments); | ||
} else { | ||
this.__queue.push(event); | ||
} | ||
} | ||
}, | ||
__checkQueue:function () { | ||
this.__queue.forEach(this.append, this); | ||
this.__queue.length = 0; | ||
}, | ||
__rollover:function () { | ||
var ret = new Promise(), file = this.__file; | ||
var dir = path.dirname(file), baseName = new RegExp("(" + escape(path.basename(path.basename(file))) + ")(?:\\.(\\d*))*"); | ||
fs.readdir(dir, hitch(this, function (err, files) { | ||
files = files.filter( | ||
function (f) { | ||
var match = f.match(baseName); | ||
if (match) { | ||
return true; | ||
} else { | ||
this.__queue.push(event); | ||
return false; | ||
} | ||
}); | ||
files = files.sort(function (a, b) { | ||
var ret = 0; | ||
if (a > b) { | ||
ret = 0; | ||
} else if (a < b) { | ||
ret = 1; | ||
} | ||
}, | ||
__checkQueue : function() { | ||
this.__queue.forEach(this.append, this); | ||
this.__queue.length = 0; | ||
}, | ||
__rollover : function() { | ||
var ret = new Promise(), file = this.__file; | ||
var dir = path.dirname(file), baseName = new RegExp("(" + escape(path.basename(path.basename(file))) + ")(?:\\.(\\d*))*"); | ||
fs.readdir(dir, hitch(this, function(err, files) { | ||
files = files.filter( | ||
function(f) { | ||
var match = f.match(baseName); | ||
if (match) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
}); | ||
files = files.sort(function(a, b) { | ||
var ret = 0; | ||
if (a > b) { | ||
ret = 0; | ||
} else if (a < b) { | ||
ret = 1; | ||
} | ||
return ret; | ||
}); | ||
var count = files.length, i = 0; | ||
var checkFile = hitch(this, function() { | ||
if (count > 0) { | ||
var f = dir + "/" + files[i++]; | ||
if (count > this.maxBackupIndex) { | ||
//drop the file; | ||
count--; | ||
fs.unlink(f, function(err) { | ||
err ? ret.errback(err) : checkFile(); | ||
}); | ||
} else { | ||
//rename the file | ||
var rn = this.__file + "." + count--; | ||
fs.rename(f, rn, function(err) { | ||
err ? ret.errback(err) : checkFile(); | ||
}); | ||
} | ||
} else { | ||
ret.callback(); | ||
} | ||
}); | ||
checkFile(); | ||
})); | ||
return ret; | ||
}, | ||
}); | ||
var count = files.length, i = 0; | ||
var checkFile = hitch(this, function () { | ||
if (count > 0) { | ||
var f = dir + "/" + files[i++]; | ||
if (count > this.maxBackupIndex) { | ||
//drop the file; | ||
count--; | ||
fs.unlink(f, function (err) { | ||
err ? ret.errback(err) : checkFile(); | ||
}); | ||
} else { | ||
//rename the file | ||
var rn = this.__file + "." + count--; | ||
fs.rename(f, rn, function (err) { | ||
err ? ret.errback(err) : checkFile(); | ||
}); | ||
} | ||
} else { | ||
ret.callback(); | ||
} | ||
}); | ||
checkFile(); | ||
})); | ||
return ret; | ||
}, | ||
getters : { | ||
getters:{ | ||
maxSize : function() { | ||
return this.__maxSize; | ||
} | ||
}, | ||
maxSize:function () { | ||
return this.__maxSize; | ||
} | ||
}, | ||
setters : { | ||
maxSize : function(size) { | ||
this.__maxSize = size ? convertToBytes(size) : DEFAULT_SIZE; | ||
} | ||
} | ||
setters:{ | ||
maxSize:function (size) { | ||
this.__maxSize = size ? convertToBytes(size) : DEFAULT_SIZE; | ||
} | ||
}); | ||
} | ||
} | ||
}).registerType("RollingFileAppender").as(module); |
@@ -1,20 +0,23 @@ | ||
var define = require("../define.js").define, base = require("../base"), fs = require('fs'); | ||
var define = require("../define.js").define, base = require("../base"), fs = require('fs'), Appender = require("./appenders/appender.js"); | ||
var logging, Logger, Level, appenders, isProcessUnCaaughtEception = false; | ||
var logging, Logger, Level, appenders; | ||
var checkProcessUncaughtException = function () { | ||
//if (!isProcessUnCaaughtEception) { | ||
var rootLogger = Logger.getRootLogger(); | ||
if (!isProcessUnCaaughtEception) { | ||
process.on("uncaughtException", function (err) { | ||
if (rootLogger.appenders.length) { | ||
rootLogger.error(err); | ||
} else { | ||
console.error(err.stack); | ||
} | ||
}); | ||
isProcessUnCaaughtEception = true; | ||
} | ||
//} | ||
}; | ||
var checkProcessUncaughtException = (function () { | ||
var isProcessUnCaaughtEception = false; | ||
return function _checkProcessUncaughtException() { | ||
//if (!isProcessUnCaaughtEception) { | ||
var rootLogger = Logger.getRootLogger(); | ||
if (!isProcessUnCaaughtEception) { | ||
process.on("uncaughtException", function (err) { | ||
if (rootLogger.appenders.length) { | ||
rootLogger.error(err); | ||
} else { | ||
console.error(err.stack); | ||
} | ||
}); | ||
isProcessUnCaaughtEception = true; | ||
} | ||
//} | ||
}; | ||
})(); | ||
@@ -36,21 +39,3 @@ var parseProperties = function (properties) { | ||
if (type) { | ||
var appender; | ||
switch (type.toLowerCase()) { | ||
case "consoleappender": | ||
appender = appenders.ConsoleAppender; | ||
break; | ||
case "jsonappender": | ||
appender = appenders.JSONAppender; | ||
break; | ||
case "fileappender": | ||
appender = appenders.FileAppender; | ||
break; | ||
case "rollingfileappender": | ||
appender = appenders.RollingFileAppender; | ||
break; | ||
} | ||
if (appender) { | ||
logger.addAppender(new appender(appenderProps)); | ||
} | ||
logger.addAppender(Appender.createAppender(type, appenderProps)); | ||
} | ||
@@ -57,0 +42,0 @@ } |
var define = require("../define.js"), | ||
base = require("../base"), | ||
Level = require("./level"), | ||
appenders = require("./appenders"), | ||
configurators = require("./config"); | ||
base = require("../base"), | ||
Level = require("./level"), | ||
appenders = require("./appenders"), | ||
configurators = require("./config"); | ||
var rootTree; | ||
@@ -255,5 +255,7 @@ var LoggerTree = define.define(null, { | ||
* @param {String} message the message to log. | ||
* | ||
* @return {comb.logging.Logger} for chaining. | ||
*/ | ||
info:function (message) { | ||
this.log(Level.INFO, message); | ||
return this.log(Level.INFO, message); | ||
}, | ||
@@ -265,5 +267,7 @@ | ||
* @param {String} message the message to log. | ||
* | ||
* @return {comb.logging.Logger} for chaining. | ||
*/ | ||
debug:function (message) { | ||
this.log(Level.DEBUG, message); | ||
return this.log(Level.DEBUG, message); | ||
}, | ||
@@ -275,5 +279,7 @@ | ||
* @param {String} message the message to log. | ||
* | ||
* @return {comb.logging.Logger} for chaining. | ||
*/ | ||
error:function (message) { | ||
this.log(Level.ERROR, message); | ||
return this.log(Level.ERROR, message); | ||
}, | ||
@@ -285,5 +291,7 @@ | ||
* @param {String} message the message to log. | ||
* | ||
* @return {comb.logging.Logger} for chaining. | ||
*/ | ||
warn:function (message) { | ||
this.log(Level.WARN, message); | ||
return this.log(Level.WARN, message); | ||
}, | ||
@@ -295,5 +303,7 @@ | ||
* @param {String} message the message to log. | ||
* | ||
* @return {comb.logging.Logger} for chaining. | ||
*/ | ||
trace:function (message) { | ||
this.log(Level.TRACE, message); | ||
return this.log(Level.TRACE, message); | ||
}, | ||
@@ -305,5 +315,7 @@ | ||
* @param {String} message the message to log. | ||
* | ||
* @return {comb.logging.Logger} for chaining. | ||
*/ | ||
fatal:function (message) { | ||
this.log(Level.FATAL, message); | ||
return this.log(Level.FATAL, message); | ||
}, | ||
@@ -316,2 +328,4 @@ | ||
* @param {String} message the message to log. | ||
* | ||
* @return {comb.logging.Logger} for chaining. | ||
*/ | ||
@@ -337,6 +351,7 @@ log:function (level, message) { | ||
}; | ||
for (var i in appenders) { | ||
Object.keys(appenders).forEach(function (i) { | ||
appenders[i].append(event); | ||
} | ||
}); | ||
} | ||
return this; | ||
}, | ||
@@ -347,2 +362,4 @@ | ||
* @param {comb.logging.Appender} appender the appender to add. | ||
* | ||
* @return {comb.logging.Logger} for chaining. | ||
*/ | ||
@@ -360,2 +377,3 @@ addAppender:function (appender) { | ||
} | ||
return this; | ||
}, | ||
@@ -366,5 +384,8 @@ | ||
* @param {Array<comb.logging.Appender>} appenders | ||
* | ||
* @return {comb.logging.Logger} for chaining. | ||
*/ | ||
addAppenders:function (appenders) { | ||
appenders.forEach(base.hitch(this, "addAppender")); | ||
appenders.forEach(this.addAppender.bind(this)); | ||
return this; | ||
}, | ||
@@ -375,2 +396,3 @@ | ||
* @param {String} name the name of the appender | ||
* @return {comb.logging.Logger} for chaining. | ||
*/ | ||
@@ -382,2 +404,3 @@ removeAppender:function (name) { | ||
} | ||
return this; | ||
}, | ||
@@ -388,6 +411,8 @@ | ||
* | ||
* @param {Array<String>} appenders a list of names of appenders to remove | ||
* @param {String[]} appenders a list of names of appenders to remove | ||
* @return {comb.logging.Logger} for chaining. | ||
*/ | ||
removeAppenders:function (appenders) { | ||
appenders.forEach(this.removeAppender, this); | ||
return this; | ||
}, | ||
@@ -397,7 +422,8 @@ | ||
* Removes all appenders from this logger and sub loggers if this Logger is additive. | ||
* | ||
* @return {comb.logging.Logger} for chaining. | ||
*/ | ||
removeAllAppenders:function () { | ||
for (var i in this.__appenders) { | ||
this.removeAppender(i); | ||
} | ||
Object.keys(this.__appenders).forEach(this.removeAppender.bind(this)); | ||
return this; | ||
}, | ||
@@ -558,2 +584,15 @@ | ||
/** | ||
* | ||
* @function | ||
* @description Alias to {@link comb.logging.Logger.getLogger}. See {@link comb.logging.Logger} for more information. | ||
* | ||
* @example | ||
* | ||
* comb.logger("my.logger"); | ||
* | ||
* @memberOf comb | ||
*/ | ||
exports.logger = Logger.getLogger.bind(Logger); | ||
var rootLogger = new Logger(""); | ||
@@ -560,0 +599,0 @@ rootTree = rootLogger._tree; |
{ | ||
"name": "comb", | ||
"description": "A framework for node", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"keywords" : ["OO", "Object Oriented", "Collections", "Tree", "HashTable", "Pool", "Logging", "Promise", "Promises", "Proxy"], | ||
@@ -6,0 +6,0 @@ "repository": { |
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
306465
51
8924