Skip to content

Instantly share code, notes, and snippets.

@josemarcosrf
Forked from miguelmota/index.js
Created January 4, 2019 19:09
Show Gist options
  • Save josemarcosrf/dcb7c0ac71e2f3ba1fb588c02e5584e7 to your computer and use it in GitHub Desktop.
Save josemarcosrf/dcb7c0ac71e2f3ba1fb588c02e5584e7 to your computer and use it in GitHub Desktop.
Node.js Winston logger wrapper to display filename
var log = require('./lib/logger')(module);
log.info('foo');
var winston = require('winston');
var getLogger = function(module) {
var path = module.filename.split('/').slice(-2).join('/');
return new winston.Logger({
transports: [
new winston.transports.Console({
colorize: true,
level: 'debug',
label: path
}),
new (winston.transports.File)({filename: 'debug.log', silent: false})
]
});
};
module.exports = getLogger;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment