Documentation
¶
Index ¶
- Constants
- Variables
- func NewHandler(pkg string) slog.Handler
- type Logger
- func (l *Logger) Critical(ctx context.Context, err error, attrs ...slog.Attr)
- func (l *Logger) Criticalw(ctx context.Context, msg string, attrs ...slog.Attr)
- func (l *Logger) Debug(ctx context.Context, msg string, attrs ...slog.Attr)
- func (l *Logger) Error(ctx context.Context, err error, attrs ...slog.Attr)
- func (l *Logger) Errorw(ctx context.Context, msg string, attrs ...slog.Attr)
- func (l *Logger) Fatal(ctx context.Context, err error, attrs ...slog.Attr)
- func (l *Logger) Fatalw(ctx context.Context, msg string, attrs ...slog.Attr)
- func (l *Logger) Info(ctx context.Context, msg string, attrs ...slog.Attr)
- func (l *Logger) Trace(ctx context.Context, msg string, attrs ...slog.Attr)
- func (l *Logger) Warn(ctx context.Context, msg string, attrs ...slog.Attr)
Constants ¶
const ( LevelTrace = slog.Level(-8) LevelDebug = slog.LevelDebug LevelInfo = slog.LevelInfo LevelWarn = slog.LevelWarn LevelError = slog.LevelError LevelCritical = slog.Level(12) LevelFatal = slog.Level(14) )
Level is a wrapper around slog.Leveler. It adds some extra Levels, like Critical.
Variables ¶
var ( String = slog.String Int = slog.Int Float = slog.Float64 Bool = slog.Bool Any = slog.Any )
Attrs are wrappers around slog.Attr.
Functions ¶
func NewHandler ¶ added in v1.2.0
NewHandler creates a new slog.Handler with OpenTelemetry support.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a wrapper around slog.Logger that adds OpenTelemetry features.
func (*Logger) Critical ¶
Critical indicates critical errors that may lead to system failure or data loss. This level is used for situations that are extremely serious and require immediate attention. It does not lead to a crash, but it should be logged and monitored closely.
func (*Logger) Criticalw ¶
Criticalw is semantically equivalent to [Critical], but it logs an error message instead of an error object.
func (*Logger) Debug ¶
Debug provides information that is useful for debugging but less detailed than trace. It's used for diagnostic information that might be helpful when trying to understand the flow of an application or troubleshoot issues.
func (*Logger) Error ¶
Error indicates significant issues that prevent the application from functioning properly.
func (*Logger) Errorw ¶
Errorw is semantically equivalent to [Error], but it logs an error message instead of an error object.
func (*Logger) Fatal ¶
Fatal indicates a fatal error that causes the current goroutine to terminate. This level is used for situations that are extremely serious and require immediate attention.
DANGER: This function uses `runtime.Goexit()`. Therefore, if called within the main goroutine you MUST call `defer os.Exit(0)` at the top of the main function.
func (*Logger) Fatalw ¶
Fatalw is semantically equivalent to [Fatal], but it logs an error message instead of an error object.
DANGER: This function uses `runtime.Goexit()`. Therefore, if called within the main goroutine you MUST call `defer os.Exit(0)` at the top of the main function.
func (*Logger) Info ¶
Info gives general information about the application’s state or normal operations, typically showing what's happening at a higher level.