@samatawy/rules
    Preparing search index...

    Class ContextLogger

    Logger implementation to handle and configure logging for a specific working context. This allows you to log events related to that context and manage them separately from other contexts.

    N.B. This does not immediately write to the registered loggers, it stores the events in a local array until the flush method is called. This allows you to control when the events are actually logged, for example after a certain operation is completed or when an error occurs.

    N.B. If you need to use the loggers registered in Logger, you can create a ContextLogger through getContextLogger() to automatically register all loggers from Logger to the new ContextLogger. You can also register and unregister loggers directly to a ContextLogger, which will not affect the loggers registered in Logger or other ContextLoggers.

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    • Parameters

      • logger: any
      • func: string
      • msg: string
      • ...args: unknown[]

      Returns void

    • Register a new bridge to connect your preferred logging library through an ILogger implementation.

      Parameters

      • name: string

        the local identifier for the bridge.

      • logger: ILogger

        an implementation of ILogger to register.

      Returns void

    • Remove a previously connected bridge to an external logging library.

      Parameters

      • logger: string | ILogger

        the identifier of the bridge (used to register).

      Returns void

    • Flush all logged events to the registered loggers, writing them using any registered loggers. This allows you to control when the events are actually logged, for example after a certain operation is completed or when an error occurs.

      Returns void