Documentation
¶
Index ¶
- Constants
- func New(ss ...Setting) *slog.Logger
- type Attr
- type Format
- type Handler
- type HandlerOptions
- type Level
- type Leveler
- type LumberjackConfig
- type Option
- type Setting
- func WithAddSource() Setting
- func WithDisableConsole() Setting
- func WithFile(file string) Setting
- func WithFormat(format Format) Setting
- func WithLevel(level Leveler) Setting
- func WithLumberjack(filename string, config *LumberjackConfig) Setting
- func WithNoColor() Setting
- func WithPath(path string) Setting
- func WithReplaceAttr(replaceAttr func(groups []string, attr Attr) Attr) Setting
- func WithTimeLayout(timeLayout string) Setting
- func WithUseDefault() Setting
- type TintOptions
Constants ¶
View Source
const ( LevelDebug = slog.LevelDebug LevelInfo = slog.LevelInfo LevelWarn = slog.LevelWarn LevelError = slog.LevelError LevelFatal = 12 )
View Source
const ( // DefaultTimeLayout the default time layout; DefaultTimeLayout = time.RFC3339 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HandlerOptions ¶
type HandlerOptions = slog.HandlerOptions
type LumberjackConfig ¶
type LumberjackConfig = struct {
// MaxSize is the maximum size in megabytes of the log file before it gets
// rotated. It defaults to 100 megabytes.
MaxSize int `json:"maxsize" yaml:"maxsize" toml:"maxsize"`
// MaxAge is the maximum number of days to retain old log files based on the
// timestamp encoded in their filename. Note that a day is defined as 24
// hours and may not exactly correspond to calendar days due to daylight
// savings, leap seconds, etc. The default is not to remove old log files
// based on age.
MaxAge int `json:"maxage" yaml:"maxage" toml:"maxage"`
// MaxBackups is the maximum number of old log files to retain. The default
// is to retain all old log files (though MaxAge may still cause them to get
// deleted.)
MaxBackups int `json:"maxbackups" yaml:"maxbackups" toml:"maxbackups"`
// LocalTime determines if the time used for formatting the timestamps in
// backup files is the computer's local time. The default is to use UTC
// time.
LocalTime bool `json:"localtime" yaml:"localtime" toml:"localtime"`
// Compress determines if the rotated log files should be compressed
// using gzip. The default is not to perform compression.
Compress bool `json:"compress" yaml:"compress" toml:"compress"`
}
type Option ¶
type Option struct {
OutputPath string
FileName string
Format Format
TimeLayout string
DisableConsole bool
Level Leveler
ReplaceAttr func(groups []string, attr Attr) Attr
AddSource bool
LumberjackConfig *LumberjackConfig
NoColor bool
UseDefault bool
}
Option custom setup config
type Setting ¶
func WithDisableConsole ¶
func WithDisableConsole() Setting
WithDisableConsole WithEnableConsole write log to os.Stdout or os.Stderr
func WithLumberjack ¶
func WithLumberjack(filename string, config *LumberjackConfig) Setting
WithLumberjack write log to some File with rotation
func WithReplaceAttr ¶
WithReplaceAttr custom replaceAttr
func WithTimeLayout ¶
WithTimeLayout custom time format
type TintOptions ¶
Click to show internal directories.
Click to hide internal directories.