Class Logger

Hierarchy

  • EventEmitter<{
        debug: [data: string];
        entry: [data: string, level: LogLevel];
        error: [data: string | Error];
        info: [data: string];
        log: [data: string];
        send: [data: IOMessage];
        warn: [data: string | Error];
    }>
    • Logger

Constructors

  • Parameters

    Returns Logger

Properties

_entries: string[] = []
io: Set<IO<SupportedInterface>> = ...
options: Partial<LoggerOptions> = {}
prefixed: string | boolean

Accessors

  • get attachedIO(): number
  • Get the number of attached streams

    Returns number

    number of attached streams

  • get entries(): string[]
  • Gets the array of log entries. Empty if retainLogs is false.

    Returns string[]

    A copy of the log entries array.

Methods

  • Type Parameters

    • T extends "send" | "log" | "info" | "warn" | "error" | "debug" | "entry"

    Parameters

    • event: T
    • fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: ArgumentMap<{
                debug: [data: string];
                entry: [data: string, level: LogLevel];
                error: [data: string | Error];
                info: [data: string];
                log: [data: string];
                send: [data: IOMessage];
                warn: [data: string | Error];
            }>[Extract<T, "send" | "log" | "info" | "warn" | "error" | "debug" | "entry">]

          Returns void

    • Optional context: any

    Returns this

  • Attaches an input or output to the Logger

    Parameters

    • io: Logger

      The interface to attach.

    • inputLevels: LogLevel[]

      The log levels to use from the i/o

    • outputLevels: LogLevel[]

      The log levels to use from the i/o If log levels are not provided, all log levels will be attached.

    • Optional prefix: string

    Returns void

  • Type Parameters

    Parameters

    • io: I
    • Optional levels: LogLevel[]
    • Optional prefix: string

    Returns void

  • Type Parameters

    Parameters

    Returns void

  • Clears retained log entries

    Returns boolean

    whether the entries where cleared or not

  • Logs a debug message with the LogLevel.DEBUG level.

    Parameters

    • Rest ...data: string[]

      The log message.

    Returns void

  • Detaches an input or output from the Logger

    Parameters

    • io: Logger

      The interface to detach.

    • inputLevels: LogLevel[]

      The log levels to use from the i/o

    • outputLevels: LogLevel[]

      The log levels to use from the i/o If log levels are not provided, all log levels will be detached.

    Returns void

  • Type Parameters

    Parameters

    Returns void

  • Type Parameters

    Parameters

    Returns void

  • Calls each of the listeners registered for a given event.

    Type Parameters

    • T extends "send" | "log" | "info" | "warn" | "error" | "debug" | "entry"

    Parameters

    • event: T
    • Rest ...args: ArgumentMap<{
          debug: [data: string];
          entry: [data: string, level: LogLevel];
          error: [data: string | Error];
          info: [data: string];
          log: [data: string];
          send: [data: IOMessage];
          warn: [data: string | Error];
      }>[Extract<T, "send" | "log" | "info" | "warn" | "error" | "debug" | "entry">]

    Returns boolean

  • Logs an error message with the LogLevel.ERROR level.

    Parameters

    • data: string | Error

      The error or log message.

    Returns Error

  • Return an array listing the events for which the emitter has registered listeners.

    Returns ("send" | "log" | "info" | "warn" | "error" | "debug" | "entry")[]

  • Logs a info message with the LogLevel.INFO level.

    Parameters

    • Rest ...data: string[]

      The log message.

    Returns void

  • Return the number of listeners listening to a given event.

    Parameters

    • event: "send" | "log" | "info" | "warn" | "error" | "debug" | "entry"

    Returns number

  • Return the listeners registered for a given event.

    Type Parameters

    • T extends "send" | "log" | "info" | "warn" | "error" | "debug" | "entry"

    Parameters

    • event: T

    Returns ((...args) => void)[]

  • Logs a message with the LogLevel.LOG level.

    Parameters

    • Rest ...data: string[]

      The log message.

    Returns void

  • Type Parameters

    • T extends "send" | "log" | "info" | "warn" | "error" | "debug" | "entry"

    Parameters

    • event: T
    • Optional fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: ArgumentMap<{
                debug: [data: string];
                entry: [data: string, level: LogLevel];
                error: [data: string | Error];
                info: [data: string];
                log: [data: string];
                send: [data: IOMessage];
                warn: [data: string | Error];
            }>[Extract<T, "send" | "log" | "info" | "warn" | "error" | "debug" | "entry">]

          Returns void

    • Optional context: any
    • Optional once: boolean

    Returns this

  • Add a listener for a given event.

    Type Parameters

    • T extends "send" | "log" | "info" | "warn" | "error" | "debug" | "entry"

    Parameters

    • event: T
    • fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: ArgumentMap<{
                debug: [data: string];
                entry: [data: string, level: LogLevel];
                error: [data: string | Error];
                info: [data: string];
                log: [data: string];
                send: [data: IOMessage];
                warn: [data: string | Error];
            }>[Extract<T, "send" | "log" | "info" | "warn" | "error" | "debug" | "entry">]

          Returns void

    • Optional context: any

    Returns this

  • Add a one-time listener for a given event.

    Type Parameters

    • T extends "send" | "log" | "info" | "warn" | "error" | "debug" | "entry"

    Parameters

    • event: T
    • fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: ArgumentMap<{
                debug: [data: string];
                entry: [data: string, level: LogLevel];
                error: [data: string | Error];
                info: [data: string];
                log: [data: string];
                send: [data: IOMessage];
                warn: [data: string | Error];
            }>[Extract<T, "send" | "log" | "info" | "warn" | "error" | "debug" | "entry">]

          Returns void

    • Optional context: any

    Returns this

  • Remove all listeners, or those of the specified event.

    Parameters

    • Optional event: "send" | "log" | "info" | "warn" | "error" | "debug" | "entry"

    Returns this

  • Remove the listeners of a given event.

    Type Parameters

    • T extends "send" | "log" | "info" | "warn" | "error" | "debug" | "entry"

    Parameters

    • event: T
    • Optional fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: ArgumentMap<{
                debug: [data: string];
                entry: [data: string, level: LogLevel];
                error: [data: string | Error];
                info: [data: string];
                log: [data: string];
                send: [data: IOMessage];
                warn: [data: string | Error];
            }>[Extract<T, "send" | "log" | "info" | "warn" | "error" | "debug" | "entry">]

          Returns void

    • Optional context: any
    • Optional once: boolean

    Returns this

  • Outputs a log message to attached outputs.

    Parameters

    • contents: string

      The log message to be sent.

    • level: LogLevel

      The log level for the message. Defaults to LogLevel.LOG.

    Returns void

  • Outputs a log message to attached outputs.

    Parameters

    Returns void

  • Converts the log entries to a string.

    Returns string

    A string representation of the log entries.

  • Logs a warning message with the LogLevel.WARN level.

    Parameters

    • data: string | Error

      The error or log message.

    Returns Error