log

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Copyright (c) Microsoft Corporation. Licensed under the MIT License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attrs

type Attrs interface {
	Attrs() []slog.Attr
}

Attrs represents an object that exposes extra slog attributes to log.

type Logger

type Logger struct{ Wrapped *slog.Logger }

Logger is a wrapper around an slog.Logger with additional helpers and nil checking.

func Wrap

func Wrap(logger ...*slog.Logger) Logger

Wrap the slog logger.

func (Logger) Debug added in v0.3.0

func (l Logger) Debug(ctx context.Context, msg string, attrs ...slog.Attr)

Debug logs a message with structured logging.

func (Logger) Enabled

func (l Logger) Enabled(ctx context.Context, level slog.Level) bool

Enabled indicates that the logger is enabled for the given logging level.

func (Logger) Error

func (l Logger) Error(ctx context.Context, err error, attrs ...slog.Attr)

Error logs a error with structured logging.

func (Logger) Info

func (l Logger) Info(ctx context.Context, msg string, attrs ...slog.Attr)

Info logs a message with structured logging.

func (Logger) Log

func (l Logger) Log(
	ctx context.Context,
	level slog.Level,
	msg string,
	attrs ...slog.Attr,
)

Log is designed to build logging wrappers; it should not be called directly. See: https://pkg.go.dev/log/slog#hdr-Wrapping_output_methods

func (Logger) Warn added in v0.2.0

func (l Logger) Warn(ctx context.Context, m any, attrs ...slog.Attr)

Warn logs a message with structured logging.

Jump to

Keyboard shortcuts

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