Documentation ¶
Index ¶
- Constants
- func CreateLogger() *slog.Logger
- func CreateLoggerWithSource(prefix string, component string) *slog.Logger
- func ErrAttr(err error) slog.Attr
- func Fatal(logger *slog.Logger, message string, slogAttrs ...any)
- func Panic(logger *slog.Logger, message string, slogAttrs ...any)
- func RFC3339Formatter() zapcore.TimeEncoder
- func SetDynamicWriteSyncer(syncer WriteSyncer)
- func SetLoggingLevel(level string)
- func SetTimeEncoder(enc string)
- type LagerAdapter
- func (l *LagerAdapter) Debug(action string, data ...lager.Data)
- func (l *LagerAdapter) Error(action string, err error, data ...lager.Data)
- func (l *LagerAdapter) Fatal(action string, err error, data ...lager.Data)
- func (l *LagerAdapter) Info(action string, data ...lager.Data)
- func (l *LagerAdapter) RegisterSink(_ lager.Sink)
- func (l *LagerAdapter) Session(task string, data ...lager.Data) lager.Logger
- func (l *LagerAdapter) SessionName() string
- func (l *LagerAdapter) WithData(data lager.Data) lager.Logger
- func (l *LagerAdapter) WithTraceInfo(req *http.Request) lager.Logger
- type Logger
- type StructWithLogValue
- type WriteSyncer
Constants ¶
const (
RequestIdHeader = "X-Vcap-Request-Id"
)
Variables ¶
This section is empty.
Functions ¶
func CreateLogger ¶
CreateLogger returns a copy of the logger. All subsequent log statements will be nested in the 'data' field.
func CreateLoggerWithSource ¶
CreateLoggerWithSource returns a copy of the logger, which comes with the 'source' attribute set to the provided prefix and component. All subsequent log statements will be nested in the 'data' field.
func ErrAttr ¶
ErrAttr is creating an slog.String attribute with 'error' key and the provided error message as value.
func Fatal ¶
Fatal logs message and slogAttrs with Error level. For compatibility with zlog, the process is terminated via os.Exit(1) after writing the log message.
func Panic ¶
Panic logs message and slogAttrs with Error level. For compatibility with zlog, the function is panicking after writing the log message.
func RFC3339Formatter ¶
func RFC3339Formatter() zapcore.TimeEncoder
RFC3339Formatter TimeEncoder for RFC3339 with trailing Z for UTC and nanoseconds
func SetDynamicWriteSyncer ¶
func SetDynamicWriteSyncer(syncer WriteSyncer)
SetDynamicWriteSyncer sets the log handler's sink.
func SetLoggingLevel ¶
func SetLoggingLevel(level string)
SetLoggingLevel dynamically sets the logging level at runtime. See https://github.com/uber-go/zap/blob/5786471c1d41c255c1d8b63ad30a82b68eda2c21/zapcore/level.go#L180 for possible logging levels.
func SetTimeEncoder ¶
func SetTimeEncoder(enc string)
SetTimeEncoder dynamically sets the time encoder at runtime: 'rfc3339': The encoder is set to a custom RFC3339 encoder All other values: The encoder is set to an Epoch encoder
Types ¶
type LagerAdapter ¶
type LagerAdapter struct {
// contains filtered or unexported fields
}
LagerAdapter tbd
func NewLagerAdapter ¶
func NewLagerAdapter(source string) *LagerAdapter
NewLagerAdapter returns a new lager.Logger that uses slog with a zap handler underneath.
func (*LagerAdapter) Debug ¶
func (l *LagerAdapter) Debug(action string, data ...lager.Data)
Debug logs a message at the debug log setLoggingLevel.
func (*LagerAdapter) Error ¶
func (l *LagerAdapter) Error(action string, err error, data ...lager.Data)
Error logs a message at the error log setLoggingLevel.
func (*LagerAdapter) Fatal ¶
func (l *LagerAdapter) Fatal(action string, err error, data ...lager.Data)
Fatal logs a message and exits with status 1.
func (*LagerAdapter) Info ¶
func (l *LagerAdapter) Info(action string, data ...lager.Data)
Info logs a message at the info log setLoggingLevel.
func (*LagerAdapter) RegisterSink ¶
func (l *LagerAdapter) RegisterSink(_ lager.Sink)
RegisterSink is never used after initialization, so it does nothing.
func (*LagerAdapter) Session ¶
func (l *LagerAdapter) Session(task string, data ...lager.Data) lager.Logger
Session returns a new logger with a nested source and optional data.
func (*LagerAdapter) SessionName ¶
func (l *LagerAdapter) SessionName() string
SessionName returns the name of the logger source
func (*LagerAdapter) WithData ¶
func (l *LagerAdapter) WithData(data lager.Data) lager.Logger
WithData returns a logger with newly added data.
func (*LagerAdapter) WithTraceInfo ¶
func (l *LagerAdapter) WithTraceInfo(req *http.Request) lager.Logger
type StructWithLogValue ¶
type StructWithLogValue struct {
Value any
}
StructWithLogValue implements LogValue(), which allows lazy execution.
func StructValue ¶
func StructValue(obj any) StructWithLogValue
StructValue takes an arbitrary struct. It returns a StructWithLogValue. which implements LogValue(), which return an slog.Value where struct fields are parsed as a list of slog.Attr, and returned as an grouped slog.Value.
func (StructWithLogValue) LogValue ¶
func (r StructWithLogValue) LogValue() slog.Value