Documentation ¶
Overview ¶
Package options holds the options handling code.
The Options struct is held in this internal package to button down access.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EntryAugmentor ¶ added in v0.11.0
EntryAugmentor augments an instance of logging.Entry. The current context and group path is provided, in case they are needed by the augmentor.
type OptionProcessor ¶
type OptionProcessor func(o *Options)
OptionProcessor interacts with the supplied Options instance.
type Options ¶
type Options struct { ExplicitLogLevel slog.Leveler EnvVarLogLevel slog.Level DefaultLogLevel slog.Leveler EntryAugmentors []EntryAugmentor // AddSource causes the handler to compute the source code position // of the log statement and add a SourceKey attribute to the output. AddSource bool // Level reports the minimum record level that will be logged. // The handler discards records with lower levels. // If Level is nil, the handler assumes LevelInfo. // The handler calls Level.Level() for each record processed; // to adjust the minimum level dynamically, use a LevelVar. Level slog.Leveler // ReplaceAttr is called to rewrite each non-group attribute before it is logged. // The attribute's value has been resolved (see [Value.Resolve]). // If ReplaceAttr returns a zero Attr, the attribute is discarded. // // The built-in attributes with keys "time", "level", "source", and "msg" // are passed to this function, except that time is omitted // if zero, and source is omitted if addSource is false. // // The first argument is a list of currently open groups that contain the // Attr. It must not be retained or modified. ReplaceAttr is never called // for Group attributes, only their contents. For example, the attribute // list // // Int("a", 1), Group("g", Int("b", 2)), Int("c", 3) // // results in consecutive calls to ReplaceAttr with the following arguments: // // nil, Int("a", 1) // []string{"g"}, Int("b", 2) // nil, Int("c", 3) // // ReplaceAttr can be used to change the default keys of the built-in // attributes, convert types (for example, to replace a `time.Time` with the // integer seconds since the Unix epoch), sanitize personal information, or // remove attributes from the output. ReplaceAttr func(groups []string, a slog.Attr) slog.Attr }
Options holds information needed to construct an instance of GcpHandler.
func ApplyOptions ¶
func ApplyOptions(options ...OptionProcessor) *Options
ApplyOptions applies the option processors, OptionProcessor, to an instance of Options which it returns.
Click to show internal directories.
Click to hide internal directories.