Documentation ¶
Index ¶
- Constants
- Variables
- func InitCLIDefault()
- func InitDefault()
- func NewHandler(options *options) slog.Handler
- func NewHandlerOptions(level slog.Leveler, opt *Options) slog.HandlerOptions
- func NewLogger(opts ...Option) *slog.Logger
- type CLIHandler
- type CLIHandlerOptions
- type Option
- func WithDisableSource() Option
- func WithDisableTime() Option
- func WithFormat(format string) Option
- func WithFullSource() Option
- func WithLevel(level string) Option
- func WithOrganization(name string) Option
- func WithOutput(output string) Option
- func WithTracing() Option
- func WithWriter(w io.Writer) Option
- type Options
- type TracingHandler
- func (h *TracingHandler) Enabled(ctx context.Context, level slog.Level) bool
- func (h *TracingHandler) Handle(ctx context.Context, r slog.Record) error
- func (h *TracingHandler) Handler() slog.Handler
- func (h *TracingHandler) WithAttrs(attrs []slog.Attr) slog.Handler
- func (h *TracingHandler) WithGroup(name string) slog.Handler
Constants ¶
View Source
const TraceIDKey = "trace_id"
Variables ¶
View Source
var Colors = map[slog.Level]*color.Color{ slog.LevelDebug: color.New(color.FgWhite), slog.LevelInfo: color.New(color.FgBlue), slog.LevelWarn: color.New(color.FgYellow), slog.LevelError: color.New(color.FgRed), }
View Source
var Strings = map[slog.Level]string{ slog.LevelDebug: "•", slog.LevelInfo: "•", slog.LevelWarn: "•", slog.LevelError: "⨯", }
Functions ¶
func NewHandler ¶
func NewHandlerOptions ¶
func NewHandlerOptions(level slog.Leveler, opt *Options) slog.HandlerOptions
Types ¶
type CLIHandler ¶
func NewCLIHandler ¶
func NewCLIHandler( out io.Writer, opts *CLIHandlerOptions, ) *CLIHandler
type CLIHandlerOptions ¶
type CLIHandlerOptions struct { DisableColor bool slog.HandlerOptions }
type Option ¶
type Option func(o *options)
Option is an application option.
func WithDisableSource ¶
func WithDisableSource() Option
func WithDisableTime ¶
func WithDisableTime() Option
func WithFormat ¶
func WithFullSource ¶
func WithFullSource() Option
func WithOrganization ¶ added in v1.3.1
func WithOutput ¶
func WithTracing ¶
func WithTracing() Option
func WithWriter ¶
type Options ¶
type Options struct { DisableSource bool FullSource bool DisableTime bool DisableColor bool // for cli // for format Name string Organization string Context string }
Options
type TracingHandler ¶
type TracingHandler struct {
// contains filtered or unexported fields
}
func NewTracingHandler ¶
func NewTracingHandler(h slog.Handler) *TracingHandler
func (*TracingHandler) Enabled ¶
Enabled implements Handler.Enabled by reporting whether level is at least as large as h's level.
func (*TracingHandler) Handler ¶
func (h *TracingHandler) Handler() slog.Handler
Handler returns the Handler wrapped by handler.
Click to show internal directories.
Click to hide internal directories.