@samatawy/rules
    Preparing search index...

    Class Logger

    Main class to handle and configure logging with multiple logger implementations. Unlike Logger implementations, this class provides static methods to manage global logging configuration and registered loggers, as well as helper functions to create ContextLoggers and temporarily override loggers for specific code blocks.

    You can also register multiple loggers that implement the ILogger interface, which will all receive the log events that pass the log level filter. If no loggers are registered, a default ConsoleLogger will be used to output to the console.

    The LogLevel can be set globally for all loggers through the setLogLevel method, which will filter out any log events below the specified level. Each registered Logger instance can have its own level, but none can bypass the global level set by this class.

    If you need to temporarily redirect all log events to a specific logger for a block of code, you can use the withLogger helper function, which will override the logger implementation during the execution of the provided function and reset it afterward.

    Index

    Constructors

    Properties

    logLevel: LogLevel = 'info'
    loggerMap: Map<string, ILogger> = ...
    levelSupport: Record<LogLevel, boolean> = ...
    override?: ILogger

    Methods

    • Globally set the logging level for all Rule engine classes.

      Parameters

      • level: LogLevel

        the level at which to start logging events.

      Returns void

    • Parameters

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

      Returns void

    • Parameters

      • msg: string
      • ...args: unknown[]

      Returns void

    • Parameters

      • msg: string
      • ...args: unknown[]

      Returns void

    • Parameters

      • msg: string
      • ...args: unknown[]

      Returns void

    • Parameters

      • msg: string
      • ...args: unknown[]

      Returns void

    • Parameters

      • msg: string
      • ...args: unknown[]

      Returns void

    • Parameters

      • 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

    • List the currently registered loggers.

      Returns Map<string, ILogger>

      a map of logger identifiers to their ILogger implementations.

    • Override the current logger implementation with a custom logger. This is useful for temporarily redirecting all log events to a specific logger. You should not need to call this method directly. Instead, use the withLogger helper function to execute a block of code with a temporary logger override.

      Parameters

      • logger: ILogger

        the custom logger to use.

      Returns void

    • Reset any active logger override, returning to the default logging behavior. You should not need to call this method directly.

      Returns void