log

package
v0.1.0-alpha.13 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: Apache-2.0 Imports: 5 Imported by: 4

Documentation

Overview

Package log provides structured logging functionality with context support.

Index

Constants

View Source
const (
	// DomainNameKey is the context key for domain name.
	DomainNameKey contextKey = "domainName"
	// TraceIDKey is the context key for trace ID.
	TraceIDKey contextKey = "traceId"
	// ServiceNameKey is the context key for service name.
	ServiceNameKey contextKey = "serviceName"
	// StartupTaskKey is the context key for startup task.
	StartupTaskKey contextKey = "startupTask"
	// UserIDKey is the context key for user ID.
	UserIDKey contextKey = "userId"
	// WorkerIDKey is the context key worker of queue processor.
	WorkerIDKey contextKey = "workerId"
)

Variables

View Source
var Logger logger = New(os.Stdout, "text", slog.LevelInfo, nil) //nolint:gochecknoglobals

Logger is the default logger instance used by package-level logging functions.

Functions

func Debug

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

Debug logs a message at Debug level.

func DebugContext

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

DebugContext logs a message at Debug level with context.

func Error

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

Error logs a message at Error level.

func ErrorContext

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

ErrorContext logs a message at Error level with context.

func Info

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

Info logs a message at Info level.

func InfoContext

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

InfoContext logs a message at Info level with context.

func New

func New(w io.Writer, loggerType string, level slog.Level, contextKeys map[string]any) *slog.Logger

New creates a new slog.Logger with the specified type (json/text), log level, and additional context keys to include.

func SetDefault

func SetDefault(l logger)

SetDefault sets the default logger used by the package-level logging functions.

func Warn

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

Warn logs a message at Warn level.

func WarnContext

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

WarnContext logs a message at Warn level with context.

Types

This section is empty.

Jump to

Keyboard shortcuts

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