2010-08-10 19:56:10 +08:00
|
|
|
/*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*jsl:option explicit*/
|
|
|
|
|
|
|
|
/**
|
2011-07-12 11:02:48 +08:00
|
|
|
* @fileoverview log4js is a library to log in JavaScript in similar manner
|
2010-08-10 19:56:10 +08:00
|
|
|
* than in log4j for Java. The API should be nearly the same.
|
2011-07-12 11:02:48 +08:00
|
|
|
*
|
2010-08-10 19:56:10 +08:00
|
|
|
* This file contains all log4js code and is the only file required for logging.
|
2011-07-12 11:02:48 +08:00
|
|
|
*
|
2010-08-10 19:56:10 +08:00
|
|
|
* <h3>Example:</h3>
|
|
|
|
* <pre>
|
2011-07-12 11:02:48 +08:00
|
|
|
* var logging = require('log4js');
|
2010-08-10 19:56:10 +08:00
|
|
|
* //add an appender that logs all messages to stdout.
|
|
|
|
* logging.addAppender(logging.consoleAppender());
|
|
|
|
* //add an appender that logs "some-category" to a file
|
|
|
|
* logging.addAppender(logging.fileAppender("file.log"), "some-category");
|
|
|
|
* //get a logger
|
2011-07-12 11:02:48 +08:00
|
|
|
* var log = logging.getLogger("some-category");
|
2010-08-10 19:56:10 +08:00
|
|
|
* log.setLevel(logging.levels.TRACE); //set the Level
|
2011-07-12 11:02:48 +08:00
|
|
|
*
|
2010-08-10 19:56:10 +08:00
|
|
|
* ...
|
2011-07-12 11:02:48 +08:00
|
|
|
*
|
2010-08-10 19:56:10 +08:00
|
|
|
* //call the log
|
|
|
|
* log.trace("trace me" );
|
|
|
|
* </pre>
|
|
|
|
*
|
|
|
|
* @version 1.0
|
|
|
|
* @author Stephan Strittmatter - http://jroller.com/page/stritti
|
|
|
|
* @author Seth Chisamore - http://www.chisamore.com
|
|
|
|
* @since 2005-05-20
|
|
|
|
* @static
|
|
|
|
* Website: http://log4js.berlios.de
|
|
|
|
*/
|
2011-07-12 11:02:48 +08:00
|
|
|
var events = require('events')
|
|
|
|
, fs = require('fs')
|
|
|
|
, path = require('path')
|
|
|
|
, sys = require('sys')
|
|
|
|
, layouts = require('./layouts')
|
|
|
|
, levels = require('./levels')
|
|
|
|
, DEFAULT_CATEGORY = '[default]'
|
|
|
|
, ALL_CATEGORIES = '[all]'
|
|
|
|
, appenders = {}
|
|
|
|
, loggers = {}
|
|
|
|
, appenderMakers = {
|
2011-01-16 10:05:13 +08:00
|
|
|
"file": function(config, fileAppender) {
|
|
|
|
var layout;
|
|
|
|
if (config.layout) {
|
2011-07-12 11:02:48 +08:00
|
|
|
layout = layouts.layout(config.layout.type, config.layout);
|
2010-12-04 17:49:39 +08:00
|
|
|
}
|
2011-01-16 10:05:13 +08:00
|
|
|
return fileAppender(config.filename, layout, config.maxLogSize, config.backups, config.pollInterval);
|
2010-12-04 17:49:39 +08:00
|
|
|
},
|
2011-01-16 10:05:13 +08:00
|
|
|
"console": function(config, fileAppender, consoleAppender) {
|
|
|
|
var layout;
|
|
|
|
if (config.layout) {
|
2011-07-12 11:02:48 +08:00
|
|
|
layout = layouts.layout(config.layout.type, config.layout);
|
2010-12-04 17:49:39 +08:00
|
|
|
}
|
2011-01-16 10:05:13 +08:00
|
|
|
return consoleAppender(layout);
|
|
|
|
},
|
|
|
|
"logLevelFilter": function(config, fileAppender, consoleAppender) {
|
|
|
|
var appender = appenderMakers[config.appender.type](config.appender, fileAppender, consoleAppender);
|
|
|
|
return logLevelFilter(config.level, appender);
|
|
|
|
}
|
|
|
|
};
|
2010-08-10 19:56:10 +08:00
|
|
|
|
2011-01-16 10:05:13 +08:00
|
|
|
/**
|
|
|
|
* Get a logger instance. Instance is cached on categoryName level.
|
|
|
|
* @param {String} categoryName name of category to log to.
|
|
|
|
* @return {Logger} instance of logger for the category
|
|
|
|
* @static
|
|
|
|
*/
|
|
|
|
function getLogger (categoryName) {
|
2011-07-12 11:02:48 +08:00
|
|
|
|
2011-01-16 10:05:13 +08:00
|
|
|
// Use default logger if categoryName is not specified or invalid
|
|
|
|
if (!(typeof categoryName == "string")) {
|
|
|
|
categoryName = DEFAULT_CATEGORY;
|
|
|
|
}
|
2010-08-10 19:56:10 +08:00
|
|
|
|
2011-01-16 10:05:13 +08:00
|
|
|
var appenderList;
|
|
|
|
if (!loggers[categoryName]) {
|
|
|
|
// Create the logger for this name if it doesn't already exist
|
|
|
|
loggers[categoryName] = new Logger(categoryName);
|
|
|
|
if (appenders[categoryName]) {
|
|
|
|
appenderList = appenders[categoryName];
|
|
|
|
appenderList.forEach(function(appender) {
|
|
|
|
loggers[categoryName].addListener("log", appender);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (appenders[ALL_CATEGORIES]) {
|
|
|
|
appenderList = appenders[ALL_CATEGORIES];
|
|
|
|
appenderList.forEach(function(appender) {
|
|
|
|
loggers[categoryName].addListener("log", appender);
|
|
|
|
});
|
2010-12-04 17:49:39 +08:00
|
|
|
}
|
2010-08-10 19:56:10 +08:00
|
|
|
}
|
2011-07-12 11:02:48 +08:00
|
|
|
|
2011-01-16 10:05:13 +08:00
|
|
|
return loggers[categoryName];
|
|
|
|
}
|
2010-08-10 19:56:10 +08:00
|
|
|
|
2011-01-16 10:05:13 +08:00
|
|
|
/**
|
|
|
|
* args are appender, then zero or more categories
|
|
|
|
*/
|
|
|
|
function addAppender () {
|
|
|
|
var args = Array.prototype.slice.call(arguments);
|
|
|
|
var appender = args.shift();
|
|
|
|
if (args.length == 0 || args[0] === undefined) {
|
|
|
|
args = [ ALL_CATEGORIES ];
|
|
|
|
}
|
|
|
|
//argument may already be an array
|
2011-03-04 16:49:43 +08:00
|
|
|
if (Array.isArray(args[0])) {
|
2011-01-16 10:05:13 +08:00
|
|
|
args = args[0];
|
|
|
|
}
|
2011-07-12 11:02:48 +08:00
|
|
|
|
2011-01-16 10:05:13 +08:00
|
|
|
args.forEach(function(category) {
|
|
|
|
if (!appenders[category]) {
|
|
|
|
appenders[category] = [];
|
2010-12-04 17:49:39 +08:00
|
|
|
}
|
2011-01-16 10:05:13 +08:00
|
|
|
appenders[category].push(appender);
|
2011-07-12 11:02:48 +08:00
|
|
|
|
2011-01-16 10:05:13 +08:00
|
|
|
if (category === ALL_CATEGORIES) {
|
|
|
|
for (var logger in loggers) {
|
|
|
|
if (loggers.hasOwnProperty(logger)) {
|
|
|
|
loggers[logger].addListener("log", appender);
|
2010-12-04 17:49:39 +08:00
|
|
|
}
|
2011-01-16 10:05:13 +08:00
|
|
|
}
|
|
|
|
} else if (loggers[category]) {
|
|
|
|
loggers[category].addListener("log", appender);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function clearAppenders () {
|
|
|
|
appenders = {};
|
|
|
|
for (var logger in loggers) {
|
|
|
|
if (loggers.hasOwnProperty(logger)) {
|
|
|
|
loggers[logger].removeAllListeners("log");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function configureAppenders(appenderList, fileAppender, consoleAppender) {
|
|
|
|
clearAppenders();
|
|
|
|
if (appenderList) {
|
|
|
|
appenderList.forEach(function(appenderConfig) {
|
|
|
|
var appender = appenderMakers[appenderConfig.type](appenderConfig, fileAppender, consoleAppender);
|
|
|
|
if (appender) {
|
2011-07-12 11:02:48 +08:00
|
|
|
addAppender(appender, appenderConfig.category);
|
2011-01-16 10:05:13 +08:00
|
|
|
} else {
|
|
|
|
throw new Error("log4js configuration problem for "+sys.inspect(appenderConfig));
|
2010-12-04 17:49:39 +08:00
|
|
|
}
|
|
|
|
});
|
2011-01-16 10:05:13 +08:00
|
|
|
} else {
|
|
|
|
addAppender(consoleAppender);
|
2010-08-10 19:56:10 +08:00
|
|
|
}
|
2011-01-16 10:05:13 +08:00
|
|
|
}
|
2010-08-10 19:56:10 +08:00
|
|
|
|
2011-01-16 10:05:13 +08:00
|
|
|
function configureLevels(levels) {
|
|
|
|
if (levels) {
|
|
|
|
for (var category in levels) {
|
|
|
|
if (levels.hasOwnProperty(category)) {
|
|
|
|
getLogger(category).setLevel(levels[category]);
|
2010-12-04 17:49:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-16 10:05:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Models a logging event.
|
|
|
|
* @constructor
|
|
|
|
* @param {String} categoryName name of category
|
|
|
|
* @param {Log4js.Level} level level of message
|
2011-07-13 16:12:29 +08:00
|
|
|
* @param {Array} data objects to log
|
2011-01-16 10:05:13 +08:00
|
|
|
* @param {Log4js.Logger} logger the associated logger
|
|
|
|
* @author Seth Chisamore
|
|
|
|
*/
|
2011-07-13 16:12:29 +08:00
|
|
|
function LoggingEvent (categoryName, level, data, logger) {
|
2011-01-16 10:05:13 +08:00
|
|
|
this.startTime = new Date();
|
|
|
|
this.categoryName = categoryName;
|
2011-07-13 16:12:29 +08:00
|
|
|
this.data = data;
|
2011-01-16 10:05:13 +08:00
|
|
|
this.level = level;
|
|
|
|
this.logger = logger;
|
|
|
|
}
|
2010-08-10 19:56:10 +08:00
|
|
|
|
2011-01-16 10:05:13 +08:00
|
|
|
/**
|
|
|
|
* Logger to log messages.
|
|
|
|
* use {@see Log4js#getLogger(String)} to get an instance.
|
|
|
|
* @constructor
|
|
|
|
* @param name name of category to log to
|
|
|
|
* @author Stephan Strittmatter
|
|
|
|
*/
|
|
|
|
function Logger (name, level) {
|
|
|
|
this.category = name || DEFAULT_CATEGORY;
|
2011-05-19 21:25:13 +08:00
|
|
|
|
|
|
|
if (! this.level) {
|
2011-05-30 19:26:30 +08:00
|
|
|
this.__proto__.level = levels.TRACE;
|
2011-05-19 21:25:13 +08:00
|
|
|
}
|
2011-01-16 10:05:13 +08:00
|
|
|
}
|
|
|
|
sys.inherits(Logger, events.EventEmitter);
|
|
|
|
|
|
|
|
Logger.prototype.setLevel = function(level) {
|
2011-07-12 11:02:48 +08:00
|
|
|
this.level = levels.toLevel(level, levels.TRACE);
|
2011-01-16 10:05:13 +08:00
|
|
|
};
|
|
|
|
|
2011-05-30 19:26:30 +08:00
|
|
|
Logger.prototype.removeLevel = function() {
|
2011-05-19 21:25:13 +08:00
|
|
|
delete this.level;
|
|
|
|
};
|
|
|
|
|
2011-07-19 07:08:15 +08:00
|
|
|
Logger.prototype.log = function() {
|
|
|
|
var args = Array.prototype.slice.call(arguments)
|
|
|
|
, logLevel = args.shift()
|
|
|
|
, loggingEvent = new LoggingEvent(this.category, logLevel, args, this);
|
2011-01-16 10:05:13 +08:00
|
|
|
this.emit("log", loggingEvent);
|
|
|
|
};
|
|
|
|
|
|
|
|
Logger.prototype.isLevelEnabled = function(otherLevel) {
|
|
|
|
return this.level.isLessThanOrEqualTo(otherLevel);
|
|
|
|
};
|
|
|
|
|
|
|
|
['Trace','Debug','Info','Warn','Error','Fatal'].forEach(
|
|
|
|
function(levelString) {
|
2011-07-12 11:02:48 +08:00
|
|
|
var level = levels.toLevel(levelString);
|
2011-01-16 10:05:13 +08:00
|
|
|
Logger.prototype['is'+levelString+'Enabled'] = function() {
|
|
|
|
return this.isLevelEnabled(level);
|
|
|
|
};
|
2011-07-12 11:02:48 +08:00
|
|
|
|
2011-07-13 16:12:29 +08:00
|
|
|
Logger.prototype[levelString.toLowerCase()] = function () {
|
2011-01-16 10:05:13 +08:00
|
|
|
if (this.isLevelEnabled(level)) {
|
2011-07-19 07:08:15 +08:00
|
|
|
var args = Array.prototype.slice.call(arguments);
|
|
|
|
args.unshift(level);
|
|
|
|
Logger.prototype.log.apply(this, args);
|
2010-12-04 17:49:39 +08:00
|
|
|
}
|
2011-01-16 10:05:13 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2011-05-30 19:26:30 +08:00
|
|
|
function setGlobalLogLevel(level) {
|
2011-07-12 11:02:48 +08:00
|
|
|
Logger.prototype.level = levels.toLevel(level, levels.TRACE);
|
2011-05-30 19:26:30 +08:00
|
|
|
}
|
|
|
|
|
2011-01-16 10:05:13 +08:00
|
|
|
/**
|
|
|
|
* Get the default logger instance.
|
|
|
|
* @return {Logger} instance of default logger
|
|
|
|
* @static
|
|
|
|
*/
|
|
|
|
function getDefaultLogger () {
|
2011-07-12 11:02:48 +08:00
|
|
|
return getLogger(DEFAULT_CATEGORY);
|
2011-01-16 10:05:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function logLevelFilter (levelString, appender) {
|
2011-07-12 11:02:48 +08:00
|
|
|
var level = levels.toLevel(levelString);
|
2011-01-16 10:05:13 +08:00
|
|
|
return function(logEvent) {
|
|
|
|
if (logEvent.level.isGreaterThanOrEqualTo(level)) {
|
|
|
|
appender(logEvent);
|
2010-12-04 17:49:39 +08:00
|
|
|
}
|
2011-01-16 10:05:13 +08:00
|
|
|
}
|
|
|
|
}
|
2010-08-10 19:56:10 +08:00
|
|
|
|
2011-07-12 11:02:48 +08:00
|
|
|
|
|
|
|
function consoleAppender (layout) {
|
|
|
|
layout = layout || layouts.colouredLayout;
|
|
|
|
return function(loggingEvent) {
|
|
|
|
console._preLog4js_log(layout(loggingEvent));
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2011-01-16 10:05:13 +08:00
|
|
|
/**
|
2011-07-12 11:02:48 +08:00
|
|
|
* File Appender writing the logs to a text file. Supports rolling of logs by size.
|
2011-01-16 10:05:13 +08:00
|
|
|
*
|
2011-07-12 11:02:48 +08:00
|
|
|
* @param file file log messages will be written to
|
|
|
|
* @param layout a function that takes a logevent and returns a string (defaults to basicLayout).
|
|
|
|
* @param logSize - the maximum size (in bytes) for a log file, if not provided then logs won't be rotated.
|
|
|
|
* @param numBackups - the number of log files to keep after logSize has been reached (default 5)
|
|
|
|
* @param filePollInterval - the time in seconds between file size checks (default 30s)
|
2011-01-16 10:05:13 +08:00
|
|
|
*/
|
2011-07-12 11:02:48 +08:00
|
|
|
function fileAppender (file, layout, logSize, numBackups, filePollInterval) {
|
|
|
|
layout = layout || layouts.basicLayout;
|
2011-07-17 10:28:26 +08:00
|
|
|
var logFile = fs.createWriteStream(file, { flags: 'a', mode: 0644, encoding: 'utf8' });
|
2011-07-12 11:02:48 +08:00
|
|
|
|
|
|
|
if (logSize > 0) {
|
|
|
|
setupLogRolling(logFile, file, logSize, numBackups || 5, (filePollInterval * 1000) || 30000);
|
2011-01-16 10:05:13 +08:00
|
|
|
}
|
2010-08-10 19:56:10 +08:00
|
|
|
|
2011-07-17 18:49:39 +08:00
|
|
|
//close the file on process exit.
|
2011-07-17 10:28:26 +08:00
|
|
|
process.on('exit', function() {
|
|
|
|
logFile.end();
|
|
|
|
});
|
|
|
|
|
2011-07-12 11:02:48 +08:00
|
|
|
return function(loggingEvent) {
|
2011-07-17 10:28:26 +08:00
|
|
|
logFile.write(layout(loggingEvent)+'\n');
|
2010-12-04 17:49:39 +08:00
|
|
|
};
|
2011-01-16 10:05:13 +08:00
|
|
|
}
|
2010-12-04 17:49:39 +08:00
|
|
|
|
2011-07-12 11:02:48 +08:00
|
|
|
function setupLogRolling (logFile, filename, logSize, numBackups, filePollInterval) {
|
|
|
|
fs.watchFile(
|
|
|
|
filename,
|
|
|
|
{
|
|
|
|
persistent: false,
|
|
|
|
interval: filePollInterval
|
|
|
|
},
|
|
|
|
function (curr, prev) {
|
|
|
|
if (curr.size >= logSize) {
|
|
|
|
rollThatLog(logFile, filename, numBackups);
|
|
|
|
}
|
|
|
|
}
|
2011-01-16 10:05:13 +08:00
|
|
|
);
|
2011-07-12 11:02:48 +08:00
|
|
|
}
|
2011-01-16 10:05:13 +08:00
|
|
|
|
2011-07-12 11:02:48 +08:00
|
|
|
function rollThatLog (logFile, filename, numBackups) {
|
|
|
|
//first close the current one.
|
2011-07-17 10:28:26 +08:00
|
|
|
logFile.end();
|
2011-07-12 11:02:48 +08:00
|
|
|
//roll the backups (rename file.n-1 to file.n, where n <= numBackups)
|
|
|
|
for (var i=numBackups; i > 0; i--) {
|
|
|
|
if (i > 1) {
|
|
|
|
if (fileExists(filename + '.' + (i-1))) {
|
|
|
|
fs.renameSync(filename+'.'+(i-1), filename+'.'+i);
|
|
|
|
}
|
2011-01-16 10:05:13 +08:00
|
|
|
} else {
|
2011-07-12 11:02:48 +08:00
|
|
|
fs.renameSync(filename, filename+'.1');
|
2010-12-11 18:55:21 +08:00
|
|
|
}
|
2010-12-04 17:49:39 +08:00
|
|
|
}
|
2011-07-12 11:02:48 +08:00
|
|
|
//open it up again
|
2011-07-17 10:28:26 +08:00
|
|
|
logFile = fs.createWriteStream(filename, { flags: 'a', mode: 0644, encoding: "utf8" });
|
2011-01-16 10:05:13 +08:00
|
|
|
}
|
2010-08-10 19:56:10 +08:00
|
|
|
|
2011-07-12 11:02:48 +08:00
|
|
|
function fileExists (filename) {
|
|
|
|
try {
|
|
|
|
fs.statSync(filename);
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
2010-12-04 17:49:39 +08:00
|
|
|
}
|
2011-07-12 11:02:48 +08:00
|
|
|
}
|
2010-08-10 19:56:10 +08:00
|
|
|
|
2011-07-12 11:02:48 +08:00
|
|
|
function configure (configurationFileOrObject) {
|
|
|
|
var config = configurationFileOrObject;
|
|
|
|
if (typeof(config) === "string") {
|
|
|
|
config = JSON.parse(fs.readFileSync(config, "utf8"));
|
2010-12-06 06:14:20 +08:00
|
|
|
}
|
2011-07-12 11:02:48 +08:00
|
|
|
if (config) {
|
|
|
|
try {
|
|
|
|
configureAppenders(config.appenders, fileAppender, consoleAppender);
|
|
|
|
configureLevels(config.levels);
|
|
|
|
} catch (e) {
|
|
|
|
throw new Error("Problem reading log4js config " + sys.inspect(config) + ". Error was \"" + e.message + "\" ("+e.stack+")");
|
2010-12-06 06:14:20 +08:00
|
|
|
}
|
|
|
|
}
|
2011-07-12 11:02:48 +08:00
|
|
|
}
|
2010-12-06 06:14:20 +08:00
|
|
|
|
2011-07-12 11:02:48 +08:00
|
|
|
function findConfiguration() {
|
|
|
|
//add current directory onto the list of configPaths
|
|
|
|
var paths = ['.'].concat(require.paths);
|
|
|
|
//add this module's directory to the end of the list, so that we pick up the default config
|
|
|
|
paths.push(__dirname);
|
|
|
|
var pathsWithConfig = paths.filter( function (pathToCheck) {
|
2010-12-06 06:14:20 +08:00
|
|
|
try {
|
2011-07-12 11:02:48 +08:00
|
|
|
fs.statSync(path.join(pathToCheck, "log4js.json"));
|
2010-12-06 06:14:20 +08:00
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
2011-07-12 11:02:48 +08:00
|
|
|
});
|
|
|
|
if (pathsWithConfig.length > 0) {
|
|
|
|
return path.join(pathsWithConfig[0], 'log4js.json');
|
2010-12-06 06:14:20 +08:00
|
|
|
}
|
2011-07-12 11:02:48 +08:00
|
|
|
return undefined;
|
|
|
|
}
|
2010-12-06 06:14:20 +08:00
|
|
|
|
2011-07-12 11:02:48 +08:00
|
|
|
function replaceConsole(logger) {
|
|
|
|
function replaceWith(fn) {
|
|
|
|
return function() {
|
|
|
|
fn.apply(logger, arguments);
|
2011-01-16 10:21:37 +08:00
|
|
|
}
|
2010-12-05 11:36:35 +08:00
|
|
|
}
|
|
|
|
|
2011-07-12 11:02:48 +08:00
|
|
|
['log','debug','info','warn','error'].forEach(function (item) {
|
|
|
|
console['_preLog4js_'+item] = console[item];
|
|
|
|
console[item] = replaceWith(item === 'log' ? logger.info : logger[item]);
|
|
|
|
});
|
2010-08-10 19:56:10 +08:00
|
|
|
|
2011-07-12 11:02:48 +08:00
|
|
|
}
|
2010-12-08 05:53:59 +08:00
|
|
|
|
2011-07-12 11:02:48 +08:00
|
|
|
//set ourselves up if we can find a default log4js.json
|
|
|
|
configure(findConfiguration());
|
|
|
|
//replace console.log, etc with log4js versions
|
|
|
|
replaceConsole(getLogger("console"));
|
2010-12-08 05:53:59 +08:00
|
|
|
|
2011-07-12 11:02:48 +08:00
|
|
|
module.exports = {
|
|
|
|
getLogger: getLogger,
|
|
|
|
getDefaultLogger: getDefaultLogger,
|
2010-12-05 07:56:09 +08:00
|
|
|
|
2011-07-12 11:02:48 +08:00
|
|
|
addAppender: addAppender,
|
|
|
|
clearAppenders: clearAppenders,
|
|
|
|
configure: configure,
|
2010-08-10 19:56:10 +08:00
|
|
|
|
2011-07-12 11:02:48 +08:00
|
|
|
levels: levels,
|
|
|
|
setGlobalLogLevel: setGlobalLogLevel,
|
2010-08-10 19:56:10 +08:00
|
|
|
|
2011-07-12 11:02:48 +08:00
|
|
|
consoleAppender: consoleAppender,
|
|
|
|
fileAppender: fileAppender,
|
|
|
|
logLevelFilter: logLevelFilter,
|
|
|
|
|
|
|
|
layouts: layouts,
|
2011-07-19 07:08:15 +08:00
|
|
|
connectLogger: require('./connect-logger').connectLogger
|
2010-08-10 19:56:10 +08:00
|
|
|
};
|
|
|
|
|
2011-07-12 11:02:48 +08:00
|
|
|
//keep the old-style layouts
|
|
|
|
['basicLayout','messagePassThroughLayout','colouredLayout','coloredLayout'].forEach(function(item) {
|
|
|
|
module.exports[item] = layouts[item];
|
|
|
|
});
|
|
|
|
|