A simple logger class.

Hierarchy

  • Logger

Constructors

  • Parameters

    • options: {
          destination?: WriteStream;
          formatter?: LogFormatter;
          historySize?: number;
          level?: string;
      } = {}
      • Optional destination?: WriteStream
      • Optional formatter?: LogFormatter
      • Optional historySize?: number
      • Optional level?: string

    Returns Logger

Properties

_capture: undefined | CapturedLogs = undefined
_historySize: undefined | number
_level: number = 7
destination: WritableStream

Log destination stream.

formatter: LogFormatter

Log formatter.

history: LogEvent[] = []

The last few logged messages.

Accessors

  • get level(): string
  • Currently active log level.

    Returns string

  • set level(level): void
  • Parameters

    • level: string

    Returns void

Methods

  • Parameters

    • level: string
    • msg: string
    • Optional context: LogContext

    Returns void

  • Capture log messages for as long as the returned object has not been stopped, useful for testing log messages.

    Parameters

    • level: string = ...

    Returns CapturedLogs

  • Create a child logger that will include context information with every log message.

    Parameters

    • context: LogContext

    Returns ChildLogger

  • Log debug message.

    Parameters

    • msg: string
    • Optional context: LogContext

    Returns void

  • Log error message.

    Parameters

    • msg: string
    • Optional context: LogContext

    Returns void

  • Log fatal message.

    Parameters

    • msg: string
    • Optional context: LogContext

    Returns void

  • Log infor message.

    Parameters

    • msg: string
    • Optional context: LogContext

    Returns void

  • Log trace message.

    Parameters

    • msg: string
    • Optional context: LogContext

    Returns void

  • Log warn message.

    Parameters

    • msg: string
    • Optional context: LogContext

    Returns void

  • Log formatter with color highlighting.

    Parameters

    • data: LogEvent

    Returns string

  • JSON log formatter.

    Parameters

    • data: LogEvent

    Returns string

  • Log formatter without color highlighting.

    Parameters

    • data: LogEvent

    Returns string

  • Log formatter for systemd.

    Parameters

    • data: LogEvent

    Returns string

Generated using TypeDoc