Documentation ¶
Index ¶
- Constants
- func BySerialDesc(i, j Message) int
- func ValidLevels() []string
- type ArgsUpdater
- type Attr
- type Getter
- type Interface
- type Logger
- func (e Logger) AddArgsUpdater(updater ArgsUpdater)
- func (l *Logger) Debug(msg string, args ...any)
- func (l *Logger) Error(msg string, args ...any)
- func (l *Logger) Get(id resource.ID) (Message, error)
- func (l *Logger) Info(msg string, args ...any)
- func (l *Logger) List() []Message
- func (l *Logger) Warn(msg string, args ...any)
- type Message
- type Options
- type ReferenceUpdater
Constants ¶
View Source
const DefaultLevel = "info"
Variables ¶
This section is empty.
Functions ¶
func BySerialDesc ¶
BySerialDesc sorts log messages by their serial.
func ValidLevels ¶ added in v0.4.0
func ValidLevels() []string
ValidLevels returns valid strings for choosing a log level. Returns the default log level first.
Types ¶
type ArgsUpdater ¶ added in v0.5.2
ArgsUpdater updates a log message's arguments.
type Interface ¶
type Interface interface { Debug(msg string, args ...any) Info(msg string, args ...any) Warn(msg string, args ...any) Error(msg string, args ...any) AddArgsUpdater(enricher ArgsUpdater) }
var Discard Interface = &noop{}
type Logger ¶
Logger wraps slog, providing further functionality such as emitting log records as pug events, and enriching records with further attributes.
func (Logger) AddArgsUpdater ¶ added in v0.5.2
func (e Logger) AddArgsUpdater(updater ArgsUpdater)
type Message ¶
type Message struct { // A message is a pug resource, but only insofar as it makes it easier to // handle consistently alongside all other resources (modules, workspaces, // etc) in the TUI. resource.ID Time time.Time Level string Message string `json:"msg"` Attributes []Attr }
Message is the event payload for a log message
type ReferenceUpdater ¶ added in v0.5.2
ReferenceUpdater checks log arguments for references to T via its ID, either directly or via a struct field, and updates or adds T to the log arguments accordingly.
func (*ReferenceUpdater[T]) UpdateArgs ¶ added in v0.5.2
func (e *ReferenceUpdater[T]) UpdateArgs(args ...any) []any
Click to show internal directories.
Click to hide internal directories.