zlog

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: MIT Imports: 10 Imported by: 22

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 added in v1.1.0

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 added in v1.1.18

func SetCons(b bool)

SetCons 同时输出控制台

func SetLogFile

func SetLogFile(fileDir string, fileName string)

SetLogFile sets the log file of StdZinxLog

func SetLogLevel added in v1.1.16

func SetLogLevel(logLevel int)

SetLogLevel sets the log level of StdZinxLog

func SetLogger added in v1.1.0

func SetLogger(newlog ziface.ILogger)

func SetMaxAge added in v1.1.18

func SetMaxAge(ma int)

SetMaxAge 最大保留天数

func SetMaxSize added in v1.1.18

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 added in v1.1.0

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 added in v1.1.0

func (log *ZinxLoggerCore) AddFlag(flag int)

AddFlag adds a flag to the bitmap flags (添加flag标记)

func (*ZinxLoggerCore) Debug added in v1.1.0

func (log *ZinxLoggerCore) Debug(v ...interface{})

func (*ZinxLoggerCore) Debugf added in v1.1.0

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

func (*ZinxLoggerCore) Error added in v1.1.0

func (log *ZinxLoggerCore) Error(v ...interface{})

func (*ZinxLoggerCore) Errorf added in v1.1.0

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

func (*ZinxLoggerCore) Fatal added in v1.1.0

func (log *ZinxLoggerCore) Fatal(v ...interface{})

func (*ZinxLoggerCore) Fatalf added in v1.1.0

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

func (*ZinxLoggerCore) Flags added in v1.1.0

func (log *ZinxLoggerCore) Flags() int

Flags gets the current log bitmap flags (获取当前日志bitmap标记)

func (*ZinxLoggerCore) Info added in v1.1.0

func (log *ZinxLoggerCore) Info(v ...interface{})

func (*ZinxLoggerCore) Infof added in v1.1.0

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

func (*ZinxLoggerCore) OutPut added in v1.1.0

func (log *ZinxLoggerCore) OutPut(level int, s string) error

OutPut outputs log file, the original method

func (*ZinxLoggerCore) Panic added in v1.1.0

func (log *ZinxLoggerCore) Panic(v ...interface{})

func (*ZinxLoggerCore) Panicf added in v1.1.0

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

func (*ZinxLoggerCore) ResetFlags added in v1.1.0

func (log *ZinxLoggerCore) ResetFlags(flag int)

ResetFlags resets the log Flags bitmap flags (重新设置日志Flags bitMap 标记位)

func (*ZinxLoggerCore) SetCons added in v1.1.18

func (log *ZinxLoggerCore) SetCons(b bool)

SetCons 同时输出控制台

func (*ZinxLoggerCore) SetLogFile added in v1.1.0

func (log *ZinxLoggerCore) SetLogFile(fileDir string, fileName string)

SetLogFile sets the log file output (设置日志文件输出)

func (*ZinxLoggerCore) SetLogHook added in v1.1.18

func (log *ZinxLoggerCore) SetLogHook(f func([]byte))

func (*ZinxLoggerCore) SetLogLevel added in v1.1.16

func (log *ZinxLoggerCore) SetLogLevel(logLevel int)

func (*ZinxLoggerCore) SetMaxAge added in v1.1.18

func (log *ZinxLoggerCore) SetMaxAge(ma int)

SetMaxAge 最大保留天数

func (*ZinxLoggerCore) SetMaxSize added in v1.1.18

func (log *ZinxLoggerCore) SetMaxSize(ms int64)

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

func (*ZinxLoggerCore) SetPrefix added in v1.1.0

func (log *ZinxLoggerCore) SetPrefix(prefix string)

SetPrefix sets a custom prefix for the log (设置日志的 用户自定义前缀字符串)

func (*ZinxLoggerCore) Stack added in v1.1.0

func (log *ZinxLoggerCore) Stack(v ...interface{})

func (*ZinxLoggerCore) Warn added in v1.1.0

func (log *ZinxLoggerCore) Warn(v ...interface{})

func (*ZinxLoggerCore) Warnf added in v1.1.0

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