Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.2 kB
3
Indexable
var winston  = require('winston');
var config = winston.config;
var PropertiesReader = require('properties-reader');
var dateformat = require('dateformat');
var path = require('path');

Configuration = PropertiesReader('Config/Configuration.Properties');


module.exports = function (filename) {
Configuration = PropertiesReader('Config/Configuration.Properties');
const tsFormat = () => (dateformat(new Date(), 'yyyy-mm-dd HH:MM:ss'));
var module = path.basename(filename);
 return new  (winston.Logger)({
    transports: [
      new (winston.transports.File)({timestamp: tsFormat,filename: 'logs/HOBS-EventEnricher.log',
        json : false,
	level : Configuration.get('server.loglevel'),
	maxsize : Configuration.get('server.logFileSize'),
	maxFiles : Configuration.get('server.logFilesToRotate'),
	tailable : true,
        formatter :  function(options) {
                return options.timestamp() + ' [' +
          config.colorize(options.level, options.level.toUpperCase()) + '] '+ 
          '[ ' + (module) + ' ] ' +
	  (options.message ? options.message : '') +
          (options.meta && Object.keys(options.meta).length ? '\n\t'+ JSON.stringify(options.meta) : '' );
        }

    })
  ]
})};



Leave a Comment