Skip to content

Instantly share code, notes, and snippets.

@nguyentienlong
Forked from miguelmota/index.js
Created April 24, 2020 07:07
Show Gist options
  • Select an option

  • Save nguyentienlong/5751d34b5c26438ac7130ff6031ba72b to your computer and use it in GitHub Desktop.

Select an option

Save nguyentienlong/5751d34b5c26438ac7130ff6031ba72b to your computer and use it in GitHub Desktop.

Revisions

  1. @miguelmota miguelmota revised this gist May 22, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions index.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,3 @@
    var log = require('../lib/logger')(module);
    var log = require('./lib/logger')(module);

    log.inf('foo');
    log.info('foo');
  2. @miguelmota miguelmota created this gist May 22, 2014.
    3 changes: 3 additions & 0 deletions index.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    var log = require('../lib/logger')(module);

    log.inf('foo');
    18 changes: 18 additions & 0 deletions logger.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    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;