Documentation ¶
Index ¶
- Constants
- func DefaultValuePatterns() []string
- func NewHandler(l Logger) slog.Handler
- type Data
- type JSONRedacter
- type LogFormat
- type LogLevel
- type Logger
- type ReconfigurableSink
- type Sink
- func NewPrettySink(writer io.Writer, minLogLevel LogLevel) Sink
- func NewRedactingSink(sink Sink, keyPatterns []string, valuePatterns []string) (Sink, error)
- func NewSlogSink(l *slog.Logger) Sink
- func NewTruncatingSink(sink Sink, maxDataStringLength int) Sink
- func NewWriterSink(writer io.Writer, minLogLevel LogLevel) Sink
Constants ¶
const ( StackTraceBufferSize = 1024 * 100 RequestIdHeader = "X-Vcap-Request-Id" )
Variables ¶
This section is empty.
Functions ¶
func DefaultValuePatterns ¶
func DefaultValuePatterns() []string
func NewHandler ¶ added in v3.0.3
NewHandler wraps the logger as a slog.Handler The supplied Logger must be a lager.logger type created by lager.NewLogger(), otherwise it panics.
Note the following log level conversions:
slog.LevelDebug -> lager.DEBUG slog.LevelError -> lager.ERROR slog.LevelError -> lager.FATAL default -> lager.INFO
Types ¶
type JSONRedacter ¶
type JSONRedacter struct {
// contains filtered or unexported fields
}
func NewJSONRedacter ¶
func NewJSONRedacter(keyPatterns []string, valuePatterns []string) (*JSONRedacter, error)
func (JSONRedacter) Redact ¶
func (r JSONRedacter) Redact(data []byte) []byte
type LogFormat ¶
type Logger ¶
type Logger interface { RegisterSink(Sink) Session(task string, data ...Data) Logger SessionName() string Debug(action string, data ...Data) Info(action string, data ...Data) Error(action string, err error, data ...Data) Fatal(action string, err error, data ...Data) WithData(Data) Logger WithTraceInfo(*http.Request) Logger }
type ReconfigurableSink ¶
type ReconfigurableSink struct {
// contains filtered or unexported fields
}
func NewReconfigurableSink ¶
func NewReconfigurableSink(sink Sink, initialMinLogLevel LogLevel) *ReconfigurableSink
func (*ReconfigurableSink) GetMinLevel ¶
func (sink *ReconfigurableSink) GetMinLevel() LogLevel
func (*ReconfigurableSink) Log ¶
func (sink *ReconfigurableSink) Log(log LogFormat)
func (*ReconfigurableSink) SetMinLevel ¶
func (sink *ReconfigurableSink) SetMinLevel(level LogLevel)
type Sink ¶
type Sink interface { //Log to the sink. Best effort -- no need to worry about errors. Log(LogFormat) }
A Sink represents a write destination for a Logger. It provides a thread-safe interface for writing logs
func NewRedactingSink ¶
NewRedactingSink creates a sink that redacts sensitive information from the data field. The old behavior of NewRedactingWriterSink (which was removed in v2) can be obtained using the following code:
redactingSink, err := NewRedactingSink( NewWriterSink(writer, minLogLevel), keyPatterns, valuePatterns, ) if err != nil { return nil, err } return NewReconfigurableSink( redactingSink, minLogLevel, ), nil
func NewSlogSink ¶ added in v3.0.3
NewSlogSink wraps a slog.Logger as a lager Sink This allows code using slog to integrate with code that uses lager Note the following log level conversions:
lager.DEBUG -> slog.LevelDebug lager.ERROR -> slog.LevelError lager.FATAL -> slog.LevelError default -> slog.LevelInfo
func NewTruncatingSink ¶
NewTruncatingSink returns a sink that truncates strings longer than the max data string length Example:
writerSink := lager.NewWriterSink(os.Stdout, lager.INFO) sink := lager.NewTruncatingSink(testSink, 20) logger := lager.NewLogger("test") logger.RegisterSink(sink) logger.Info("message", lager.Data{"A": strings.Repeat("a", 25)})
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
Package lagerctx provides convenience when using Lager with the context feature of the standard library.
|
Package lagerctx provides convenience when using Lager with the context feature of the standard library. |