How to use winston-daily-rotate-file - 9 common examples

To help you get started, we’ve selected a few winston-daily-rotate-file 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 vpdb / server / src / app / common / logger.ts View on Github external
zippedArchive: true,
				datePattern: 'YYYY-MM',
			});
			transport.on('rotate', (oldFilename, newFilename) => {
				this.info(null, '[app] Rotating text logs from %s to %s.', oldFilename, newFilename);
			});
			transport.on('new', newFilename => {
				this.info(null, '[app] Creating new text log at %s.', newFilename);
			});
			this.textLogger.add(transport);
			this.info(null, '[app] Text logger enabled at %s.', logPath);
		}
		/* istanbul ignore next */
		if (config.vpdb.logging.file.json) {
			const logPath = resolve(config.vpdb.logging.file.json);
			const transport = new DailyRotateFile({
				filename: basename(logPath),
				dirname: dirname(logPath),
				zippedArchive: true,
				datePattern: 'YYYY-MM',
			});
			transport.on('rotate', (oldFilename, newFilename) => {
				this.info(null, '[app] Rotating JSON logs from %s to %s.', oldFilename, newFilename);
			});
			transport.on('new', newFilename => {
				this.info(null, '[app] Creating new JSON log at %s.', newFilename);
			});
			this.jsonLogger = winston.createLogger({
				format: winston.format.json(),
				transports: [transport],
				level: config.vpdb.logging.level,
			});
github blinksocks / blinksocks / src / core / config.js View on Github external
_initLogger(json) {
    // log_path, log_level, log_max_days
    this.log_path = path.resolve(process.cwd(), json.log_path || 'blinksocks.log');
    this.log_level = json.log_level || 'info';
    this.log_max_days = json.log_max_days || null;

    const { transports, format: { printf, combine, timestamp, splat, prettyPrint } } = winston;
    const trans = [new transports.Console()];

    if (process.env.NODE_ENV !== 'test') {
      trans.push(
        new WinstonDailyRotateFile({
          filename: this.log_path,
          maxFiles: this.log_max_days ? this.log_max_days + 'd' : null,
        }),
      );
    }

    logger.configure({
      level: process.env.NODE_ENV === 'test' ? 'error' : this.log_level,
      format: combine(
        timestamp(),
        splat(),
        // TODO: Enable coloring. Currently we have to prevent dumping color characters in log files.
        // colorize(),
        prettyPrint(),
        printf((info) => `${info.timestamp} - ${info.level}: ${info.message}`),
      ),
github mike-jung / node-web-starter / util / logger.js View on Github external
var Daily = function Daily(options) {

    winstonDaily.call(this, options);
    options = options || {};

    // Set transport name
    this.name = 'daily';

    this.highlightLabel = !!options.label && !!options.highlightLabels && options.highlightLabels.indexOf(this.label) >= 0;
};
github mimecuvalo / helloworld / server / index.js View on Github external
function createLogger() {
  return winston.createLogger({
    format: winston.format.combine(winston.format.timestamp(), winston.format.json()),
    transports: [
      new WinstonDailyRotateFile({
        name: 'app',
        filename: path.resolve(process.cwd(), 'logs', 'app-%DATE%.log'),
        zippedArchive: true,
      }),
    ],
  });
}
github parse-community / parse-server / src / Adapters / Logger / WinstonLogger.js View on Github external
{
              filename: 'parse-server.info',
              json: true,
              format: format.combine(
                format.timestamp(),
                format.splat(),
                format.json()
              ),
            },
            options
          )
        );
        parseServer.name = 'parse-server';
        transports.push(parseServer);

        const parseServerError = new DailyRotateFile(
          Object.assign(
            {
              filename: 'parse-server.err',
              json: true,
              format: format.combine(
                format.timestamp(),
                format.splat(),
                format.json()
              ),
            },
            options,
            { level: 'error' }
          )
        );
        parseServerError.name = 'parse-server-error';
        transports.push(parseServerError);
github parse-community / parse-server / src / Adapters / Logger / WinstonLogger.js View on Github external
function configureTransports(options) {
  const transports = [];
  if (options) {
    const silent = options.silent;
    delete options.silent;

    try {
      if (!_.isNil(options.dirname)) {
        const parseServer = new DailyRotateFile(
          Object.assign(
            {
              filename: 'parse-server.info',
              json: true,
              format: format.combine(
                format.timestamp(),
                format.splat(),
                format.json()
              ),
            },
            options
          )
        );
        parseServer.name = 'parse-server';
        transports.push(parseServer);
github SockTrader / SockTrader / src / sockTrader / core / logger.ts View on Github external
function createLogger(category: string, dailyRotate = false): winston.Logger {
    const silent = process.env.NODE_ENV === "test";
    return winston.loggers.add(category, {
        format: logFormat,
        transports: [
            new winston.transports.Console({silent}),
            !dailyRotate
                ? new winston.transports.File({filename: `./src/logs/${category}.log`, silent})
                : new DailyRotateFile({
                    filename: `${category}-%DATE%.log`,
                    dirname: "./src/logs",
                    datePattern: "YYYY-MM-DD",
                    zippedArchive: true,
                    createSymlink: true,
                    symlinkName: `current-${category}.log`,
                    maxFiles: "14d",
                    silent,
                }),
        ],
    });
}
github breuerfelix / jinsta / src / core / logging.ts View on Github external
function addLogRotate(workspace: string): void {
	const logRotate = new DailyRotateFile({
		format: format.combine(winston.format.splat(), winston.format.timestamp(), winston.format.padLevels(), fileLogFormat),
		level: 'debug',
		filename: path.resolve(workspace, 'logs', 'jinsta-%DATE%.log'),
		datePattern: 'YYYY-MM-DD',
		zippedArchive: true,
		maxSize: '20m',
		maxFiles: '7d',
	});

	logger.add(logRotate);
}
github magic8bot / magic8bot / src / util / logger.ts View on Github external
function* getWinstonTransports(): IterableIterator {
  const fileLogger = isFileLoggerAvailable()
  if (fileLogger) {
    yield new DailyRotateFile({
      filename: magic8bot.loggerFile,
      datePattern: 'YYYY-MM-DD-HH',
      maxSize: '20m',
      maxFiles: '7d',
    })
  }

  if (process.env.NODE_ENV === 'development' || !fileLogger) {
    yield new winston.transports.Console({
      format: formatter,
    })
  }
}

winston-daily-rotate-file

A transport for winston which logs to a rotating file each day.

MIT
Latest version published 9 months ago

Package Health Score

75 / 100
Full package analysis

Popular winston-daily-rotate-file functions