Documentation ¶
Index ¶
- Constants
- type Handler
- type HandlerOption
- func WithColor() HandlerOption
- func WithDebugColor(color string) HandlerOption
- func WithErrorColor(color string) HandlerOption
- func WithFatalColor(color string) HandlerOption
- func WithGroupFilter(filter []string) HandlerOption
- func WithGroupTextOutputFormat(format string) HandlerOption
- func WithInfoColor(color string) HandlerOption
- func WithJSON() HandlerOption
- func WithLogLevel(level slog.Level) HandlerOption
- func WithShortLevels() HandlerOption
- func WithStdErr(err ...io.Writer) HandlerOption
- func WithStdOut(out ...io.Writer) HandlerOption
- func WithTextOutputFormat(format string) HandlerOption
- func WithTimeFormat(format string) HandlerOption
- func WithTraceColor(color string) HandlerOption
- func WithWarnColor(color string) HandlerOption
Constants ¶
View Source
const ( LevelTrace slog.Level = slog.LevelDebug - 2 LevelFatal slog.Level = slog.LevelError + 2 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func NewHandler(opts ...HandlerOption) *Handler
type HandlerOption ¶
type HandlerOption func(*Handler)
func WithColor ¶
func WithColor() HandlerOption
func WithDebugColor ¶
func WithDebugColor(color string) HandlerOption
func WithErrorColor ¶
func WithErrorColor(color string) HandlerOption
func WithFatalColor ¶
func WithFatalColor(color string) HandlerOption
func WithGroupFilter ¶
func WithGroupFilter(filter []string) HandlerOption
You can use this to filter out logs from specific groups
func WithGroupTextOutputFormat ¶
func WithGroupTextOutputFormat(format string) HandlerOption
func WithInfoColor ¶
func WithInfoColor(color string) HandlerOption
func WithJSON ¶
func WithJSON() HandlerOption
func WithLogLevel ¶
func WithLogLevel(level slog.Level) HandlerOption
func WithShortLevels ¶
func WithShortLevels() HandlerOption
func WithStdErr ¶
func WithStdErr(err ...io.Writer) HandlerOption
func WithStdOut ¶
func WithStdOut(out ...io.Writer) HandlerOption
func WithTextOutputFormat ¶
func WithTextOutputFormat(format string) HandlerOption
WithTextOutputFormat sets the format for the group output. The order of the fields are: 1. Record Level (Debug, Info, Warn, Error) 2. Record Time 3. Record Message
The default format is "[%s] %s - %s\n". If you want to rearrange the fields, you can use the indexes: "%[3]s %[1]s %[2]\n" This will output "{Record Message} {Record Level} {Record Time}\n"
User must provide newline in format
func WithTimeFormat ¶
func WithTimeFormat(format string) HandlerOption
func WithTraceColor ¶
func WithTraceColor(color string) HandlerOption
func WithWarnColor ¶
func WithWarnColor(color string) HandlerOption
Click to show internal directories.
Click to hide internal directories.