zlog

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

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

View Source
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方式,用户可以选择头部需要哪些标记位被打印)

View Source
const (
	LogDebug = iota
	LogInfo
	LogWarn
	LogError
	LogPanic
	LogFatal
)

Log Level

View Source
const (
	LOG_MAX_BUF = 1024 * 1024
)

Variables

View Source
var StdZinxLog = NewZinxLog("", BitDefault)

StdZinxLog creates a global log

Functions

func AddFlag

func AddFlag(flag int)

AddFlag adds a flag to StdZinxLog

func CleanZinxLog

func CleanZinxLog(log *ZinxLoggerCore)

CleanZinxLog Recycle log resources

func Debug

func Debug(v ...interface{})

func Debugf

func Debugf(format string, v ...interface{})

func Error

func Error(v ...interface{})

func Errorf

func Errorf(format string, v ...interface{})

func Fatal

func Fatal(v ...interface{})

func Fatalf

func Fatalf(format string, v ...interface{})

func Flags

func Flags() int

Flags gets the flags of StdZinxLog

func Info

func Info(v ...interface{})

func Infof

func Infof(format string, v ...interface{})

func Ins

func Ins() ziface.ILogger

func Panic

func Panic(v ...interface{})

func Panicf

func Panicf(format string, v ...interface{})

func ResetFlags

func ResetFlags(flag int)

ResetFlags sets the flags of StdZinxLog

func SetCons

func SetCons(b bool)

SetCons 同时输出控制台

func SetLogFile

func SetLogFile(fileDir string, fileName string)

SetLogFile sets the log file of StdZinxLog

func SetLogLevel

func SetLogLevel(logLevel int)

SetLogLevel sets the log level of StdZinxLog

func SetLogger

func SetLogger(newlog ziface.ILogger)

func SetMaxAge

func SetMaxAge(ma int)

SetMaxAge 最大保留天数

func SetMaxSize

func SetMaxSize(ms int64)

SetMaxSize 单个日志最大容量 单位:字节

func SetPrefix

func SetPrefix(prefix string)

SetPrefix sets the log prefix of StdZinxLog

func Stack

func Stack(v ...interface{})

func Warn

func Warn(v ...interface{})

func Warnf

func Warnf(format string, v ...interface{})

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) SetCons

func (log *ZinxLoggerCore) SetCons(b bool)

SetCons 同时输出控制台

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) SetMaxAge

func (log *ZinxLoggerCore) SetMaxAge(ma int)

SetMaxAge 最大保留天数

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{})

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL