package slogtime

Import Path
	go.pact.im/x/slogtime (on go.dev)

Dependency Relation
	imports 4 packages, and imported by 0 packages

Involved Source Files Package slogtime provides an alternative [slog.Logger] implementation that allows using custom [time.Now] function for log records. It also has a smaller API surface that requires using explicit [slog.Level], [context.Context] and [slog.Attr]s.
Package-Level Type Names (only one, which is exported)
/* sort exporteds by: | */
Logger is an alternative implementation of [slog.Logger] that allows customizing the time source for log records. Unlike [slog.Logger], Logger does not provide convenience methods like Info, Debug, Warn, or Error. Instead, all logging is done through the Log method with explicit level, context, and attributes. Enabled reports whether l emits log records at the given context and level. Handler returns the underlying [slog.Handler]. Log emits a log record with the given level, message, and attributes. The record includes a source location obtained from the call stack. With returns a [Logger] that includes the given attributes in each output operation. Arguments are converted to attributes as if by [Logger.Log]. WithGroup returns a [Logger] that starts a group. The keys of all attributes added to the [Logger] will be qualified by the given name. WithTime returns a [Logger] that uses the given time function. If now is nil, [time.Now] will be used. func New(h slog.Handler, now func() time.Time) *Logger func (*Logger).With(attrs ...slog.Attr) *Logger func (*Logger).WithGroup(name string) *Logger func (*Logger).WithTime(now func() time.Time) *Logger
Package-Level Functions (only one, which is exported)
New creates a new [Logger] that uses the given handler and time function. If now is nil, [time.Now] will be used when logging.