Skip to content

Instantly share code, notes, and snippets.

@keis
Created October 7, 2013 12:42
Show Gist options
  • Save keis/6867255 to your computer and use it in GitHub Desktop.
Save keis/6867255 to your computer and use it in GitHub Desktop.
loopback glue for log4js
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