Back to Pocketbase

Interface Logger

static/jsvm/interfaces/slog.Logger.html

latest5.5 KB
Original Source

Interface Logger

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

Index

Methods

debugdebugContextenablederrorerrorContexthandlerinfoinfoContextloglogAttrswarnwarnContextwithwithGroup

Methods

debug

  • debug(msg, ...args): void

Debug logs at [LevelDebug].

Parameters

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

Returns void

debugContext

  • debugContext(ctx, msg, ...args): void

DebugContext logs at [LevelDebug] with the given context.

Parameters

ctx: context.Context
msg: string
Rest ...args: any[]

Returns void

enabled

  • enabled(ctx, level): boolean

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

Parameters

ctx: context.Context
level: Level

Returns boolean

error

  • error(msg, ...args): void

Error logs at [LevelError].

Parameters

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

Returns void

errorContext

  • errorContext(ctx, msg, ...args): void

ErrorContext logs at [LevelError] with the given context.

Parameters

ctx: context.Context
msg: string
Rest ...args: any[]

Returns void

handler

Handler returns l's Handler.

Returns slog.Handler

info

  • info(msg, ...args): void

Info logs at [LevelInfo].

Parameters

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

Returns void

infoContext

  • infoContext(ctx, msg, ...args): void

InfoContext logs at [LevelInfo] with the given context.

Parameters

ctx: context.Context
msg: string
Rest ...args: any[]

Returns void

log

  • log(ctx, level, msg, ...args): 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".Copy

Parameters

ctx: context.Context
level: Level
msg: string
Rest ...args: any[]

Returns void

logAttrs

  • logAttrs(ctx, level, msg, ...attrs): void

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

Parameters

ctx: context.Context
level: Level
msg: string
Rest ...attrs: Attr[]

Returns void

warn

  • warn(msg, ...args): void

Warn logs at [LevelWarn].

Parameters

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

Returns void

warnContext

  • warnContext(ctx, msg, ...args): void

WarnContext logs at [LevelWarn] with the given context.

Parameters

ctx: context.Context
msg: string
Rest ...args: any[]

Returns void

with

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 Logger

withGroup

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 Logger

Settings

Member Visibility

  • Inherited

Theme

OSLightDark

On This Page

Generated using TypeDoc