Documentation
¶
Index ¶
- Constants
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func SetLogger(logger *Log)
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- type CallerInfo
- type Config
- type Formatter
- type JSONFormatter
- type Level
- type Log
- func (l *Log) Close() error
- func (l *Log) Debug(args ...interface{})
- func (l *Log) Debugf(format string, args ...interface{})
- func (l *Log) Error(args ...interface{})
- func (l *Log) Errorf(format string, args ...interface{})
- func (l *Log) Fatal(args ...interface{})
- func (l *Log) Fatalf(format string, args ...interface{})
- func (l *Log) GetLevel() Level
- func (l *Log) Info(args ...interface{})
- func (l *Log) Infof(format string, args ...interface{})
- func (l *Log) SetLevel(level Level)
- func (l *Log) SetOutput(path string) error
- func (l *Log) Warn(args ...interface{})
- func (l *Log) Warnf(format string, args ...interface{})
- type Logger
- type Rotator
- type TextFormatter
Constants ¶
View Source
const ( Reset = "\033[0m" Bold = "\033[1m" Red = "\033[31m" Green = "\033[32m" Yellow = "\033[33m" Blue = "\033[34m" Purple = "\033[35m" Cyan = "\033[36m" White = "\033[37m" BoldRed = "\033[1;31m" BoldGreen = "\033[1;32m" BoldYellow = "\033[1;33m" BoldBlue = "\033[1;34m" BoldPurple = "\033[1;35m" BoldCyan = "\033[1;36m" BoldWhite = "\033[1;37m" )
ANSI 颜色代码
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CallerInfo ¶ added in v1.0.8
CallerInfo 调用者信息
type Config ¶ added in v1.0.8
type Config struct {
Level Level `json:"level"` // 日志级别
FilePath string `json:"file_path"` // 日志文件路径
MaxSize int64 `json:"max_size"` // 单个日志文件最大大小(MB)
MaxAge int `json:"max_age"` // 日志保留天数
Compress bool `json:"compress"` // 是否压缩
Formatter Formatter `json:"formatter"` // 日志格式化器
ForceColor bool `json:"force_color"` // 强制启用颜色
NoColor bool `json:"no_color"` // 禁用颜色
Console bool `json:"console"` // 是否输出到控制台
}
Config 日志配置
type Formatter ¶ added in v1.0.8
type Formatter interface {
Format(level Level, msg string, caller *CallerInfo) string
}
Formatter 日志格式化器接口
type JSONFormatter ¶ added in v1.0.8
type JSONFormatter struct {
TimeFormat string
}
JSONFormatter JSON格式化器
func NewJSONFormatter ¶ added in v1.0.8
func NewJSONFormatter() *JSONFormatter
func (*JSONFormatter) Format ¶ added in v1.0.8
func (f *JSONFormatter) Format(level Level, msg string, caller *CallerInfo) string
type Logger ¶ added in v1.0.8
type Logger interface {
// 基础日志方法
Debug(args ...interface{})
Info(args ...interface{})
Warn(args ...interface{})
Error(args ...interface{})
Fatal(args ...interface{})
// 格式化日志方法
Debugf(format string, args ...interface{})
Infof(format string, args ...interface{})
Warnf(format string, args ...interface{})
Errorf(format string, args ...interface{})
Fatalf(format string, args ...interface{})
// 设置日志级别
SetLevel(level Level)
// 获取日志级别
GetLevel() Level
}
Logger 日志接口
type Rotator ¶ added in v1.0.8
type Rotator struct {
// contains filtered or unexported fields
}
Rotator 日志轮转器
func NewRotator ¶ added in v1.0.8
NewRotator 创建日志轮转器
type TextFormatter ¶ added in v1.0.8
type TextFormatter struct {
// 时间格式
TimeFormat string
// 是否显示完整路径
FullPath bool
ForceColor bool // 强制启用颜色
NoColor bool // 禁用颜色
}
TextFormatter 文本格式化器
func NewTextFormatter ¶ added in v1.0.8
func NewTextFormatter() *TextFormatter
func (*TextFormatter) Format ¶ added in v1.0.8
func (f *TextFormatter) Format(level Level, msg string, caller *CallerInfo) string
Click to show internal directories.
Click to hide internal directories.