Documentation ¶
Index ¶
- Constants
- func InitMLog(cfgFile, logDir string)
- type LogConf
- type LogDriver
- type Logger
- type LoggerImpl
- func (t *LoggerImpl) Debug(msg string, ctx ...interface{})
- func (t *LoggerImpl) Error(msg string, ctx ...interface{})
- func (t *LoggerImpl) Fatal(msg string, ctx ...interface{})
- func (t *LoggerImpl) GetLogId() string
- func (t *LoggerImpl) Info(msg string, ctx ...interface{})
- func (t *LoggerImpl) SetCommField(key string, value interface{})
- func (t *LoggerImpl) SetInfoField(key string, value interface{})
- func (t *LoggerImpl) Warn(msg string, ctx ...interface{})
- type Lvl
Constants ¶
View Source
const ( CommFieldLogId = "logid" CommFieldSubMod = "submod" CommFieldPid = "pid" CommFieldCall = "call" DefaultCallDepth = 4 )
Reserve base key
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LogConf ¶
type LogConf struct { Module string `yaml:"module,omitempty"` Filename string `yaml:"filename,omitempty"` // 日志格式:logfmt、json Fmt string `yaml:"fmt,omitempty"` // 日志输出级别:debug、trace、info、warn、error Level string `yaml:"level,omitempty"` // 日志分割周期(单位:分钟) RotateInterval int `yaml:"rotateInterval,omitempty"` // 日志保留天数(单位:小时) RotateBackups int `yaml:"rotateBackups,omitempty"` // 是否输出到标准输出 Console bool `yaml:"console,omitempty"` // 设置日志模式是否是异步 Async bool `yaml:"async,omitempty"` // 设置异步模式下缓冲区大小 BufSize int `yaml:"bufSize,omitempty"` }
LogConfig is the log envconfig of node
func GetDefLogConf ¶
func GetDefLogConf() *LogConf
func LoadLogConf ¶
type LogDriver ¶
type LogDriver interface { Fatal(msg string, ctx ...interface{}) Error(msg string, ctx ...interface{}) Warn(msg string, ctx ...interface{}) Info(msg string, ctx ...interface{}) Debug(msg string, ctx ...interface{}) }
LogDriver 底层日志库约束接口
type Logger ¶
type Logger interface { GetLogId() string SetCommField(key string, value interface{}) SetInfoField(key string, value interface{}) Fatal(msg string, ctx ...interface{}) Error(msg string, ctx ...interface{}) Warn(msg string, ctx ...interface{}) Info(msg string, ctx ...interface{}) Debug(msg string, ctx ...interface{}) }
type LoggerImpl ¶
type LoggerImpl struct {
// contains filtered or unexported fields
}
func NewLogger ¶
func NewLogger(logId, subMod string) (*LoggerImpl, error)
NewLogger 使用NewLogger请先调用InitMLog全局初始化
func (*LoggerImpl) Debug ¶
func (t *LoggerImpl) Debug(msg string, ctx ...interface{})
func (*LoggerImpl) Error ¶
func (t *LoggerImpl) Error(msg string, ctx ...interface{})
func (*LoggerImpl) Fatal ¶
func (t *LoggerImpl) Fatal(msg string, ctx ...interface{})
func (*LoggerImpl) GetLogId ¶
func (t *LoggerImpl) GetLogId() string
func (*LoggerImpl) Info ¶
func (t *LoggerImpl) Info(msg string, ctx ...interface{})
func (*LoggerImpl) SetCommField ¶
func (t *LoggerImpl) SetCommField(key string, value interface{})
func (*LoggerImpl) SetInfoField ¶
func (t *LoggerImpl) SetInfoField(key string, value interface{})
func (*LoggerImpl) Warn ¶
func (t *LoggerImpl) Warn(msg string, ctx ...interface{})
type Lvl ¶
type Lvl int
Lvl is a type for predefined log levels.
func LvlFromString ¶
LvlFromString returns the appropriate Lvl from a string name. Useful for parsing command line args and configuration files.
Click to show internal directories.
Click to hide internal directories.