Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Logger

📝 Expressive TypeScript Logger for Node.js

Hierarchy

  • Logger

Index

Constructors

constructor

  • Parameters

    • Optional settings: ISettingsParam

      Configuration of the logger instance (all settings are optional with sane defaults)

    • Optional parentSettings: ISettings

    Returns Logger

Accessors

settings

  • Readonly settings of the current logger instance. Used for testing.

    Returns ISettings

Methods

attachTransport

  • Attaches external Loggers, e.g. external log services, file system, database

    Parameters

    • transportLogger: TTransportLogger<(message: ILogObject) => void>

      External logger to be attached. Must implement all log methods.

    • Default value minLevel: TLogLevelName = "silly"

      Minimum log level to be forwarded to this attached transport logger. (e.g. debug)

    Returns void

debug

  • Logs a debug message.

    Parameters

    • Rest ...args: unknown[]

      Multiple log attributes that should be logged out.

    Returns ILogObject

error

  • Logs an error message.

    Parameters

    • Rest ...args: unknown[]

      Multiple log attributes that should be logged out.

    Returns ILogObject

fatal

  • Logs a fatal message.

    Parameters

    • Rest ...args: unknown[]

      Multiple log attributes that should be logged out.

    Returns ILogObject

getChildLogger

  • Returns a child logger based on the current instance with inherited settings

    Parameters

    • Optional settings: ISettingsParam

      Overwrite settings inherited from parent logger

    Returns Logger

info

  • Logs an info message.

    Parameters

    • Rest ...args: unknown[]

      Multiple log attributes that should be logged out.

    Returns ILogObject

prettyError

  • prettyError(error: Error, print?: boolean, exposeErrorCodeFrame?: boolean, exposeStackTrace?: boolean, stackOffset?: number, stackLimit?: number, std?: IStd): IErrorObject
  • Helper: Pretty print error without logging it

    Parameters

    • error: Error

      Error object

    • Default value print: boolean = true

      Print the error or return only? (default: true)

    • Default value exposeErrorCodeFrame: boolean = true

      Should the code frame be exposed? (default: true)

    • Default value exposeStackTrace: boolean = true

      Should the stack trace be exposed? (default: true)

    • Default value stackOffset: number = 0

      Offset lines of the stack trace (default: 0)

    • Default value stackLimit: number = Infinity

      Limit number of lines of the stack trace (default: Infinity)

    • Default value std: IStd = this.settings.stdErr

      Which std should the output be printed to? (default: stdErr)

    Returns IErrorObject

setSettings

  • Change settings during runtime Changes will be propagated to potential child loggers

    Parameters

    • settings: ISettingsParam

      Settings to overwrite with. Only this settings will be overwritten, rest will remain the same.

    • Optional parentSettings: ISettings

      INTERNAL USE: Is called by a parent logger to propagate new settings.

    Returns ISettings

silly

  • Logs a silly message.

    Parameters

    • Rest ...args: unknown[]

      Multiple log attributes that should be logged out.

    Returns ILogObject

trace

  • Logs a trace message.

    Parameters

    • Rest ...args: unknown[]

      Multiple log attributes that should be logged out.

    Returns ILogObject

warn

  • Logs a warn message.

    Parameters

    • Rest ...args: unknown[]

      Multiple log attributes that should be logged out.

    Returns ILogObject

Generated using TypeDoc