@valkey/valkey-glide
    Preparing search index...

    Class Logger

    A singleton class that allows logging which is consistent with logs from the internal GLIDE core. The logger can be set up in 2 ways -

    1. By calling init, which configures the logger only if it wasn't previously configured.
    2. By calling setLoggerConfig, which replaces the existing configuration, and means that new logs will not be saved with the logs that were sent before the call. The previous logs will remain unchanged. If none of these functions are called, the first log attempt will initialize a new logger with default configuration.
    Index

    Methods

    • Initialize a logger if it wasn't initialized before - this method is meant to be used when there is no intention to replace an existing logger. The logger will filter all logs with a level lower than the given level. If given a fileName argument, will write the logs to files postfixed with fileName. If fileName isn't provided, the logs will be written to the console.

      Parameters

      • Optionallevel: LevelOptions

        Set the logger level to one of [ERROR, WARN, INFO, DEBUG, TRACE, OFF]. If log level isn't provided, the logger will be configured with default configuration. To turn off logging completely, set the level to level "off".

      • OptionalfileName: string

        If provided the target of the logs will be the file mentioned. Otherwise, logs will be printed to the console.

      Returns void

    • Logs the provided message if the provided log level is lower then the logger level.

      Parameters

      • logLevel: LevelOptions

        The log level of the provided message.

      • logIdentifier: string

        The log identifier should give the log a context.

      • message: string

        The message to log.

      • Optionalerr: Error

        The exception or error to log.

      Returns void

    • Creates a new logger instance and configure it with the provided log level and file name.

      Parameters

      • level: LevelOptions

        Set the logger level to one of [ERROR, WARN, INFO, DEBUG, TRACE, OFF].

      • OptionalfileName: string

        The target of the logs will be the file mentioned.

      Returns void