Documentation ¶
Index ¶
- Constants
- type StructuredLogger
- func (sl *StructuredLogger) Log(ctx context.Context, level slog.Level, msg string, args ...any)
- func (sl *StructuredLogger) LogAlert(ctx context.Context, msg string, args ...any)
- func (sl *StructuredLogger) LogCritical(ctx context.Context, msg string, args ...any)
- func (sl *StructuredLogger) LogDebug(ctx context.Context, msg string, args ...any)
- func (sl *StructuredLogger) LogEmergency(ctx context.Context, msg string, args ...any)
- func (sl *StructuredLogger) LogError(ctx context.Context, msg string, args ...any)
- func (sl *StructuredLogger) LogInfo(ctx context.Context, msg string, args ...any)
- func (sl *StructuredLogger) LogNotice(ctx context.Context, msg string, args ...any)
- func (sl *StructuredLogger) LogWarning(ctx context.Context, msg string, args ...any)
- func (sl *StructuredLogger) SetLogLevel(level string)
Constants ¶
View Source
const ( LevelNotice = slog.LevelInfo + 1 LevelCritical = slog.LevelError + 1 LevelAlert = slog.LevelError + 2 LevelEmergency = slog.LevelError + 3 )
Custom log levels beyond the standard slog levels
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type StructuredLogger ¶
type StructuredLogger struct {
// contains filtered or unexported fields
}
func NewStructuredLogger ¶
func NewStructuredLogger(projectID, component string, r *http.Request, writer io.Writer) *StructuredLogger
NewStructuredLogger creates a new StructuredLogger instance with optional trace information.
func (*StructuredLogger) LogAlert ¶
func (sl *StructuredLogger) LogAlert(ctx context.Context, msg string, args ...any)
LogAlert logs an alert message (custom level).
func (*StructuredLogger) LogCritical ¶
func (sl *StructuredLogger) LogCritical(ctx context.Context, msg string, args ...any)
LogCritical logs a critical message (custom level).
func (*StructuredLogger) LogDebug ¶
func (sl *StructuredLogger) LogDebug(ctx context.Context, msg string, args ...any)
LogDebug logs a debug message.
func (*StructuredLogger) LogEmergency ¶
func (sl *StructuredLogger) LogEmergency(ctx context.Context, msg string, args ...any)
LogEmergency logs an emergency message (custom level).
func (*StructuredLogger) LogError ¶
func (sl *StructuredLogger) LogError(ctx context.Context, msg string, args ...any)
LogError logs an error message.
func (*StructuredLogger) LogInfo ¶
func (sl *StructuredLogger) LogInfo(ctx context.Context, msg string, args ...any)
LogInfo logs an info message.
func (*StructuredLogger) LogNotice ¶
func (sl *StructuredLogger) LogNotice(ctx context.Context, msg string, args ...any)
LogNotice logs a notice message (mapped to LevelNotice).
func (*StructuredLogger) LogWarning ¶
func (sl *StructuredLogger) LogWarning(ctx context.Context, msg string, args ...any)
LogWarning logs a warning message.
func (*StructuredLogger) SetLogLevel ¶
func (sl *StructuredLogger) SetLogLevel(level string)
SetLogLevel sets the minimum level of logs to output.
Click to show internal directories.
Click to hide internal directories.