mirror of
https://github.com/log4js-node/log4js-node.git
synced 2025-12-08 19:26:01 +00:00
Merge pull request #421 from nwoltman/logging-perf
Improve core logging performance
This commit is contained in:
commit
478da4a721
@ -33,7 +33,7 @@ function wrapErrorsWithInspect(items) {
|
||||
if (semver.satisfies(process.version, '>=6')) {
|
||||
return util.format(item);
|
||||
} else {
|
||||
return util.format(item) + '\n' + item.stack;
|
||||
return util.format(item) + '\n' + item.stack;
|
||||
}
|
||||
} };
|
||||
} else {
|
||||
@ -43,7 +43,14 @@ function wrapErrorsWithInspect(items) {
|
||||
}
|
||||
|
||||
function formatLogData(logData) {
|
||||
var data = Array.isArray(logData) ? logData : Array.prototype.slice.call(arguments);
|
||||
var data = logData;
|
||||
if (!Array.isArray(data)) {
|
||||
var numArgs = arguments.length;
|
||||
data = new Array(numArgs);
|
||||
for (var i = 0; i < numArgs; i++) {
|
||||
data[i] = arguments[i];
|
||||
}
|
||||
}
|
||||
return util.format.apply(util, wrapErrorsWithInspect(data));
|
||||
}
|
||||
|
||||
|
||||
@ -82,7 +82,10 @@ function addLevelMethods(level) {
|
||||
Logger.prototype[levelMethod] = function () {
|
||||
if (logWritesEnabled && this.isLevelEnabled(level)) {
|
||||
var numArgs = arguments.length;
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
var args = new Array(numArgs);
|
||||
for (var i = 0; i < numArgs; i++) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
this._log(level, args);
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user