How to use the winston.createLogger 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 feathers-plus / generator-feathers-plus / test-expands / a-gens / js / cumulative.test-expected / src1 / logger.js View on Github external
// Logger. (Can be re-generated.)
const { createLogger, format, transports } = require('winston');
// !code: imports // !end
// !code: init // !end

// Configure the Winston logger. For the complete documentation seee https://github.com/winstonjs/winston
const moduleExports = createLogger({
  // ! code: level
  // To see more detailed errors, change this to debug'
  level: 'info',
  // !end
  // ! code: format
  format: format.combine(
    format.splat(),
    format.simple()
  ),
  // !end
  // ! code: transport
  transports: [
    new transports.Console()
  ],
  // !end
  // !code: moduleExports // !end
github ptarmiganlabs / butler-app-duplicator / index.js View on Github external
if (config.get('fileLogging')) {
    logTransports.push(
        new(winston.transports.DailyRotateFile)({
            // dirname: path.join(__dirname, config.get('logDirectory')),
            dirname: path.join(__dirname, 'log'),
            filename: 'butler-app-duplicator.%DATE%.log',
            level: config.get('logLevel'),
            datePattern: 'YYYY-MM-DD',
            maxFiles: '30d'
        })
    );
}


logger = winston.createLogger({
    transports: logTransports,
    format: winston.format.combine(
        winston.format.timestamp(),
        winston.format.printf(info => `${info.timestamp} ${info.level}: ${info.message}`)
    )
});


// Function to get current logging level
getLoggingLevel = () => {
    return logTransports.find(transport => {
        return transport.name == 'console';
    }).level;
};
github te-emprego / api / src / service / logger.js View on Github external
const winston = require('winston');

const logger = winston.createLogger({
  level: 'info',
  format: winston.format.json(),
  transports: [
    // - Write to all logs with level `info` and below to `combined.log`
    // - Write all logs error (and below) to `error.log`.
    new winston.transports.File({ filename: 'logs/error.log', level: 'error' }),
    new winston.transports.File({ filename: 'logs/info.log', level: 'info' }),
    new winston.transports.File({ filename: 'logs/all.log' }),
  ],
});

// If we're not in production then log to the `console` with the format:
// `${info.level}: ${info.message} JSON.stringify({ ...rest }) `
if (process.env.NODE_ENV !== 'production') {
  logger.add(new winston.transports.Console({
    format: winston.format.simple(),
github juffalow / pentest-tool-lite / src / index.js View on Github external
function initPentest(options) {
  const logger = winston.createLogger({
    level: options.debug ? 'debug' : (options.verbose ? 'verbose' : 'error'),
    format: winston.format.json(),
    silent: !options.debug || !options.verbose,
    transports: [
      new winston.transports.Console({
        format: winston.format.simple(),
      }),
    ]
  });

  const pentest = new Pentest(logger);
  const request = new Request(new BlackHole(), logger);
  
  pentest.add('security', () => {
    pentest.add('https', new HTTPS(request, logger));
    pentest.add('hsts', new HSTS(request, logger));
github mylisabox / lisa-box / config / log.js View on Github external
*
   * Exposed on app.log
   */
  logger: winston.createLogger({
    level: 'debug',
    exitOnError: true,
    format: winston.format.combine(
      winston.format.colorize({all: true}),
      winston.format.cli(),
    ),
    transports: [
      new winston.transports.Console()
    ]
  }),

  pluginLogger: winston.createLogger({
    level: 'debug',
    exitOnError: true,
    format: winston.format.combine(
      winston.format.colorize({all: true}),
      winston.format.cli(),
    ),
    transports: [
      new winston.transports.Console()
    ]
  })

}
github opencollective / backyourstack / src / logger.js View on Github external
import winston from 'winston';

const logger = winston.createLogger();

const winstonLevel = process.env.LOG_LEVEL || 'info';

const winstonBaseFormat = winston.format.combine(
  winston.format.simple(),
  winston.format.splat(),
);

const winstonFormat = process.env.IS_CLIENT
  ? winstonBaseFormat
  : winston.format.combine(winston.format.colorize(), winstonBaseFormat);

const winstonConsole = new winston.transports.Console({
  level: winstonLevel,
  format: winstonFormat,
});
github ScriptSmith / instamancer / src / cli.ts View on Github external
const getLogger = (args) => {
    const transports = [];
    if (args["logging"] !== "none") {
        transports.push(
            new winston.transports.File({
                filename: args["logfile"],
                level: args["logging"],
                silent: args["logging"] === "none",
            }),
        );
    }
    return winston.createLogger({
        level: args["logging"],
        silent: args["logging"] === "none",
        transports,
    });
};
github dataclay / event-scripts / NodeJS / deploy-output / logger.js View on Github external
var winston           = require('winston'),
    moment            = require('moment');

const { createLogger, format, transports } = require('winston');
const logger = winston.createLogger({

  transports : [
    
    new winston.transports.Console({
        prettyPrint : true
      , format      : format.combine(
                         format.splat(),
                         format.simple(),
                         format.printf(info => `${info.message}`)
                      )
    }),

    new winston.transports.File({ 
        filename    : `${__dirname}/deploy-out.log`
      , level       : 'info'
      , prettyPrint : true
github satoripop / thesuperlogger / src / logger.js View on Github external
//create email transport if wanted
		if(!_.isEmpty(this.options.mailSettings)) {
			this.mailLevel = process.env.MAIL_LOG_LEVEL || lowestLevel;

			Object.assign(this.options.mailSettings, {
				level: this.mailLevel,
				handleExceptions: false,
			});
			const mailTransport = new winstonMail(this.options.mailSettings);
			this.mailTransport = mailTransport;

			transports.unshift(mailTransport);
		}
		//create winston logger
		this.logger = createLogger({
			levels,
			transports,
			exitOnError: false,
		});
		//add level colors
		addColors({
			levels,
			colors,
		});

		//set log
		let log = new Log();
		this.Log = log;
		//set logblock
		this.Logblock = Logblock;
github rafaeldelboni / koa-api-startup-kit / src / middlewares / logger.js View on Github external
function logErrorFactory () {
  const logger = winston.createLogger(options)
  return function logAndThrow (error, status = 500) {
    logger.error(error)
    this.throw(status, error, { expose: true })
  }
}