Documentation ¶
Index ¶
- func DiscardHandler() slog.Handler
- func FormatLogfmtUint64(n uint64) string
- func FormatSlogValue(v slog.Value, tmp []byte) (result []byte)
- func JSONHandler(wr io.Writer) slog.Handler
- func JSONHandlerWithLevel(wr io.Writer, level slog.Level) slog.Handler
- func LogfmtHandler(wr io.Writer) slog.Handler
- func LogfmtHandlerWithLevel(wr io.Writer, level slog.Level) slog.Handler
- type TerminalHandler
- func (h *TerminalHandler) Enabled(_ context.Context, level slog.Level) bool
- func (h *TerminalHandler) Handle(_ context.Context, r slog.Record) error
- func (t *TerminalHandler) ResetFieldPadding()
- func (h *TerminalHandler) WithAttrs(attrs []slog.Attr) slog.Handler
- func (h *TerminalHandler) WithGroup(name string) slog.Handler
- type TerminalStringer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatLogfmtUint64 ¶
FormatLogfmtUint64 formats n with thousand separators.
func FormatSlogValue ¶
FormatSlogValue formats a slog.Value for serialization to terminal.
func JSONHandler ¶
JSONHandler returns a handler which prints records in JSON format.
func JSONHandlerWithLevel ¶
JSONHandlerWithLevel returns a handler which prints records in JSON format that are less than or equal to the specified verbosity level.
func LogfmtHandler ¶
LogfmtHandler returns a handler which prints records in logfmt format, an easy machine-parseable but human-readable format for key/value pairs.
For more details see: http://godoc.org/github.com/kr/logfmt
Types ¶
type TerminalHandler ¶
type TerminalHandler struct {
// contains filtered or unexported fields
}
func NewTerminalHandler ¶
func NewTerminalHandler(wr io.Writer, useColor bool) *TerminalHandler
NewTerminalHandler returns a handler which formats log records at all levels optimized for human readability on a terminal with color-coded level output and terser human friendly timestamp. This format should only be used for interactive programs or while developing.
[LEVEL] [TIME] MESSAGE key=value key=value ...
Example:
[DBUG] [May 16 20:58:45] remove route ns=haproxy addr=127.0.0.1:50002
func NewTerminalHandlerWithLevel ¶
NewTerminalHandlerWithLevel returns the same handler as NewTerminalHandler but only outputs records which are less than or equal to the specified verbosity level.
func (*TerminalHandler) ResetFieldPadding ¶
func (t *TerminalHandler) ResetFieldPadding()
ResetFieldPadding zeroes the field-padding for all attribute pairs.
type TerminalStringer ¶
type TerminalStringer interface {
TerminalString() string
}
TerminalStringer is an analogous interface to the stdlib stringer, allowing own types to have custom shortened serialization formats when printed to the screen.