Libraries
    Preparing search index...

    Structured logger with per-level methods, child context support, and AsyncDisposable for graceful shutdown.

    Log methods are synchronous and fire-and-forget — they push events into an internal async microtask pipeline.

    Accepts both plain string templates and typed TypedTemplate objects (produced by ParseStringSchemaBuilder from @cleverbrush/schema). Typed templates carry a template property with the raw {Property} pattern, which the logger uses as messageTemplate so all events of the same shape are grouped correctly in Seq, SigNoz, ClickHouse, etc.

    logger.info('Server started on port {Port}', { Port: 3000 });

    const child = logger.forContext('SourceContext', 'OrderService');
    child.info('Processing order {OrderId}', { OrderId: 42 });

    // Typed template — structured grouping
    import { s } from '@cleverbrush/schema';
    const tmpl = s.parseString('Order #{OrderId} placed by {UserId}');
    child.info(tmpl, { OrderId: 1, UserId: 'u-99' });

    Implements

    • AsyncDisposable
    Index

    Constructors

    • Parameters

      • pipeline: LoggerPipeline
      • OptionalcontextProperties: Record<string, unknown>

      Returns Logger

    Methods

    • Returns Promise<void>

    • Log a debug-level message.

      Parameters

      • template: string
      • Optionalproperties: Record<string, unknown>

      Returns void

    • Log a debug-level message.

      Type Parameters

      • T extends Record<string, unknown>

      Parameters

      Returns void

    • Log an error-level message with an optional exception.

      Parameters

      • template: string
      • Optionalproperties: Record<string, unknown>

      Returns void

    • Log an error-level message with an optional exception.

      Parameters

      • error: Error
      • template: string
      • Optionalproperties: Record<string, unknown>

      Returns void

    • Log an error-level message with an optional exception.

      Type Parameters

      • T extends Record<string, unknown>

      Parameters

      Returns void

    • Log an error-level message with an optional exception.

      Type Parameters

      • T extends Record<string, unknown>

      Parameters

      Returns void

    • Log a fatal-level message with an optional exception.

      Parameters

      • template: string
      • Optionalproperties: Record<string, unknown>

      Returns void

    • Log a fatal-level message with an optional exception.

      Parameters

      • error: Error
      • template: string
      • Optionalproperties: Record<string, unknown>

      Returns void

    • Log a fatal-level message with an optional exception.

      Type Parameters

      • T extends Record<string, unknown>

      Parameters

      Returns void

    • Log a fatal-level message with an optional exception.

      Type Parameters

      • T extends Record<string, unknown>

      Parameters

      Returns void

    • Flushes all pending events through the pipeline to sinks.

      Returns Promise<void>

    • Creates a child logger with additional context properties.

      Parameters

      • key: string | Record<string, unknown>

        property name, or an object of key-value pairs

      • Optionalvalue: unknown

        property value (when key is a string)

      Returns Logger

      a new Logger with merged context properties

    • Log an information-level message.

      Parameters

      • template: string
      • Optionalproperties: Record<string, unknown>

      Returns void

    • Log an information-level message.

      Type Parameters

      • T extends Record<string, unknown>

      Parameters

      Returns void

    • Checks whether the given level is enabled for this logger.

      Parameters

      Returns boolean

      true if events at this level would be processed

    • Log a trace-level message.

      Parameters

      • template: string
      • Optionalproperties: Record<string, unknown>

      Returns void

    • Log a trace-level message.

      Type Parameters

      • T extends Record<string, unknown>

      Parameters

      Returns void

    • Log a warning-level message.

      Parameters

      • template: string
      • Optionalproperties: Record<string, unknown>

      Returns void

    • Log a warning-level message.

      Type Parameters

      • T extends Record<string, unknown>

      Parameters

      Returns void

    • Polls an environment variable for log level changes.

      Parameters

      • envVar: string

        environment variable name to watch

      • intervalMs: number = 30_000

        polling interval in milliseconds (default: 30000)

      Returns void