Documentation
¶
Index ¶
- Variables
- func Alert(f any, v ...any)
- func Close() error
- func Debug(f any, v ...any)
- func DelOutput(name string)
- func Error(f any, v ...any)
- func Fatal(f any, v ...any)
- func FileNameFormatterDefault() (name, backup string, expire int64)
- func Format(format any, args ...any) (text string)
- func Info(f any, v ...any)
- func Panic(f any, v ...any)
- func SetCallDepth(depth int)
- func SetFilePathFormatter(f filePathFormatter)
- func SetLevel(level Level)
- func SetOutput(name string, output Output) error
- func Sprint(level Level, content string, stack ...string)
- func Trace(f any, v ...any)
- func Warn(f any, v ...any)
- func Write(msg *Message, stack ...string)
- type Conn
- type File
- type Level
- type Logger
- func (log *Logger) Alert(format any, args ...any)
- func (log *Logger) Close() error
- func (log *Logger) Debug(format any, args ...any)
- func (log *Logger) DelOutput(name string)
- func (log *Logger) Error(format any, args ...any)
- func (log *Logger) Fatal(format any, args ...any)
- func (log *Logger) Info(format any, args ...any)
- func (log *Logger) Panic(format any, args ...any)
- func (log *Logger) SetCallDepth(depth int)
- func (log *Logger) SetFilePathFormatter(f filePathFormatter)
- func (log *Logger) SetLevel(level Level)
- func (log *Logger) SetOutput(name string, output Output) error
- func (log *Logger) Sprint(level Level, content string, stack ...string)
- func (log *Logger) Trace(format any, args ...any)
- func (log *Logger) Warn(format any, args ...any)
- func (log *Logger) Write(msg *Message, stack ...string)
- type Message
- type Output
Constants ¶
This section is empty.
Variables ¶
View Source
var Console = &console{colorful: true}
Functions ¶
func FileNameFormatterDefault ¶ added in v0.2.4
FileNameFormatterDefault 默认日志文件,每日一份
func SetCallDepth ¶ added in v0.0.2
func SetCallDepth(depth int)
func SetFilePathFormatter ¶ added in v0.1.2
func SetFilePathFormatter(f filePathFormatter)
SetFilePathFormatter 设置日志起始路径
Types ¶
type Conn ¶ added in v0.0.2
type File ¶ added in v0.0.2
type File struct {
Sprintf func(*Message) *strings.Builder //格式化message
// contains filtered or unexported fields
}
func (*File) SetFileName ¶ added in v0.0.3
func (f *File) SetFileName(fileNameFormatterFunc fileNameFormatter)
SetFileName 设置日志文件名, 前缀(string) 或者 fileNameFormatter 注意:该方法只应在初始化时调用
func (*File) SetFileSize ¶ added in v0.1.0
SetFileSize 设置文件大小(M),默认无限制 注意:该方法只应在初始化时调用
func (*File) SetFlushInterval ¶ added in v0.2.5
SetFlushInterval 设置缓冲区刷新间隔 注意:该方法可以在运行时调用,会在下一次定时器触发时生效
type Level ¶ added in v0.0.2
type Level int8
const ( LevelDebug Level = 0 // 调试信息,最详细的日志 LevelTrace Level = 1 // 追踪信息, 例如: 函数调用, 变量值 LevelInfo Level = 2 // 一般信息,正常运行状态, 例如: 服务启动, 数据库连接成功 LevelWarn Level = 3 // 警告信息,可能的问题, 例如: 配置错误, 资源不足 LevelAlert Level = 4 // 警报信息,需要关注的问题, 例如: 数据库连接失败, 内存泄漏 LevelError Level = 5 // 错误信息,发生错误但不影响程序运行, 例如: 文件读写错误, 网络连接错误 LevelPanic Level = 6 // 严重错误,抛出panic但不终止程序 LevelFatal Level = 7 // 致命错误,记录日志后终止程序运行 )
日志等级,数值越大优先级越高
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func (*Logger) SetCallDepth ¶
func (*Logger) SetFilePathFormatter ¶ added in v0.1.2
func (log *Logger) SetFilePathFormatter(f filePathFormatter)
SetFilePathFormatter 设置日志起始路径
Click to show internal directories.
Click to hide internal directories.