Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Logger

Hierarchy

  • Logger

Implements

Index

Constructors

constructor

  • new Logger(context?: string): Logger
  • Creates a new logger with no handlers configured. Add handlers with addHandler using a Fluent API.

    Parameters

    • Optional context: string

      Context for the new logger. Defaults to Default.

    Returns Logger

Properties

Private Readonly _context

_context: string

Private _metadata

_metadata: Record<string, unknown> = ...

Private handlers

handlers: ILogHandler[] = ...

Accessors

context

  • get context(): string
  • Current context this logger is scoped to.

    Returns string

metadata

  • get metadata(): Record<string, unknown>
  • Current metadata stored on this logger.

    Returns Record<string, unknown>

Methods

addHandler

  • Parameters

    • handler: ILogHandler
    • Optional condition: boolean | (() => boolean)

    Returns ILogger

Private addHandlers

addMetadata

  • addMetadata(metadata: Record<string, unknown>): ILogger
  • Adds a metadata object to the logger which will be included in created ILogRecords. New metadata will be merged with existing metadata. Existing keys will be overwritten.

    Parameters

    • metadata: Record<string, unknown>

    Returns ILogger

critical

  • critical(...args: unknown[]): void
  • Sends a log record with the level CRITICAL to all handlers.

    Parameters

    • Rest ...args: unknown[]

    Returns void

debug

  • debug(...args: unknown[]): void
  • Sends a log record with the level DEBUG to all handlers.

    Parameters

    • Rest ...args: unknown[]

    Returns void

error

  • error(...args: unknown[]): void
  • Sends a log record with the level ERROR to all handlers.

    Parameters

    • Rest ...args: unknown[]

    Returns void

info

  • info(...args: unknown[]): void
  • Sends a log record with the level INFO to all handlers.

    Parameters

    • Rest ...args: unknown[]

    Returns void

Private notifyHandlers

  • notifyHandlers(level: LogLevel, args: unknown[]): void
  • Parameters

    Returns void

verbose

  • verbose(...args: unknown[]): void
  • Sends a log record with the level VERBOSE to all handlers.

    Parameters

    • Rest ...args: unknown[]

    Returns void

warning

  • warning(...args: unknown[]): void
  • Sends a log record with the level WARNING to all handlers.

    Parameters

    • Rest ...args: unknown[]

    Returns void

withContext

  • withContext(context: string): ILogger
  • Creates a new logger scoped to a given context. All current handlers and metadata is copied over to the logger.

    Parameters

    • context: string

    Returns ILogger

Generated using TypeDoc