Documentation ¶
Index ¶
Constants ¶
View Source
const ( LevelInfo = slog.LevelInfo LevelWarn = slog.LevelWarn LevelError = slog.LevelError LevelDebug = slog.LevelDebug )
Variables ¶
View Source
var ( NewTextHandler = slog.NewTextHandler NewJSONHandler = slog.NewJSONHandler New = slog.New SetDefault = slog.SetDefault StringAttr = slog.String BoolAttr = slog.Bool Float64Attr = slog.Float64 AnyAttr = slog.Any DurationAttr = slog.Duration IntAttr = slog.Int Int64Attr = slog.Int64 Uint64Attr = slog.Uint64 GroupValue = slog.GroupValue Group = slog.Group )
Functions ¶
Types ¶
type HandlerOptions ¶
type HandlerOptions = slog.HandlerOptions
type Logger ¶
func NewLogger ¶
func NewLogger(opts ...LoggerOption) *Logger
func WithDefaultAttrs ¶
WithDefaultAttrs returns logger with default attributes.
type LoggerOption ¶
type LoggerOption func(*LoggerOptions)
func WithAddSource ¶
func WithAddSource(addSource bool) LoggerOption
WithAddSource logger option sets the add source option, which will add source file and line number to the log record.
func WithIsJSON ¶
func WithIsJSON(isJSON bool) LoggerOption
WithIsJSON logger option sets the is json option, which will set JSON format for the log record.
func WithLevel ¶
func WithLevel(level string) LoggerOption
WithLevel logger option sets the log level, if not set, the default level is Info.
func WithSetDefault ¶
func WithSetDefault(setDefault bool) LoggerOption
WithSetDefault logger option sets the set default option, which will set the created logger as default logger.
type LoggerOptions ¶
Click to show internal directories.
Click to hide internal directories.