A Logger records structured information about each call to its Log, Debug, Info, Warn, and Error methods. For each call, it creates a [Record] and passes it to a [Handler].

To create a new Logger, call [New] or a Logger method that begins "With".

Hierarchy

  • Logger

Methods

  • Debug logs at [LevelDebug].

    Parameters

    • msg: string
    • Rest ...args: any[]

    Returns void

  • DebugContext logs at [LevelDebug] with the given context.

    Parameters

    Returns void

  • Enabled reports whether l emits log records at the given context and level.

    Parameters

    Returns boolean

  • Error logs at [LevelError].

    Parameters

    • msg: string
    • Rest ...args: any[]

    Returns void

  • ErrorContext logs at [LevelError] with the given context.

    Parameters

    Returns void

  • Info logs at [LevelInfo].

    Parameters

    • msg: string
    • Rest ...args: any[]

    Returns void

  • InfoContext logs at [LevelInfo] with the given context.

    Parameters

    Returns void

  • Log emits a log record with the current time and the given level and message. The Record's Attrs consist of the Logger's attributes followed by the Attrs specified by args.

    The attribute arguments are processed as follows:

      - If an argument is an Attr, it is used as is.
    - If an argument is a string and this is not the last argument,
    the following argument is treated as the value and the two are combined
    into an Attr.
    - Otherwise, the argument is treated as a value with key "!BADKEY".

    Parameters

    Returns void

  • LogAttrs is a more efficient version of [Logger.Log] that accepts only Attrs.

    Parameters

    Returns void

  • Warn logs at [LevelWarn].

    Parameters

    • msg: string
    • Rest ...args: any[]

    Returns void

  • WarnContext logs at [LevelWarn] with the given context.

    Parameters

    Returns void

  • With returns a Logger that includes the given attributes in each output operation. Arguments are converted to attributes as if by [Logger.Log].

    Parameters

    • Rest ...args: any[]

    Returns slog.Logger

  • WithGroup returns a Logger that starts a group, if name is non-empty. The keys of all attributes added to the Logger will be qualified by the given name. (How that qualification happens depends on the [Handler.WithGroup] method of the Logger's Handler.)

    If name is empty, WithGroup returns the receiver.

    Parameters

    • name: string

    Returns slog.Logger

Generated using TypeDoc