Documentation ¶
Index ¶
- Constants
- Variables
- func AddFlag(flag int)
- func CleanYLog(log *YLoggerCore)
- 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 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 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{})
- func Zip(dst io.Writer, src string) error
- func ZipToFile(dst, src string) error
- type ILogger
- type Writer
- type YLoggerCore
- func (log *YLoggerCore) AddFlag(flag int)
- func (log *YLoggerCore) Debug(v ...interface{})
- func (log *YLoggerCore) Debugf(format string, v ...interface{})
- func (log *YLoggerCore) Error(v ...interface{})
- func (log *YLoggerCore) Errorf(format string, v ...interface{})
- func (log *YLoggerCore) Fatal(v ...interface{})
- func (log *YLoggerCore) Fatalf(format string, v ...interface{})
- func (log *YLoggerCore) Flags() int
- func (log *YLoggerCore) Info(v ...interface{})
- func (log *YLoggerCore) Infof(format string, v ...interface{})
- func (log *YLoggerCore) OutPut(level int, s string) error
- func (log *YLoggerCore) Panic(v ...interface{})
- func (log *YLoggerCore) Panicf(format string, v ...interface{})
- func (log *YLoggerCore) ResetFlags(flag int)
- func (log *YLoggerCore) SetCons(b bool)
- func (log *YLoggerCore) SetLogFile(fileDir string, fileName string)
- func (log *YLoggerCore) SetLogHook(f func([]byte))
- func (log *YLoggerCore) SetLogLevel(logLevel int)
- func (log *YLoggerCore) SetMaxAge(ma int)
- func (log *YLoggerCore) SetMaxSize(ms int64)
- func (log *YLoggerCore) SetPrefix(prefix string)
- func (log *YLoggerCore) Stack(v ...interface{})
- func (log *YLoggerCore) Warn(v ...interface{})
- func (log *YLoggerCore) 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 StdYLog = NewYLog("", BitDefault)
StdYLog creates a global log
Functions ¶
func SetLogFile ¶
SetLogFile sets the log file of StdYLog
func SetLogLevel ¶ added in v1.0.3
func SetLogLevel(logLevel int)
SetLogLevel sets the log level of StdYLog
Types ¶
type ILogger ¶ added in v1.0.3
type ILogger interface { //without context InfoF(format string, v ...interface{}) ErrorF(format string, v ...interface{}) DebugF(format string, v ...interface{}) //with context InfoFX(ctx context.Context, format string, v ...interface{}) ErrorFX(ctx context.Context, format string, v ...interface{}) DebugFX(ctx context.Context, format string, v ...interface{}) }
type Writer ¶ added in v1.0.3
type Writer struct {
// contains filtered or unexported fields
}
func (*Writer) SetMaxSize ¶ added in v1.0.3
SetMaxSize 单个日志最大容量
type YLoggerCore ¶ added in v1.0.3
type YLoggerCore struct {
// contains filtered or unexported fields
}
func NewYLog ¶
func NewYLog(prefix string, flag int) *YLoggerCore
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 (*YLoggerCore) AddFlag ¶ added in v1.0.3
func (log *YLoggerCore) AddFlag(flag int)
AddFlag adds a flag to the bitmap flags (添加flag标记)
func (*YLoggerCore) Debug ¶ added in v1.0.3
func (log *YLoggerCore) Debug(v ...interface{})
func (*YLoggerCore) Debugf ¶ added in v1.0.3
func (log *YLoggerCore) Debugf(format string, v ...interface{})
func (*YLoggerCore) Error ¶ added in v1.0.3
func (log *YLoggerCore) Error(v ...interface{})
func (*YLoggerCore) Errorf ¶ added in v1.0.3
func (log *YLoggerCore) Errorf(format string, v ...interface{})
func (*YLoggerCore) Fatal ¶ added in v1.0.3
func (log *YLoggerCore) Fatal(v ...interface{})
func (*YLoggerCore) Fatalf ¶ added in v1.0.3
func (log *YLoggerCore) Fatalf(format string, v ...interface{})
func (*YLoggerCore) Flags ¶ added in v1.0.3
func (log *YLoggerCore) Flags() int
Flags gets the current log bitmap flags (获取当前日志bitmap标记)
func (*YLoggerCore) Info ¶ added in v1.0.3
func (log *YLoggerCore) Info(v ...interface{})
func (*YLoggerCore) Infof ¶ added in v1.0.3
func (log *YLoggerCore) Infof(format string, v ...interface{})
func (*YLoggerCore) OutPut ¶ added in v1.0.3
func (log *YLoggerCore) OutPut(level int, s string) error
OutPut outputs log file, the original method
func (*YLoggerCore) Panic ¶ added in v1.0.3
func (log *YLoggerCore) Panic(v ...interface{})
func (*YLoggerCore) Panicf ¶ added in v1.0.3
func (log *YLoggerCore) Panicf(format string, v ...interface{})
func (*YLoggerCore) ResetFlags ¶ added in v1.0.3
func (log *YLoggerCore) ResetFlags(flag int)
ResetFlags resets the log Flags bitmap flags (重新设置日志Flags bitMap 标记位)
func (*YLoggerCore) SetCons ¶ added in v1.0.3
func (log *YLoggerCore) SetCons(b bool)
SetCons 同时输出控制台
func (*YLoggerCore) SetLogFile ¶ added in v1.0.3
func (log *YLoggerCore) SetLogFile(fileDir string, fileName string)
SetLogFile sets the log file output (设置日志文件输出)
func (*YLoggerCore) SetLogHook ¶ added in v1.0.3
func (log *YLoggerCore) SetLogHook(f func([]byte))
func (*YLoggerCore) SetLogLevel ¶ added in v1.0.3
func (log *YLoggerCore) SetLogLevel(logLevel int)
func (*YLoggerCore) SetMaxAge ¶ added in v1.0.3
func (log *YLoggerCore) SetMaxAge(ma int)
SetMaxAge 最大保留天数
func (*YLoggerCore) SetMaxSize ¶ added in v1.0.3
func (log *YLoggerCore) SetMaxSize(ms int64)
SetMaxSize 单个日志最大容量 单位:字节
func (*YLoggerCore) SetPrefix ¶ added in v1.0.3
func (log *YLoggerCore) SetPrefix(prefix string)
SetPrefix sets a custom prefix for the log (设置日志的 用户自定义前缀字符串)
func (*YLoggerCore) Stack ¶ added in v1.0.3
func (log *YLoggerCore) Stack(v ...interface{})
func (*YLoggerCore) Warn ¶ added in v1.0.3
func (log *YLoggerCore) Warn(v ...interface{})
func (*YLoggerCore) Warnf ¶ added in v1.0.3
func (log *YLoggerCore) Warnf(format string, v ...interface{})