logger

package
v1.4.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const IsoZonedDateTime = "2006-01-02 15:04:05"

Variables

This section is empty.

Functions

func Debug

func Debug(sender, format string, v ...any)

Debug logs at debug level for the specified sender

func Debugf

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

func Error

func Error(sender, format string, v ...any)

Error logs at error level for the specified sender

func Errorf

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

func Info

func Info(sender, format string, v ...any)

Info logs at info level for the specified sender

func Infof

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

func Log

func Log(level LogLevel, sender string, format string, v ...any)

Log logs at the specified level for the specified sender

func SetZerolog

func SetZerolog(opts ...OptFunc)

SetZerolog

func Warn

func Warn(sender, format string, v ...any)

Warn logs at warn level for the specified sender

func Warnf

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

Types

type LogConfig

type LogConfig struct {
	LogLevel       string `json:"log_level" yaml:"log_level"`               // 日志级别
	LogDir         string `json:"log_dir" yaml:"log_dir"`                   // 日志文件路径
	LogWithDate    bool   `json:"log_with_date" yaml:"log_with_date"`       // 按日期存放日志
	LogWithLevel   bool   `json:"log_with_level" yaml:"log_with_level"`     // 按级别存放日志
	LogWithColor   bool   `json:"log_with_color" yaml:"log_with_color"`     // 是否输出彩色日志
	LogWithConsole bool   `json:"log_with_console" yaml:"log_with_console"` // 是否输出到控制台
	LogSaveDay     int    `json:"log_save_day" yaml:"log_save_day"`         // 保存时间,单位天
}

type LogLevel

type LogLevel uint8

LogLevel defines log levels.

const (
	LevelDebug LogLevel = iota
	LevelInfo
	LevelWarn
	LevelError
)

defines our own log levels, just in case we'll change logger in future

type MultiWriter

type MultiWriter struct {
	// contains filtered or unexported fields
}

func NewMultiWriter

func NewMultiWriter(opts ...OptFunc) *MultiWriter

func (*MultiWriter) Write

func (m *MultiWriter) Write(p []byte) (n int, err error)

func (*MultiWriter) WriteLevel

func (m *MultiWriter) WriteLevel(level zerolog.Level, p []byte) (n int, err error)

type OptFunc

type OptFunc func(*MultiWriter) *MultiWriter

func WithFileName

func WithFileName(name string) OptFunc

func WithLogConfig

func WithLogConfig(cfg *LogConfig) OptFunc

Jump to

Keyboard shortcuts

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