Documentation
¶
Overview ¶
Package sloge implements the functions, types, and interfaces for the module.
Package sloge implements the functions, types, and interfaces for the module.
Package sloge implements the functions, types, and interfaces for the module.
Package sloge implements the functions, types, and interfaces for the module.
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 WithConsole(set bool) Setting
- func WithDefault(set bool) Setting
- func WithDevConfig(config *DevConfig) 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
- type Source
- type TextHandler
- type TintOptions
- type Value
Constants ¶
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 )
slog is a wrapper around slog
const ( 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 )
devslog is a wrapper around devslog
const ( // DefaultTimeLayout the default time layout; DefaultTimeLayout = time.RFC3339 )
const (
LevelFatal = 12
)
Variables ¶
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 )
var ( Err = tint.Err NewTintHandler = tint.NewHandler )
tint is a wrapper around tint
var ( // NewDevSlogHandler is a wrapper around devslog.NewHandler NewDevSlogHandler = devslog.NewHandler )
Functions ¶
This section is empty.
Types ¶
type DevConfig ¶ added in v0.0.87
type DevConfig = struct { // Max number of printed elements in slice. MaxSlice uint `json:"max_slice" yaml:"max_slice" toml:"max_slice"` // If the attributes should be sorted by keys SortKeys bool `json:"sort_keys" yaml:"sort_keys" toml:"sort_keys"` // 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:"debug_color" yaml:"debug_color" toml:"debug_color"` // Set color for Info level, default: devslog.Green InfoColor Color `json:"info_color" yaml:"info_color" toml:"info_color"` // Set color for Warn level, default: devslog.Yellow WarnColor Color `json:"warn_color" yaml:"warn_color" toml:"warn_color"` // Set color for Error level, default: devslog.Red ErrorColor Color `json:"error_color" yaml:"error_color" toml:"error_color"` // Max stack trace frames when unwrapping errors MaxTrace uint `json:"max_trace" yaml:"max_trace" toml:"max_trace"` // Use method String() for formatting value Formatter bool `json:"formatter" yaml:"formatter" toml:"formatter"` }
type DevSlogOptions ¶ added in v0.0.87
devslog is a wrapper around devslog
type HandlerOptions ¶ added in v0.0.87
type HandlerOptions = slog.HandlerOptions
slog is a wrapper around slog
type JSONHandler ¶ added in v0.0.87
type JSONHandler = slog.JSONHandler
slog is a wrapper around slog
type LumberjackConfig ¶ added in v0.0.87
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:"max_size" yaml:"max_size" toml:"max_size"` // 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:"max_age" yaml:"max_age" toml:"max_age"` // 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:"max_backups" yaml:"max_backups" toml:"max_backups"` // 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.87
type LumberjackLogger = lumberjack.Logger
LumberjackLogger is a wrapper around lumberjack.Logger
type Option ¶
type Option struct { OutputPath string FileName string Format Format TimeLayout string Console bool Level Leveler ReplaceAttr func(groups []string, attr Attr) Attr AddSource bool LumberjackConfig *LumberjackConfig DevConfig *DevConfig NoColor bool Default bool }
Option custom setup config
type Setting ¶ added in v0.0.87
type Setting = func(*Option)
func WithAddSource ¶ added in v0.0.87
func WithAddSource() Setting
WithAddSource add source info to log
func WithConsole ¶ added in v0.0.87
WithConsole set the log to console or /dev/null
func WithDefault ¶ added in v0.0.87
WithDefault use output as slog.Default()
func WithDevConfig ¶ added in v0.0.87
WithDevConfig set dev config
func WithLumberjack ¶
func WithLumberjack(filename string, config *LumberjackConfig) Setting
WithLumberjack write log to some File with rotation
func WithReplaceAttr ¶ added in v0.0.87
WithReplaceAttr custom replaceAttr
func WithTimeLayout ¶
WithTimeLayout custom time format
type TextHandler ¶ added in v0.0.87
type TextHandler = slog.TextHandler
slog is a wrapper around slog
type TintOptions ¶ added in v0.0.87
TintOptions is a wrapper around tint.Options