slog

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// standard levels
	LevelDebug = slog.LevelDebug
	LevelInfo  = slog.LevelInfo
	LevelWarn  = slog.LevelWarn
	LevelError = slog.LevelError

	// LevelExtraDebug is between Debug and Trace. It had extra information that's useful sometimes
	// but not as overwhelming as Trace. e.g. OTel logging is at this level.
	LevelExtraDebug = slog.LevelDebug - 1

	// Trace is the most verbose level. It includes session logging and an enormous amount of detail from
	// buildkit on cache refs and cache queries.
	LevelTrace = slog.LevelDebug - 2
)

Variables

This section is empty.

Functions

func ContextWithColorMode added in v0.11.7

func ContextWithColorMode(ctx context.Context, noColor bool) context.Context

ContextWithDebugMode enables or disables color mode in the given context's OpenTelemetry baggage.

func ContextWithDebugMode added in v0.11.7

func ContextWithDebugMode(ctx context.Context, debug bool) context.Context

ContextWithDebugMode enables or disables debug mode in the given context's OpenTelemetry baggage.

func Debug

func Debug(msg string, args ...any)

func DebugContext

func DebugContext(ctx context.Context, msg string, args ...any)

func Error

func Error(msg string, args ...any)

func ErrorContext

func ErrorContext(ctx context.Context, msg string, args ...any)

func ExtraDebug

func ExtraDebug(msg string, args ...any)

func ExtraDebugContext

func ExtraDebugContext(ctx context.Context, msg string, args ...any)

func Info

func Info(msg string, args ...any)

func InfoContext

func InfoContext(ctx context.Context, msg string, args ...any)

func NewJSONHandler

func NewJSONHandler(w io.Writer, opts *slog.HandlerOptions) *slog.JSONHandler

func NewTextHandler

func NewTextHandler(w io.Writer, opts *slog.HandlerOptions) *slog.TextHandler

func SetDefault

func SetDefault(l *Logger)

func Trace

func Trace(msg string, args ...any)

func TraceContext

func TraceContext(ctx context.Context, msg string, args ...any)

func Warn

func Warn(msg string, args ...any)

func WarnContext

func WarnContext(ctx context.Context, msg string, args ...any)

Types

type Level

type Level = slog.Level

type Logger

type Logger struct {
	*slog.Logger
}

Logger wraps the slog.Logger type with support for a few additional levels

func Default

func Default() *Logger

func New

func New(h slog.Handler) *Logger

func PrettyLogger added in v0.11.7

func PrettyLogger(dest io.Writer, profile termenv.Profile, level slog.Level) *Logger

func SpanLogger added in v0.11.7

func SpanLogger(ctx context.Context, name string, attrs ...log.KeyValue) *Logger

SpanLogger returns a Logger that writes to the give context's span logs.

The logger will use the context's baggage to determine the log level and color profile:

- If no-color=true is set in baggage, the profile will be Ascii. Otherwise, it will be ANSI.

- If debug=true is set in baggage, the log level will be Debug. Otherwise, it will be Info.

func With

func With(args ...any) *Logger

func (*Logger) ExtraDebug

func (l *Logger) ExtraDebug(msg string, args ...any)

func (*Logger) ExtraDebugContext

func (l *Logger) ExtraDebugContext(ctx context.Context, msg string, args ...any)

func (*Logger) Trace

func (l *Logger) Trace(msg string, args ...any)

func (*Logger) TraceContext

func (l *Logger) TraceContext(ctx context.Context, msg string, args ...any)

func (*Logger) With

func (l *Logger) With(args ...any) *Logger

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳