How to use the winston.remove function in winston

To help you get started, we’ve selected a few winston examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stefanwille / nodejs-integration-testing / src / server.js View on Github external
const booksController = require('./booksController');

winston.add(winston.transports.File, {
  filename: `logs/${process.env['NODE_ENV']}.log`,
});

process.on('unhandledRejection', (error, promise) => {
  console.error('##### Unhandled Promise Rejection: #####');
  console.error((error && error.stack) || error);
  console.error(promise);
  throw error;
});

// Don't show the log when in test env
if (process.env['NODE_ENV'] === 'test') {
  winston.remove(winston.transports.Console);
}

const winstonStream = {
  write: function(message, encoding) {
    winston.info(message);
  },
};

const app = express();
app.use(morgan('combined', { stream: winstonStream }));

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.text());

app.use(booksController.getRouter());
github jh3y / kody / src / lib / main.js View on Github external
error  : 3,
      success: 4,
      silly  : 5
    },
    COLORS: {
      info   : 'blue',
      warn   : 'yellow',
      error  : 'red',
      success: 'green',
      silly  : 'rainbow'
    }
  }
};


winston.remove(winston.transports.Console);
winston.add(winston.transports.Console, {
  level    : 'silly',
  colorize : true,
  formatter: function(options) {
    const color = PROPS.LOGGER_CONFIG.COLORS[options.level];
    return `[${pkg.name.cyan}] ${options.message[color]}`;
  }
});
winston.setLevels(PROPS.LOGGER_CONFIG.LEVELS);

program
  .version(pkg.version)
  .parse(process.argv);

try {
  kody.init();
github RisingStack / multi-process-nodejs-example / config / components / logger.js View on Github external
const { error, value: envVars } = joi.validate(process.env, envVarsSchema)
if (error) {
  throw new Error(`Config validation error: ${error.message}`)
}

const config = {
  logger: {
    level: envVars.LOGGER_LEVEL,
    enabled: envVars.LOGGER_ENABLED
  }
}

winston.level = config.logger.level
if (!config.logger.enabled) {
  winston.remove(winston.transports.Console)
}

module.exports = config
github wood1986 / ln / comparison / winston.js View on Github external
"use strict";

var log = require("winston");

log.add(log.transports.File, {
  "filename": "winston.log"
});
log.remove(log.transports.Console);
require("./common.js")(log);
github sjlu / popular-movies / lib / winston.js View on Github external
var winston = require('winston')

winston.remove(winston.transports.Console)
winston.add(winston.transports.Console, {
  colorize: true,
  level: 'info'
})

module.exports = winston
github gardr / validator-web / logger.js View on Github external
var pack = require('./package.json');
var config = require('./lib/config.js');
var winston  = require('winston');

var logsFolder = config.get('logFileName');

winston.add(winston.transports.DailyRotateFile, {
  filename: logsFolder,
  datePattern: '.yyyyMMdd'
});
winston.remove(winston.transports.Console);

module.exports =  winston;
github TryStarboard / Starboard / source / server / util / logging.js View on Github external
/*eslint no-process-env:0*/

import 'le_node';
import config from 'config';
import winston from 'winston';
import koaLogger from 'koa-logger';

winston.remove(winston.transports.Console);

if (process.env.NODE_ENV === 'development') {
  winston.add(winston.transports.Console, {
    colorize: true,
    timestamp: true,
    prettyPrint: true,
    humanReadableUnhandledException: true,
  });
} else {
  winston.add(winston.transports.Logentries, {
    token: config.get('logEntries.token'),
    minLevel: 1,
  });
}

export const logger = winston;
github numenta / nupic.tools / utils / logger.js View on Github external
function initializeLogger(logDirectory, logLevel) {
    var logFileName = new Date().toISOString() + '.log'
      , logPath
      ;
    if (! initialized) {
        if (! logDirectory) {
            logDirectory = path.join(__dirname, 'logs');
        }
        if (! logLevel) {
            logLevel = 'debug';
        }
        logPath = path.join(logDirectory, logFileName);
        if (! fs.existsSync(logDirectory)) {
            fs.mkdirSync(logDirectory);
        }
        winston.remove(winston.transports.Console);
        winston.add(winston.transports.Console, {
            level: logLevel,
            colorize: true,
            handleExceptions: false
        });
        winston.add(winston.transports.File, {
            filename: logPath,
            level: logLevel,
            handleExceptions: false
        });
        winston.info('Winston logger initialized at level "%s", writing to %s', logLevel, logPath);
        initialized = true;
    }
    return winston;
}
github pdeschen / camelot / camelot.js View on Github external
var Camelot = function (options) {
  this.opts = mixin(options, _options);
  if (!this.opts.verbose) { 
    logger.remove(logger.transports.Console);
  }
  logger.info('init options: ' + JSON.stringify(this.opts));
  return this;
};
github tjfontaine / dnsbalance / server.js View on Github external
"use strict";

var fs = require('fs'),
  path = require('path'),
  util = require('util'),
  vm = require('vm'),
  winston = require('winston'),
  optimist = require('optimist'),
  Config = require('./lib/configfile'),
  Zones = require('./lib/zones').Zones,
  BindParser = require('./lib/bind_zone'),
  DNSBalance = require('./lib/dnsbalance');

//require('long-stack-traces');

winston.remove(winston.transports.Console);

winston.add(winston.transports.Console, {
  colorize: true,
  timestamp: true
});

var argv = optimist['default']('c', path.join(path.dirname(__filename), 'config.js'))
  .describe('c', 'Specify the config file')
  .alias('c', 'config')
  .argv;

var config = new Config(argv.c);

config.on('loaded', function () {
  var srv, self = this;