# Code coverage report for slap/lib/logger.js

## Statements: 100% (12 / 12) Branches: 62.5% (5 / 8) Functions: 100% (1 / 1) Lines: 100% (11 / 11) Ignored: none

All files » slap/lib/ » logger.js

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    301
    1
    1

    1

    1
    1

    1
    1

    1

    1
    1
     var path = require('path');
    var winston = require('winston');
    require('bluebird').longStackTraces();

    var packageName = require('../package').name;

    function logger (opts) {
      var winstonLogger = new winston.Logger({
        transports: [
          new winston.transports.File({
            filename: path.join(opts.dir || '.', opts.filename || packageName + '.log'),
            level: opts.level || 'info',
            handleExceptions: true,
            exitOnError: false,
            json: false,
            prettyPrint: true,
            colorize: true
          })
        ]
      });

      var levels = winston.config.npm.levels;
      Eif (levels[opts.level] < levels.info) require('longjohn');

      winstonLogger.extend(logger);
    }

    module.exports = logger;
    global.logger = logger;