Documentation ¶
Overview ¶
Package zlog provides logging interfaces for zinx. This includes:
- stdzlog module, which provides global logging methods - zlogger module, which defines logging protocols as object methods
Current file description: @Title zlogger.go @Description Basic logging interface, including Debug, Fatal, etc. @Author Aceld - Thu Mar 11 10:32:29 CST 2019
@Title stdzlog.go @Description Wraps zlogger log methods to provide global methods @Author Aceld - Thu Mar 11 10:32:29 CST 2019
Index ¶
- Constants
- Variables
- func AddFlag(flag int)
- func CleanZinxLog(log *ZinxLoggerCore)
- func Debug(v ...interface{})
- func Debugf(format string, v ...interface{})
- func Error(v ...interface{})
- func Errorf(format string, v ...interface{})
- func Fatal(v ...interface{})
- func Fatalf(format string, v ...interface{})
- func Flags() int
- func Info(v ...interface{})
- func Infof(format string, v ...interface{})
- func Ins() ziface.ILogger
- func Panic(v ...interface{})
- func Panicf(format string, v ...interface{})
- func ResetFlags(flag int)
- func SetCons(b bool)
- func SetLogFile(fileDir string, fileName string)
- func SetLogLevel(logLevel int)
- func SetLogger(newlog ziface.ILogger)
- func SetMaxAge(ma int)
- func SetMaxSize(ms int64)
- func SetPrefix(prefix string)
- func Stack(v ...interface{})
- func Warn(v ...interface{})
- func Warnf(format string, v ...interface{})
- type ZinxLoggerCore
- func (log *ZinxLoggerCore) AddFlag(flag int)
- func (log *ZinxLoggerCore) Debug(v ...interface{})
- func (log *ZinxLoggerCore) Debugf(format string, v ...interface{})
- func (log *ZinxLoggerCore) Error(v ...interface{})
- func (log *ZinxLoggerCore) Errorf(format string, v ...interface{})
- func (log *ZinxLoggerCore) Fatal(v ...interface{})
- func (log *ZinxLoggerCore) Fatalf(format string, v ...interface{})
- func (log *ZinxLoggerCore) Flags() int
- func (log *ZinxLoggerCore) Info(v ...interface{})
- func (log *ZinxLoggerCore) Infof(format string, v ...interface{})
- func (log *ZinxLoggerCore) OutPut(level int, s string) error
- func (log *ZinxLoggerCore) Panic(v ...interface{})
- func (log *ZinxLoggerCore) Panicf(format string, v ...interface{})
- func (log *ZinxLoggerCore) ResetFlags(flag int)
- func (log *ZinxLoggerCore) SetCons(b bool)
- func (log *ZinxLoggerCore) SetLogFile(fileDir string, fileName string)
- func (log *ZinxLoggerCore) SetLogHook(f func([]byte))
- func (log *ZinxLoggerCore) SetLogLevel(logLevel int)
- func (log *ZinxLoggerCore) SetMaxAge(ma int)
- func (log *ZinxLoggerCore) SetMaxSize(ms int64)
- func (log *ZinxLoggerCore) SetPrefix(prefix string)
- func (log *ZinxLoggerCore) Stack(v ...interface{})
- func (log *ZinxLoggerCore) Warn(v ...interface{})
- func (log *ZinxLoggerCore) Warnf(format string, v ...interface{})
Constants ¶
const ( BitDate = 1 << iota // Date flag bit 2019/01/23 (日期标记位) BitTime // Time flag bit 01:23:12 (时间标记位) BitMicroSeconds // Microsecond flag bit 01:23:12.111222 (微秒级标记位) BitLongFile // Complete file name /home/go/src/zinx/server.go (完整文件名称) BitShortFile // Last file name server.go (最后文件名) BitLevel // Current log level: 0(Debug), 1(Info), 2(Warn), 3(Error), 4(Panic), 5(Fatal) (当前日志级别) BitStdFlag = BitDate | BitTime // Standard log header format (标准头部日志格式) BitDefault = BitLevel | BitShortFile | BitStdFlag // Default log header format (默认日志头部格式) )
Log header information flag, using bitmap mode, users can choose which flag bits to print in the header (日志头部信息标记位,采用bitmap方式,用户可以选择头部需要哪些标记位被打印)
const ( LogDebug = iota LogInfo LogWarn LogError LogPanic LogFatal )
Log Level
const (
LOG_MAX_BUF = 1024 * 1024
)
Variables ¶
var StdZinxLog = NewZinxLog("", BitDefault)
StdZinxLog creates a global log
Functions ¶
func SetLogFile ¶
SetLogFile sets the log file of StdZinxLog
Types ¶
type ZinxLoggerCore ¶
type ZinxLoggerCore struct {
// contains filtered or unexported fields
}
func NewZinxLog ¶
func NewZinxLog(prefix string, flag int) *ZinxLoggerCore
NewZinxLog Create a new log
out: The file io for standard output prefix: The prefix of the log flag: The flag of the log header information
func (*ZinxLoggerCore) AddFlag ¶
func (log *ZinxLoggerCore) AddFlag(flag int)
AddFlag adds a flag to the bitmap flags (添加flag标记)
func (*ZinxLoggerCore) Debug ¶
func (log *ZinxLoggerCore) Debug(v ...interface{})
func (*ZinxLoggerCore) Debugf ¶
func (log *ZinxLoggerCore) Debugf(format string, v ...interface{})
func (*ZinxLoggerCore) Error ¶
func (log *ZinxLoggerCore) Error(v ...interface{})
func (*ZinxLoggerCore) Errorf ¶
func (log *ZinxLoggerCore) Errorf(format string, v ...interface{})
func (*ZinxLoggerCore) Fatal ¶
func (log *ZinxLoggerCore) Fatal(v ...interface{})
func (*ZinxLoggerCore) Fatalf ¶
func (log *ZinxLoggerCore) Fatalf(format string, v ...interface{})
func (*ZinxLoggerCore) Flags ¶
func (log *ZinxLoggerCore) Flags() int
Flags gets the current log bitmap flags (获取当前日志bitmap标记)
func (*ZinxLoggerCore) Info ¶
func (log *ZinxLoggerCore) Info(v ...interface{})
func (*ZinxLoggerCore) Infof ¶
func (log *ZinxLoggerCore) Infof(format string, v ...interface{})
func (*ZinxLoggerCore) OutPut ¶
func (log *ZinxLoggerCore) OutPut(level int, s string) error
OutPut outputs log file, the original method
func (*ZinxLoggerCore) Panic ¶
func (log *ZinxLoggerCore) Panic(v ...interface{})
func (*ZinxLoggerCore) Panicf ¶
func (log *ZinxLoggerCore) Panicf(format string, v ...interface{})
func (*ZinxLoggerCore) ResetFlags ¶
func (log *ZinxLoggerCore) ResetFlags(flag int)
ResetFlags resets the log Flags bitmap flags (重新设置日志Flags bitMap 标记位)
func (*ZinxLoggerCore) SetLogFile ¶
func (log *ZinxLoggerCore) SetLogFile(fileDir string, fileName string)
SetLogFile sets the log file output (设置日志文件输出)
func (*ZinxLoggerCore) SetLogHook ¶
func (log *ZinxLoggerCore) SetLogHook(f func([]byte))
func (*ZinxLoggerCore) SetLogLevel ¶
func (log *ZinxLoggerCore) SetLogLevel(logLevel int)
func (*ZinxLoggerCore) SetMaxSize ¶
func (log *ZinxLoggerCore) SetMaxSize(ms int64)
SetMaxSize 单个日志最大容量 单位:字节
func (*ZinxLoggerCore) SetPrefix ¶
func (log *ZinxLoggerCore) SetPrefix(prefix string)
SetPrefix sets a custom prefix for the log (设置日志的 用户自定义前缀字符串)
func (*ZinxLoggerCore) Stack ¶
func (log *ZinxLoggerCore) Stack(v ...interface{})
func (*ZinxLoggerCore) Warn ¶
func (log *ZinxLoggerCore) Warn(v ...interface{})
func (*ZinxLoggerCore) Warnf ¶
func (log *ZinxLoggerCore) Warnf(format string, v ...interface{})