Documentation
¶
Index ¶
- Constants
- Variables
- type Attr
- type Color
- type DevConfig
- type DevslogOptions
- type Format
- type Handler
- type HandlerOptions
- type JSONHandler
- type Kind
- type Level
- type LevelVar
- type Leveler
- type LogValuer
- type Logger
- type LumberjackConfig
- type LumberjackLogger
- type Option
- type Record
- 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 Source
- type TextHandler
- type TintOptions
- type Value
Constants ¶
View Source
const ( KindAny = slog.KindAny KindBool = slog.KindBool KindDuration = slog.KindDuration KindFloat64 = slog.KindFloat64 KindGroup = slog.KindGroup KindInt64 = slog.KindInt64 KindLogValuer = slog.KindLogValuer KindString = slog.KindString KindTime = slog.KindTime KindUint64 = slog.KindUint64 LevelDebug = slog.LevelDebug LevelError = slog.LevelError LevelInfo = slog.LevelInfo LevelKey = slog.LevelKey LevelWarn = slog.LevelWarn MessageKey = slog.MessageKey SourceKey = slog.SourceKey TimeKey = slog.TimeKey Black = devslog.Black Blue = devslog.Blue Cyan = devslog.Cyan Green = devslog.Green Magenta = devslog.Magenta Red = devslog.Red UnknownColor = devslog.UnknownColor White = devslog.White Yellow = devslog.Yellow )
View Source
const ( // DefaultTimeLayout the default time layout; DefaultTimeLayout = time.RFC3339 )
View Source
const (
LevelFatal = 12
)
Variables ¶
View Source
var ( Any = slog.Any AnyValue = slog.AnyValue Bool = slog.Bool BoolValue = slog.BoolValue Debug = slog.Debug DebugContext = slog.DebugContext Default = slog.Default Duration = slog.Duration DurationValue = slog.DurationValue Error = slog.Error ErrorContext = slog.ErrorContext Float64 = slog.Float64 Float64Value = slog.Float64Value Group = slog.Group GroupValue = slog.GroupValue Info = slog.Info InfoContext = slog.InfoContext Int = slog.Int Int64 = slog.Int64 Int64Value = slog.Int64Value IntValue = slog.IntValue Log = slog.Log LogAttrs = slog.LogAttrs NewJSONHandler = slog.NewJSONHandler NewLogLogger = slog.NewLogLogger NewRecord = slog.NewRecord NewTextHandler = slog.NewTextHandler SetDefault = slog.SetDefault SetLogLoggerLevel = slog.SetLogLoggerLevel String = slog.String StringValue = slog.StringValue Time = slog.Time TimeValue = slog.TimeValue Uint64 = slog.Uint64 Uint64Value = slog.Uint64Value Warn = slog.Warn WarnContext = slog.WarnContext With = slog.With Err = tint.Err NewTintHandler = tint.NewHandler NewDevslogHandler = devslog.NewHandler )
Functions ¶
This section is empty.
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 Color `json:"debugcolor" yaml:"debugcolor" toml:"debugcolor"`
// Set color for Info level, default: devslog.Green
InfoColor Color `json:"infocolor" yaml:"infocolor" toml:"infocolor"`
// Set color for Warn level, default: devslog.Yellow
WarnColor Color `json:"warncolor" yaml:"warncolor" toml:"warncolor"`
// Set color for Error level, default: devslog.Red
ErrorColor 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 DevslogOptions ¶ added in v0.0.81
type HandlerOptions ¶
type HandlerOptions = slog.HandlerOptions
type JSONHandler ¶ added in v0.0.81
type JSONHandler = slog.JSONHandler
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 LumberjackLogger ¶ added in v0.0.81
type LumberjackLogger = lumberjack.Logger
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 TextHandler ¶ added in v0.0.81
type TextHandler = slog.TextHandler
type TintOptions ¶
Click to show internal directories.
Click to hide internal directories.