node.js - how to get logger name inside winston custom transport function? -


i have 2 loggers:

 var category1 = winston.loggers.get('category1');  var category2 = winston.loggers.get('category2'); 

and need custom names (or default).

customlogger.prototype.log = function (level, msg, meta, callback) {    // need logger name here! (category1 or category2 or undefined / default) } 

how right way it?

thanks

as hotfix ..

// fix logger name metadata var originalgetlogger = winston.container.prototype.get // winston.loggers.get(loggername); winston.container.prototype.get = function(loggername,options){     var logger = originalgetlogger.call(winston.loggers,loggername,options)     logger.rewriters.push(function(level, msg, meta) {         meta._l = loggername;         return meta;     });     return logger; } 

im overriding fn add rewriter, , rewriter im adding logger name metadata.

// each log insert loggername meta var loggera = winston.loggers.get('loggernamea');  var loggerb = winston.loggers.get('loggernameb'); 

if there better let me know. thanks.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -