How to use the bunyan.RotatingFileStream function in bunyan

To help you get started, we’ve selected a few bunyan 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 verdaccio / verdaccio / src / lib / logger.ts View on Github external
import {prettyTimestamped} from "./logger/format/pretty-timestamped";
import {pretty} from "./logger/format/pretty";
import {jsonFormat} from "./logger/format/json";

const cluster = require('cluster');
const Logger = require('bunyan');
const Error = require('http-errors');
const Stream = require('stream');
const pkgJSON = require('../../package.json');
const _ = require('lodash');
const dayjs = require('dayjs');

/**
 * A RotatingFileStream that modifies the message first
 */
class VerdaccioRotatingFileStream extends Logger.RotatingFileStream {
  // We depend on mv so that this is there
  write(obj) {
    super.write(jsonFormat(obj, false));
  }

  rotate(): void {
    super.rotate();
    this.emit('rotated');
  }
}

let logger;

export interface LoggerTarget {
  type?: string;
  format?: string;