ssube/cautious-journey

View on GitHub
src/logger/bunyan.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import { constructorName } from '@apextoaster/js-utils';
import bunyan from 'bunyan';
import { Logger } from 'noicejs';

/**
 * Attach bunyan to the Logger. Does very little, since bunyan matches the Logger interface.
 */
export class BunyanLogger {
  public static create(options: bunyan.LoggerOptions): Logger {
    return bunyan.createLogger({
      ...options,
      serializers: {
        ...bunyan.stdSerializers,
        container: constructorName,
        logger: constructorName,
        module: constructorName,
      },
    });
  }
}