log

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, attrs ...any)

func Debugf

func Debugf(format string, args ...any)

func Error

func Error(msg string, attrs ...any)

func Errorf

func Errorf(format string, args ...any)

func Info

func Info(msg string, attrs ...any)

func Infof

func Infof(format string, args ...any)

func Init

func Init(config *Config, attrs map[string]any)

func NewSlogLogger

func NewSlogLogger(config *Config, options ...Option) *slog.Logger

func Sync

func Sync() error

func Warn

func Warn(msg string, attrs ...any)

func Warnf

func Warnf(format string, args ...any)

Types

type AddCallerStatus

type AddCallerStatus int
const (
	AddCallerStatusKeep AddCallerStatus = iota
	AddCallerStatusEnable
	AddCallerStatusDisable
)

type BaseLogger

type BaseLogger interface {
	Debug(msg string, args ...any)
	Info(msg string, args ...any)
	Warn(msg string, args ...any)
	Error(msg string, args ...any)
}

type Config

type Config struct {
	File    *FileConfig    `json:"file" yaml:"file"`
	Console *ConsoleConfig `json:"console" yaml:"console"`
	Level   string         `json:"level" yaml:"level"`
}

func NewDefaultConfig

func NewDefaultConfig() *Config

type ConsoleConfig

type ConsoleConfig struct {
	Disable bool `json:"disable" yaml:"disable"`
}

type Field

type Field = zap.Field

func Any

func Any(key string, value interface{}) Field

func Bool

func Bool(key string, value bool) Field

func Duration

func Duration(key string, value time.Duration) Field

func Err

func Err(err error) Field

func Float64

func Float64(key string, value float64) Field

func Group

func Group(key string, values ...any) Field

func Int

func Int(key string, value int) Field

func Int64

func Int64(key string, value int64) Field

func String

func String(key, value string) Field

func Time

func Time(key string, value time.Time) Field

func Uint64

func Uint64(key string, value uint64) Field

type FileConfig

type FileConfig struct {
	FileName   string `json:"file_name" yaml:"file_name"`
	MaxSize    int    `json:"max_size" yaml:"max_size"`
	MaxBackups int    `json:"max_backups" yaml:"max_backups"`
	MaxAge     int    `json:"max_age" yaml:"max_age"`
}

type Logger

type Logger interface {
	BaseLogger
	Debugf(format string, args ...any)
	Infof(format string, args ...any)
	Warnf(format string, args ...any)
	Errorf(format string, args ...any)
}

func With

func With(options ...Option) Logger

type Option

type Option = func(*options)

func AddCaller

func AddCaller() Option

func AddCallerSkip

func AddCallerSkip(skip int) Option

func DisableCaller

func DisableCaller() Option

func WithAttrs

func WithAttrs(attrs map[string]any) Option

func WithName

func WithName(name string) Option

func WithStackAt

func WithStackAt(level zapcore.Level) Option

Jump to

Keyboard shortcuts

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