Documentation
¶
Overview ¶
Package log provides structured logging functionality with context support.
Index ¶
- Constants
- Variables
- func Debug(msg string, args ...any)
- func DebugContext(ctx context.Context, msg string, args ...any)
- func Error(msg string, args ...any)
- func ErrorContext(ctx context.Context, msg string, args ...any)
- func Info(msg string, args ...any)
- func InfoContext(ctx context.Context, msg string, args ...any)
- func New(w io.Writer, loggerType string, level slog.Level, contextKeys map[string]any) *slog.Logger
- func SetDefault(l logger)
- func Warn(msg string, args ...any)
- func WarnContext(ctx context.Context, msg string, args ...any)
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 DebugContext ¶
DebugContext logs a message at Debug level with context.
func ErrorContext ¶
ErrorContext logs a message at Error level with context.
func InfoContext ¶
InfoContext logs a message at Info level with context.
func New ¶
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.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.