log

package
v0.10.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package log contains functions used internally for logging to a default logger implementing slog.Logger. The default logger can be set using [logger.SetDefault].

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Default added in v0.7.0

func Default() *slog.Logger

Default returns the default logger. This method is guaranteed to always return a value, even if the default has explicitly beed set to nil. If no default has been configured, or overriden by a nil value, the logger will discard all logged messages.

func ErrAttr added in v0.7.0

func ErrAttr(err error) slog.Attr

ErrAttr creates a log record attribute representing an error.

If the error originates from V8, the relevant JavaScript location and stack trace are included in the log record.

func ReplaceStackAttr added in v0.10.3

func ReplaceStackAttr(grps []string, attr slog.Attr) slog.Attr

ReplaceStackAttr removes "stack" entries from log output. While stack output can be beneficial in some scenarios, it's very verbose.

There is also a security consideration, stack output can expose details about the inner workings of the system, that can be exploited to find weaknesses. The intended use case of this library is not production use, there are still risks log messages leak, e.g., build logs.

func SetDefault

func SetDefault(logger *slog.Logger)

Set a default slog/Logger instance to use in contexts where a specific logger has not been set. If no default logger is set, the default will discard all log messages.

Types

type LogSource added in v0.5.1

type LogSource interface{ Logger() *slog.Logger }

type Logger added in v0.5.1

type Logger = *slog.Logger

type LoggerLogSource added in v0.5.1

type LoggerLogSource struct{ L *slog.Logger }

func (LoggerLogSource) Logger added in v0.5.1

func (s LoggerLogSource) Logger() Logger

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL