DWS Packages
    Preparing search index...

    Interface LoggerSink<TLogObject, TConfig>

    A logging destination.

    This is the object a SinkFactory returns. The factory runs inside the logger worker, so the sink closes over its own state (file handles, buffers, …) instead of exposing it. All values the sink needs must be created inside the factory body — it cannot close over module-scoped imports (use dynamic import() or runtime globals such as Bun instead).

    interface LoggerSink<TLogObject = unknown, TConfig = unknown> {
        config?: TConfig;
        close?(): void | Promise<void>;
        flush?(): void | Promise<void>;
        log(
            level: LogLevels,
            timestamp: number,
            object: TLogObject,
        ): void | Promise<void>;
    }

    Type Parameters

    • TLogObject = unknown
    • TConfig = unknown
    Index

    Properties

    Methods

    Properties

    config?: TConfig

    Optional configuration for the sink

    Methods

    • Closes the sink and releases its resources. Called when the logger is closing. Optional - implement this if your sink needs cleanup (e.g. closing file handles, database connections).

      Returns void | Promise<void>

    • Flushes any buffered data to the underlying destination. Called by Logger.flush; implement it when your sink buffers writes (e.g. a file writer) and durability on flush matters.

      Returns void | Promise<void>

    • Logs a message with the sink's implementation.

      Parameters

      • level: LogLevels

        The log level at which the message should be logged.

      • timestamp: number

        The epoch timestamp (ms) at which the message was logged.

      • object: TLogObject

        The object to log.

      Returns void | Promise<void>

      A promise when the sink is asynchronous; it is awaited by Logger.flush.