loge

package
v0.0.86 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

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 Attr

type Attr = slog.Attr

type Color added in v0.0.81

type Color = devslog.Color

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 DevslogOptions = devslog.Options

type Format

type Format int
const (
	// FormatJSON json format
	FormatJSON Format = iota
	// FormatText text format
	FormatText
	// FormatTint tint format
	FormatTint
	// FormatDev dev format
	FormatDev
)

func (Format) String

func (i Format) String() string

type Handler

type Handler = slog.Handler

type HandlerOptions

type HandlerOptions = slog.HandlerOptions

type JSONHandler added in v0.0.81

type JSONHandler = slog.JSONHandler

type Kind added in v0.0.81

type Kind = slog.Kind

type Level

type Level = slog.Level

type LevelVar added in v0.0.81

type LevelVar = slog.LevelVar

type Leveler

type Leveler = slog.Leveler

type LogValuer added in v0.0.81

type LogValuer = slog.LogValuer

type Logger added in v0.0.81

type Logger = slog.Logger

func New

func New(ss ...Setting) *Logger

New create a new slog.Logger

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 Record added in v0.0.81

type Record = slog.Record

type Setting

type Setting = func(*Option)

func WithAddSource

func WithAddSource() Setting

WithAddSource add source info to log

func WithDevConfig added in v0.0.43

func WithDevConfig(config *DevConfig) Setting

WithDevConfig set dev config

func WithDisableConsole

func WithDisableConsole() Setting

WithDisableConsole WithEnableConsole write log to os.Stdout or os.Stderr

func WithFile

func WithFile(file string) Setting

WithFile write log to some File

func WithFormat

func WithFormat(format Format) Setting

WithFormat custom format

func WithLevel

func WithLevel(level Leveler) Setting

WithLevel custom log level

func WithLumberjack

func WithLumberjack(filename string, config *LumberjackConfig) Setting

WithLumberjack write log to some File with rotation

func WithNoColor

func WithNoColor() Setting

WithNoColor disable color

func WithPath

func WithPath(path string) Setting

WithPath custom path to write log

func WithReplaceAttr

func WithReplaceAttr(replaceAttr func(groups []string, attr Attr) Attr) Setting

WithReplaceAttr custom replaceAttr

func WithTimeLayout

func WithTimeLayout(timeLayout string) Setting

WithTimeLayout custom time format

func WithUseDefault

func WithUseDefault() Setting

WithUseDefault use output as slog.Default()

type Source added in v0.0.81

type Source = slog.Source

type TextHandler added in v0.0.81

type TextHandler = slog.TextHandler

type TintOptions

type TintOptions = tint.Options

type Value added in v0.0.81

type Value = slog.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL