Documentation ¶
Index ¶
- Constants
- func LevelFromStr(level string) int
- type Brush
- type LogInstance
- type LogManager
- func (l *LogManager) Close()
- func (l *LogManager) Debug(format string, a ...interface{}) (err error)
- func (l *LogManager) Debugx(logID, format string, a ...interface{}) (err error)
- func (l *LogManager) EnableLogger(name string, enable bool) (err error)
- func (l *LogManager) Fatal(format string, a ...interface{}) (err error)
- func (l *LogManager) Fatalx(logID, format string, a ...interface{}) (err error)
- func (l *LogManager) GetLogger(name string) (logger XLogger, err error)
- func (l *LogManager) Init(name string, config map[string]string, source ...string) (err error)
- func (l *LogManager) Notice(format string, a ...interface{}) (err error)
- func (l *LogManager) Noticex(logID, format string, a ...interface{}) (err error)
- func (l *LogManager) ReOpen() (err error)
- func (l *LogManager) RegisterLogger(name string, logger XLogger) (err error)
- func (l *LogManager) SetLevel(name, level string) (err error)
- func (l *LogManager) SetLevelAll(level string)
- func (l *LogManager) Trace(format string, a ...interface{}) (err error)
- func (l *LogManager) Tracex(logID, format string, a ...interface{}) (err error)
- func (l *LogManager) UnregisterLogger(name string) (err error)
- func (l *LogManager) Warn(format string, a ...interface{}) (err error)
- func (l *LogManager) Warnx(logID, format string, a ...interface{}) (err error)
- type XConsoleLog
- func (p *XConsoleLog) Close()
- func (p *XConsoleLog) Debug(format string, a ...interface{}) error
- func (p *XConsoleLog) Debugx(logID, format string, a ...interface{}) error
- func (p *XConsoleLog) Fatal(format string, a ...interface{}) error
- func (p *XConsoleLog) Fatalx(logID, format string, a ...interface{}) error
- func (p *XConsoleLog) GetHost() string
- func (p *XConsoleLog) Init(config map[string]string) (err error)
- func (p *XConsoleLog) Notice(format string, a ...interface{}) error
- func (p *XConsoleLog) Noticex(logID, format string, a ...interface{}) error
- func (p *XConsoleLog) ReOpen() error
- func (p *XConsoleLog) SetLevel(level string)
- func (p *XConsoleLog) SetSkip(skip int)
- func (p *XConsoleLog) Trace(format string, a ...interface{}) error
- func (p *XConsoleLog) Tracex(logID, format string, a ...interface{}) error
- func (p *XConsoleLog) Warn(format string, a ...interface{}) error
- func (p *XConsoleLog) Warnx(logID, format string, a ...interface{}) error
- type XFileLog
- func (p *XFileLog) Close()
- func (p *XFileLog) Debug(format string, a ...interface{}) error
- func (p *XFileLog) Debugx(logID, format string, a ...interface{}) error
- func (p *XFileLog) Fatal(format string, a ...interface{}) error
- func (p *XFileLog) Fatalx(logID, format string, a ...interface{}) error
- func (p *XFileLog) GetHost() string
- func (p *XFileLog) Init(config map[string]string) (err error)
- func (p *XFileLog) Notice(format string, a ...interface{}) error
- func (p *XFileLog) Noticex(logID, format string, a ...interface{}) error
- func (p *XFileLog) ReOpen() error
- func (p *XFileLog) SetLevel(level string)
- func (p *XFileLog) SetSkip(skip int)
- func (p *XFileLog) Trace(format string, a ...interface{}) error
- func (p *XFileLog) Tracex(logID, format string, a ...interface{}) error
- func (p *XFileLog) Warn(format string, a ...interface{}) error
- func (p *XFileLog) Warnx(logID, format string, a ...interface{}) error
- type XLogger
Constants ¶
const ( XFileLogDefaultLogID = "900000001" SpliterDelay = 5 CleanDays = -3 )
constants of XFileLog
const ( DebugLevel = iota TraceLevel NoticeLevel WarnLevel FatalLevel NoneLevel )
log level
const (
XConsoleLogDefaultlogID = "800000001"
)
constants of XConsoleLog
const (
XLogDefSkipNum = 4
)
log skip num
Variables ¶
This section is empty.
Functions ¶
func LevelFromStr ¶
LevelFromStr get log level from level string
Types ¶
type LogInstance ¶
type LogInstance struct {
// contains filtered or unexported fields
}
LogInstance wraps a XLogger
type LogManager ¶
type LogManager struct {
// contains filtered or unexported fields
}
LogManager is the manager that hold different kind of xlog loggers
func CreateLogManager ¶
CreateLogManager create log manager from configs.
func (*LogManager) Debug ¶
func (l *LogManager) Debug(format string, a ...interface{}) (err error)
Debug implements XLogger
func (*LogManager) Debugx ¶
func (l *LogManager) Debugx(logID, format string, a ...interface{}) (err error)
Debugx implements XLogger
func (*LogManager) EnableLogger ¶
func (l *LogManager) EnableLogger(name string, enable bool) (err error)
EnableLogger enable or disable a logger
func (*LogManager) Fatal ¶
func (l *LogManager) Fatal(format string, a ...interface{}) (err error)
Fatal implements XLogger
func (*LogManager) Fatalx ¶
func (l *LogManager) Fatalx(logID, format string, a ...interface{}) (err error)
Fatalx implements XLogger
func (*LogManager) GetLogger ¶
func (l *LogManager) GetLogger(name string) (logger XLogger, err error)
GetLogger get logger by name
func (*LogManager) Init ¶
Init LogManager with config. The name can be set to "console" or "file". Please reference to XConsoleLog and XFileLog.
func (*LogManager) Notice ¶
func (l *LogManager) Notice(format string, a ...interface{}) (err error)
Notice implements XLogger
func (*LogManager) Noticex ¶
func (l *LogManager) Noticex(logID, format string, a ...interface{}) (err error)
Noticex implements XLogger
func (*LogManager) ReOpen ¶
func (l *LogManager) ReOpen() (err error)
ReOpen reopen all enabled loggers
func (*LogManager) RegisterLogger ¶
func (l *LogManager) RegisterLogger(name string, logger XLogger) (err error)
RegisterLogger register a logger
func (*LogManager) SetLevel ¶
func (l *LogManager) SetLevel(name, level string) (err error)
SetLevel implements XLogger
func (*LogManager) SetLevelAll ¶
func (l *LogManager) SetLevelAll(level string)
SetLevelAll set level to all loggers
func (*LogManager) Trace ¶
func (l *LogManager) Trace(format string, a ...interface{}) (err error)
Trace implements XLogger
func (*LogManager) Tracex ¶
func (l *LogManager) Tracex(logID, format string, a ...interface{}) (err error)
Tracex implements XLogger
func (*LogManager) UnregisterLogger ¶
func (l *LogManager) UnregisterLogger(name string) (err error)
UnregisterLogger unregister a logger
func (*LogManager) Warn ¶
func (l *LogManager) Warn(format string, a ...interface{}) (err error)
Warn implements XLogger
func (*LogManager) Warnx ¶
func (l *LogManager) Warnx(logID, format string, a ...interface{}) (err error)
Warnx implements XLogger
type XConsoleLog ¶
type XConsoleLog struct {
// contains filtered or unexported fields
}
XConsoleLog is the console logger
func (*XConsoleLog) Close ¶
func (p *XConsoleLog) Close()
Close implements XLogger 关闭日志库。注意:如果没有调用Close()关闭日志库的话,将会造成文件句柄泄露
func (*XConsoleLog) Debug ¶
func (p *XConsoleLog) Debug(format string, a ...interface{}) error
Debug implements XLogger
func (*XConsoleLog) Debugx ¶
func (p *XConsoleLog) Debugx(logID, format string, a ...interface{}) error
Debugx implements XLogger
func (*XConsoleLog) Fatal ¶
func (p *XConsoleLog) Fatal(format string, a ...interface{}) error
Fatal implements XLogger
func (*XConsoleLog) Fatalx ¶
func (p *XConsoleLog) Fatalx(logID, format string, a ...interface{}) error
Fatalx implements XLogger
func (*XConsoleLog) Init ¶
func (p *XConsoleLog) Init(config map[string]string) (err error)
Init init XConsoleLog
func (*XConsoleLog) Notice ¶
func (p *XConsoleLog) Notice(format string, a ...interface{}) error
Notice implements XLogger
func (*XConsoleLog) Noticex ¶
func (p *XConsoleLog) Noticex(logID, format string, a ...interface{}) error
Noticex implements XLogger
func (*XConsoleLog) SetLevel ¶
func (p *XConsoleLog) SetLevel(level string)
SetLevel implements XLogger
func (*XConsoleLog) Trace ¶
func (p *XConsoleLog) Trace(format string, a ...interface{}) error
Trace implements XLogger
func (*XConsoleLog) Tracex ¶
func (p *XConsoleLog) Tracex(logID, format string, a ...interface{}) error
Tracex implements XLogger
func (*XConsoleLog) Warn ¶
func (p *XConsoleLog) Warn(format string, a ...interface{}) error
Warn implements XLogger
func (*XConsoleLog) Warnx ¶
func (p *XConsoleLog) Warnx(logID, format string, a ...interface{}) error
Warnx implements XLogger
type XFileLog ¶
type XFileLog struct {
// contains filtered or unexported fields
}
XFileLog is the file logger
type XLogger ¶
type XLogger interface { // init logger Init(config map[string]string) error // reopen logger ReOpen() error //设置日志级别, 级别如下: "Debug", "Trace", "Notice", "Warn", "Fatal", "None" SetLevel(level string) // set skip SetSkip(skip int) // 打印Debug日志. 当日志级别大于Debug时, 不会输出任何日志 Debug(format string, a ...interface{}) error // 打印Trace日志. 当日志级别大于Trace时, 不会输出任何日志 Trace(format string, a ...interface{}) error // 打印Notice日志. 当日志级别大于Notice时, 不会输出任何日志 Notice(format string, a ...interface{}) error // 打印Warn日志. 当日志级别大于Warn时, 不会输出任何日志 Warn(format string, a ...interface{}) error // 打印Fatal日志. 当日志级别大于Fatal时, 不会输出任何日志 Fatal(format string, a ...interface{}) error // 打印Debug日志, 需要传入logID. 当日志级别大于Debug时, 不会输出任何日志 Debugx(logID, format string, a ...interface{}) error // 打印Trace日志, 需要传入logID. 当日志级别大于Trace时, 不会输出任何日志 Tracex(logID, format string, a ...interface{}) error // 打印Notice日志, 需要传入logID. 当日志级别大于Notice时, 不会输出任何日志 Noticex(logID, format string, a ...interface{}) error // 打印Warn日志, 需要传入logID. 当日志级别大于Warn时, 不会输出任何日志 Warnx(logID, format string, a ...interface{}) error // 打印Fatal日志, 需要传入logID. 当日志级别大于Fatal时, 不会输出任何日志 Fatalx(logID, format string, a ...interface{}) error // 关闭日志库. 注意: 如果没有调用Close()关闭日志库的话, 将会造成文件句柄泄露 Close() }
XLogger declares method that log instance should implement.
func NewXConsoleLog ¶
func NewXConsoleLog() XLogger
NewXConsoleLog is the constructor of XConsoleLog
func NewXFileLog ¶
func NewXFileLog() XLogger
NewXFileLog is the constructor of XFileLog 生成一个日志实例,service用来标识业务的服务名。 比如:logger := xlog.NewXFileLog("gaea")