Documentation ¶
Index ¶
Constants ¶
const ( Trace = "trace" Debug = "debug" Info = "info" Error = "error" Fatal = "fatal" Panic = "panic" )
日志级别
const (
TimeFormat = "2006-01-02 15:04:05.999999"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { LogDir string `json:"logDir" yaml:"logDir" default:"temp/log"` // 日志保存文件夹 LogName string `json:"logName" yaml:"logName" default:"app"` // 日志文件名 LogLevel string `json:"logLevel" yaml:"logLevel" default:"debug"` // 日志级别 LogSize int `json:"logSize" yaml:"logSize" default:"100"` // 日志大小(单位:mb) LogAge int `json:"logAge" yaml:"logAge" default:"1"` // 日志保留天数(单位:天) LogBackups int `json:"logBackups" yaml:"logBackups" default:"10"` // 日志备份数 }
日志配置
var CONFIG *Config
type LfsHook ¶
type LfsHook struct {
// contains filtered or unexported fields
}
LfsHook is a hook to handle writing to local log files.
func NewHook ¶
returns new LFS hook. Output can be a string, io.Writer, WriterMap or PathMap. If using io.Writer or WriterMap, user is responsible for closing the used io.Writer.
func (*LfsHook) Fire ¶
writes the log file to defined path or using the defined writer. User who run this function needs to write permissions to the file or directory if the file does not yet exist.
func (*LfsHook) SetDefaultPath ¶
sets default path for levels that don't have any defined output path.
func (*LfsHook) SetDefaultWriter ¶
sets default writer for levels that don't have any defined writer.
func (*LfsHook) SetFormatter ¶
sets the format that will be used by hook. If using text formatter, this method will disable color output to make the log file more readable.
type LogFormatter ¶
type LogFormatter struct {
TimeFormat string
}