How to use pino-multi-stream - 5 common examples

To help you get started, we’ve selected a few pino-multi-stream 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 easy-mock / easy-mock / util / logger.js View on Github external
/* istanbul ignore if */
if (process.env.NODE_ENV === 'production') {
  if (!fs.existsSync(logDir)) mkdirp.sync(logDir)

  streams = [
    {level: 'info', stream: fs.createWriteStream(`logs/${date}-info.log`, streamOpt)},
    {level: 'error', stream: fs.createWriteStream(`logs/${date}-error.log`, streamOpt)}
  ]
}

module.exports = koaPinoLogger({
  name: 'Easy Mock',
  level: process.env.NODE_ENV === 'test' ? 'silent' : /* istanbul ignore next */ 'info',
  genReqId: req => req.headers['x-request-id'] || uuid.v4()
}, multistream(streams))
github ethereum-optimism / optimism / packages / core-utils / src / common / logger.ts View on Github external
base: null,
    }

    let loggerStreams: Streams = [{ stream: process.stdout }]
    if (options.sentryOptions) {
      loggerStreams.push({
        level: 'error',
        stream: createWriteStream({
          ...options.sentryOptions,
          stackAttributeKey: 'err',
        }),
      })
    }
    if (options.streams) loggerStreams = loggerStreams.concat(options.streams)

    this.inner = pino(loggerOptions, pinoms.multistream(loggerStreams))
  }
github paritytech / fether / packages / fether-electron / src / main / app / utils / pino.js View on Github external
export default opts => Pino({ name, ...opts }, multistream(streams));
github rolling-scopes / rsschool-app / server / src / logger.ts View on Github external
export function createDefaultLogger() {
  const streams = [{ stream: process.stdout }];
  const { accessKeyId, secretAccessKey, region } = config.aws;
  if (process.env.NODE_ENV === 'production' && accessKeyId && secretAccessKey) {
    const writeStream = cloudwatch({
      interval: 2000,
      aws_access_key_id: accessKeyId,
      aws_secret_access_key: secretAccessKey,
      aws_region: region,
      group: '/app/rsschool-api',
    });
    streams.push(writeStream);
  }
  return pinoLogger({ streams, base: null }) as ILogger;
}
github patrickmichalina / fusing-angular / src / electron / log.ts View on Github external
export const initLogger = (isDev = false) => {
  app.setAppLogsPath()
  const logBasePath = app.getPath('logs')

  const fileOutStream = (title: string) => createWriteStream(`${logBasePath}/${app.name}.${title}.log`, { flags: 'a' })

  const devlogs = isDev ? [
    { level: 'trace', stream: pinoms.prettyStream() },
    { level: 'trace', stream: fileOutStream('trace') }
  ] : []

  const lg: Logger = pinoms({
    streams: [
      ...devlogs,
      { level: 'info', stream: fileOutStream('info') },
      { level: 'warn', stream: fileOutStream('warn') },
      { level: 'error', stream: fileOutStream('error') },
      { level: 'fatal', stream: fileOutStream('fatal') }
    ]
  }) as Logger

  const master = lg.child({ ver: app.getVersion() })
  const main = master.child({ platform: 'electron-main' })
  const rdr = master.child({ platform: 'electron-renderer' })

pino-multi-stream

A wrapper for the Pino logger that provides Bunyan's multipe destination stream API

MIT
Latest version published 1 year ago

Package Health Score

53 / 100
Full package analysis