Documentation ¶
Overview ¶
This source you can use! This source you can use!
Package log
This source you can use! This source you can use! This source you can use!
Index ¶
- Constants
- Variables
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Init(jsconf string) (err error)
- func InitConf(cfg *Config) (err error)
- func IsAll() bool
- func IsDebug() bool
- func IsError() bool
- func IsInfo() bool
- func IsNotice() bool
- func IsWarn() bool
- func Log(args ...interface{})
- func Logf(format string, args ...interface{})
- func New(filename string)
- func Notice(args ...interface{})
- func Noticef(format string, args ...interface{})
- func SetRootAppender(appenders ...Appender)
- func SetRootFileAppender(fileName string)
- func SetRootLevel(l int)
- func SetRootOnlyLevel(ls ...int)
- func SetRootSeparationAppender(fileName string)
- func UseRoot(name string) error
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- type Appender
- type Config
- type ConfigLogger
- type ConsoleAppender
- func (l ConsoleAppender) Log(extendCallpath int, level string, args ...interface{})
- func (l ConsoleAppender) Logf(extendCallpath int, level string, format string, args ...interface{})
- func (l ConsoleAppender) Logln(extendCallpath int, level string, args ...interface{})
- func (l ConsoleAppender) SetCallpath(level int)
- type DailyAppender
- type FileAppender
- func (l *FileAppender) Log(extendCallpath int, level string, args ...interface{})
- func (l *FileAppender) Logf(extendCallpath int, level string, format string, args ...interface{})
- func (l *FileAppender) Logln(extendCallpath int, level string, args ...interface{})
- func (l FileAppender) SetCallpath(level int)
- type LevelSeparationAppender
- func (this *LevelSeparationAppender) Log(extendCallpath int, level string, args ...interface{})
- func (this *LevelSeparationAppender) Logf(extendCallpath int, level string, format string, args ...interface{})
- func (this *LevelSeparationAppender) Logln(extendCallpath int, level string, args ...interface{})
- func (this *LevelSeparationAppender) SetCallpath(level int)
- func (this *LevelSeparationAppender) SetLevelAppender(level string, appender Appender)
- type Logger
- func (l *Logger) Debug(args ...interface{})
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Error(args ...interface{})
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) IsAll() bool
- func (l *Logger) IsDebug() bool
- func (l *Logger) IsError() bool
- func (l *Logger) IsInfo() bool
- func (l *Logger) IsLogLevel(level int) bool
- func (l *Logger) IsNotice() bool
- func (l *Logger) IsWarn() bool
- func (l *Logger) Log(args ...interface{})
- func (l *Logger) Logf(format string, args ...interface{})
- func (l *Logger) Notice(args ...interface{})
- func (l *Logger) Noticef(format string, args ...interface{})
- func (l *Logger) Panic(args ...interface{})
- func (l *Logger) Panicf(format string, args ...interface{})
- func (l *Logger) SetCallpath(callpath int)
- func (l *Logger) Warn(args ...interface{})
- func (l *Logger) Warnf(format string, args ...interface{})
- type LoggerConf
- type LoggerManager
- func (self *LoggerManager) Logger(name string) (logger *Logger)
- func (self *LoggerManager) SetLogger(logger *Logger)
- func (self *LoggerManager) SetRootAppender(appenders ...Appender)
- func (self *LoggerManager) SetRootLevel(l int)
- func (self *LoggerManager) SetRootOnlyLevel(ls ...int)
- func (self *LoggerManager) UpdateConf(cfg *Config) error
- func (self *LoggerManager) UseRoot(name string) (err error)
- type Tree
Constants ¶
View Source
const ( NOSET = 0 NO = 110 PANIC = 120 ERROR = 130 WARN = 140 NOTICE = 150 LOG = 160 DEBUG = 170 ALL = 180 )
Variables ¶
View Source
var ( DefaultLowCallpath = 0 DefaultAppenderCallpath = 2 DefaultLoggerCallpath = 3 )
View Source
var LogLevelMap map[string]int = map[string]int{ "NO": NO, "DEBUG": DEBUG, "WARN": WARN, "NOTICE": NOTICE, "LOG": LOG, "ERROR": ERROR, "PANIC": PANIC, "ALL": ALL, }
View Source
var UseShortFile bool
Functions ¶
func SetRootAppender ¶
func SetRootAppender(appenders ...Appender)
func SetRootFileAppender ¶
func SetRootFileAppender(fileName string)
func SetRootLevel ¶
func SetRootLevel(l int)
func SetRootOnlyLevel ¶
func SetRootOnlyLevel(ls ...int)
func SetRootSeparationAppender ¶
func SetRootSeparationAppender(fileName string)
Types ¶
type Appender ¶
type Appender interface { Log(extendCallpath int, level string, args ...interface{}) Logln(extendCallpath int, level string, args ...interface{}) Logf(extendCallpath int, level string, format string, args ...interface{}) SetCallpath(int) }
日志的输出接口
type Config ¶
type Config struct { UseShortFile bool Appenders map[string]struct { Type string Target string } Loggers map[string]ConfigLogger Root ConfigLogger Roots map[string]ConfigLogger // contains filtered or unexported fields }
日志的配置,可以通过配置json来配置日志
func (*Config) BuildAppenders ¶
实例化配置中的appender
func (*Config) BuildLoggers ¶
func (self *Config) BuildLoggers() []*LoggerConf
func (Config) RootLogger ¶
func (self Config) RootLogger() *LoggerConf
func (Config) RootsLogger ¶
func (self Config) RootsLogger() map[string]*LoggerConf
type ConfigLogger ¶
type ConfigLogger struct { Appenders []string Level interface{} }
type ConsoleAppender ¶
type ConsoleAppender struct {
// contains filtered or unexported fields
}
func NewConsoleAppender ¶
func NewConsoleAppender(name string) *ConsoleAppender
func (ConsoleAppender) SetCallpath ¶
func (l ConsoleAppender) SetCallpath(level int)
type DailyAppender ¶
type DailyAppender struct { *FileAppender // contains filtered or unexported fields }
func NewDailyAppender ¶
func NewDailyAppender(name, fileName string) *DailyAppender
func NewDailyAppenderEx ¶
func NewDailyAppenderEx(name, fileName, extension string) *DailyAppender
func (DailyAppender) SetCallpath ¶
func (l DailyAppender) SetCallpath(level int)
type FileAppender ¶
type FileAppender struct {
// contains filtered or unexported fields
}
func NewFileAppender ¶
func NewFileAppender(name string, fileName string) *FileAppender
func (*FileAppender) Log ¶
func (l *FileAppender) Log(extendCallpath int, level string, args ...interface{})
func (*FileAppender) Logf ¶
func (l *FileAppender) Logf(extendCallpath int, level string, format string, args ...interface{})
func (*FileAppender) Logln ¶
func (l *FileAppender) Logln(extendCallpath int, level string, args ...interface{})
func (FileAppender) SetCallpath ¶
func (l FileAppender) SetCallpath(level int)
type LevelSeparationAppender ¶
type LevelSeparationAppender struct { Name string // contains filtered or unexported fields }
把不同等级的信息打印到不同的Appender中
func NewLevelSeparationAppender ¶
func NewLevelSeparationAppender(name string) *LevelSeparationAppender
func NewLevelSeparationDailyAppender ¶
func NewLevelSeparationDailyAppender(name string, fileName string) *LevelSeparationAppender
func (*LevelSeparationAppender) Log ¶
func (this *LevelSeparationAppender) Log(extendCallpath int, level string, args ...interface{})
func (*LevelSeparationAppender) Logf ¶
func (this *LevelSeparationAppender) Logf(extendCallpath int, level string, format string, args ...interface{})
func (*LevelSeparationAppender) Logln ¶
func (this *LevelSeparationAppender) Logln(extendCallpath int, level string, args ...interface{})
func (*LevelSeparationAppender) SetCallpath ¶
func (this *LevelSeparationAppender) SetCallpath(level int)
func (*LevelSeparationAppender) SetLevelAppender ¶
func (this *LevelSeparationAppender) SetLevelAppender(level string, appender Appender)
type Logger ¶
type Logger struct { *LoggerConf Callpath int // 不放在LoggerConf中,因为同一个名称的Logger实例,Conf相同,可能被封装的层次不同,用Callpath的不同 }
日志类
func (*Logger) IsLogLevel ¶
func (*Logger) SetCallpath ¶
type LoggerConf ¶
logger的配置类
func (*LoggerConf) SetAppender ¶
func (self *LoggerConf) SetAppender(appenders ...Appender)
func (*LoggerConf) SetLevel ¶
func (self *LoggerConf) SetLevel(level int)
func (*LoggerConf) SetOnlyLevels ¶
func (self *LoggerConf) SetOnlyLevels(levels ...int)
type LoggerManager ¶
type LoggerManager struct { *Tree // contains filtered or unexported fields }
日志的管理类,用于加载配置,返回正确的logger
func CurLoggerMananger ¶
func CurLoggerMananger() (cfg *LoggerManager)
func NewLoggerManager ¶
func NewLoggerManager(root *LoggerConf) *LoggerManager
func NewLoggerManagerWithConf ¶
func NewLoggerManagerWithConf(cfg *Config) (*LoggerManager, error)
func NewLoggerManagerWithJsconf ¶
func NewLoggerManagerWithJsconf(jsConf string) (*LoggerManager, error)
func (*LoggerManager) Logger ¶
func (self *LoggerManager) Logger(name string) (logger *Logger)
func (*LoggerManager) SetLogger ¶
func (self *LoggerManager) SetLogger(logger *Logger)
func (*LoggerManager) SetRootAppender ¶
func (self *LoggerManager) SetRootAppender(appenders ...Appender)
func (*LoggerManager) SetRootLevel ¶
func (self *LoggerManager) SetRootLevel(l int)
func (*LoggerManager) SetRootOnlyLevel ¶
func (self *LoggerManager) SetRootOnlyLevel(ls ...int)
func (*LoggerManager) UpdateConf ¶
func (self *LoggerManager) UpdateConf(cfg *Config) error
func (*LoggerManager) UseRoot ¶
func (self *LoggerManager) UseRoot(name string) (err error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.