Documentation
¶
Index ¶
- Constants
- func New(ss ...Setting) *slog.Logger
- type Attr
- type DevConfig
- type Format
- type Handler
- type HandlerOptions
- type Level
- type Leveler
- type LumberjackConfig
- type Option
- type Setting
- func WithAddSource() Setting
- func WithDevConfig(config *DevConfig) 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 DevConfig ¶ added in v0.0.43
type DevConfig = struct {
// Max number of printed elements in slice.
MaxSlice uint `json:"maxslice" yaml:"maxslice" toml:"maxslice"`
// If the attributes should be sorted by keys
SortKeys bool `json:"sortkeys" yaml:"sortkeys" toml:"sortkeys"`
// Add blank line after each log
NewLine bool `json:"newline" yaml:"newline" toml:"newline"`
// Indent \n in strings
Indent bool `json:"indent" yaml:"indent" toml:"indent"`
// Set color for Debug level, default: devslog.Blue
DebugColor devslog.Color `json:"debugcolor" yaml:"debugcolor" toml:"debugcolor"`
// Set color for Info level, default: devslog.Green
InfoColor devslog.Color `json:"infocolor" yaml:"infocolor" toml:"infocolor"`
// Set color for Warn level, default: devslog.Yellow
WarnColor devslog.Color `json:"warncolor" yaml:"warncolor" toml:"warncolor"`
// Set color for Error level, default: devslog.Red
ErrorColor devslog.Color `json:"errorcolor" yaml:"errorcolor" toml:"errorcolor"`
// Max stack trace frames when unwrapping errors
MaxTrace uint `json:"maxtrace" yaml:"maxtrace" toml:"maxtrace"`
// Use method String() for formatting value
Formatter bool `json:"formatter" yaml:"formatter" toml:"formatter"`
}
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
DevConfig *DevConfig
NoColor bool
UseDefault bool
}
Option custom setup config
type Setting ¶
type Setting = func(*Option)
func WithDevConfig ¶ added in v0.0.43
WithDevConfig set dev config
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.