Created
October 7, 2013 12:42
-
-
Save keis/6867255 to your computer and use it in GitHub Desktop.
loopback glue for log4js
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'), | |
sentinel = {}; | |
function loopbackAppender() { | |
return function (loggingEvent) { | |
var logger = log4js.getLogger(loggingEvent.categoryName), | |
isRemote = !!loggingEvent.remoteAddress, | |
hasLooped = loggingEvent._loopback !== sentinel; | |
if (hasLooped && isRemote) { | |
loggingEvent._loopback = sentinel; | |
logger.emit("log", loggingEvent); | |
} | |
}; | |
} | |
function configure(config, options) { | |
return loopbackAppender(); | |
} | |
exports.appender = loopbackAppender; | |
exports.configure = configure; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment