Documentation
¶
Index ¶
- Constants
- func New(opts ...Option) *slog.Logger
- func NewPrettyHandler(w io.Writer, opts *Options) slog.Handler
- type Buffer
- func (b *Buffer) AppendBool(v bool)
- func (b *Buffer) AppendByte(p byte)
- func (b *Buffer) AppendBytes(p []byte)
- func (b *Buffer) AppendFloat(f float64, bitSize int)
- func (b *Buffer) AppendFloat32(f float32)
- func (b *Buffer) AppendFloat64(f float64)
- func (b *Buffer) AppendInt(i int64)
- func (b *Buffer) AppendQuote(s string)
- func (b *Buffer) AppendString(s string)
- func (b *Buffer) AppendTimeFormat(t time.Time, layout string)
- func (b *Buffer) AppendUint(i uint64)
- func (b *Buffer) Cap() int
- func (b *Buffer) Len() int
- func (b *Buffer) Replace(i int, p byte)
- func (b *Buffer) Reset()
- func (b *Buffer) String() string
- func (b *Buffer) Write(p []byte) (int, error)
- func (b *Buffer) WriteString(s string) (int, error)
- func (b *Buffer) WriteTo(writer io.Writer) (int64, error)
- type LevelFormatter
- type Option
- type Options
- type PrettyHandler
- type ReplaceAttrFunc
- type SourceFormatter
- type TimeFormatter
Constants ¶
View Source
const ( FormatJson = "json" FormatText = "text" FormatPretty = "pretty" FormatDiscard = "discard" LevelDebug = "debug" LevelInfo = "info" LevelWarn = "warn" LevelError = "error" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
func (*Buffer) AppendBool ¶
func (*Buffer) AppendByte ¶
func (*Buffer) AppendBytes ¶
func (*Buffer) AppendFloat ¶
func (*Buffer) AppendFloat32 ¶
func (*Buffer) AppendFloat64 ¶
func (*Buffer) AppendQuote ¶
func (*Buffer) AppendString ¶
func (*Buffer) AppendUint ¶
type LevelFormatter ¶
func DefaultLevelFormatter ¶
func DefaultLevelFormatter(color bool) LevelFormatter
type Options ¶
type Options struct {
// Level is the minimum [slog.Level] that will be logged.
// Records with lower levels will be discarded.
Level slog.Leveler
// ReplaceAttr is used to rewrite each non-group [slog.Attr] before it is
// logged. See https://pkg.go.dev/log/slog#HandlerOptions for details.
ReplaceAttr ReplaceAttrFunc
// AddSource enables computing the source code position of the log
// statement and adds [slog.SourceKey] attributes to the output.
AddSource bool
// DisableColor disables the use of ANSI colour codes in messages.
DisableColor bool
// TimeFormatter is the [time.Time] formatter used to format log timestamps.
TimeFormatter TimeFormatter
// LevelFormatter is the [slog.Level] formatter used to format log levels.
LevelFormatter LevelFormatter
// SourceFormatter is the [slog.Source] formatter used to format log sources.
SourceFormatter SourceFormatter
}
func (*Options) ToSlogHandleOptions ¶
func (o *Options) ToSlogHandleOptions() *slog.HandlerOptions
type PrettyHandler ¶
type PrettyHandler struct {
// contains filtered or unexported fields
}
type SourceFormatter ¶
func DefaultSourceFormatter ¶
func DefaultSourceFormatter(color bool) SourceFormatter
type TimeFormatter ¶
func DefaultTimeFormatter ¶
func DefaultTimeFormatter(layout string) TimeFormatter
Click to show internal directories.
Click to hide internal directories.