Created
March 24, 2011 03:45
-
-
Save marcello3d/884530 to your computer and use it in GitHub Desktop.
simple log4js wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var log4js = require('log4js')() | |
log4js.addAppender(log4js.consoleAppender()) | |
/** | |
* Get a logger. If no name is specified, retrieve the caller's filename | |
* example: | |
* var log = require('./log.js')() | |
*/ | |
module.exports = function(name) { | |
if (!name) { | |
// | |
var split = new Error().stack.split('\n')[2] | |
var scriptName = /\(([^(:]+):/.exec(split)[1] | |
name = scriptName.substring(process.cwd().length+1) | |
} | |
return log4js.getLogger(name) | |
} | |
/** | |
* Access to the raw log4js object | |
*/ | |
module.exports.log4js = log4js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment