zlog

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: GPL-3.0 Imports: 9 Imported by: 67

Documentation

Overview

Package zlog 主要提供zinx相关日志记录接口 包括:

stdzlog模块, 提供全局日志方法
zlogger模块,  日志内部定义协议,均为对象类方法

当前文件描述: @Title zlogger.go @Description 基础日志接口,包括Debug、Fatal等 @Author Aceld - Thu Mar 11 10:32:29 CST 2019

Package zlog 主要提供zinx相关日志记录接口 包括:

stdzlog模块, 提供全局日志方法
zlogger模块,  日志内部定义协议,均为对象类方法

当前文件描述: @Title stdzlog.go @Description 包裹zlogger日志方法,提供全局方法 @Author Aceld - Thu Mar 11 10:32:29 CST 2019

Index

Constants

View Source
const (
	BitDate         = 1 << iota                            //日期标记位  2019/01/23
	BitTime                                                //时间标记位  01:23:12
	BitMicroSeconds                                        //微秒级标记位 01:23:12.111222
	BitLongFile                                            //完整文件名称 /home/go/src/zinx/server.go
	BitShortFile                                           //最后文件名   server.go
	BitLevel                                               //当前日志级别: 0(Debug), 1(Info), 2(Warn), 3(Error), 4(Panic), 5(Fatal)
	BitStdFlag      = BitDate | BitTime                    //标准头部日志格式
	BitDefault      = BitLevel | BitShortFile | BitStdFlag //默认日志头部格式
)

日志头部信息标记位,采用bitmap方式,用户可以选择头部需要哪些标记位被打印

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

日志级别

View Source
const (
	LOG_MAX_BUF = 1024 * 1024
)

Variables

View Source
var StdZinxLog = NewZinxLog(os.Stderr, "", BitDefault)

StdZinxLog 创建全局log

Functions

func AddFlag

func AddFlag(flag int)

AddFlag 添加flag标记

func CleanZinxLog

func CleanZinxLog(log *ZinxLoggerCore)

回收日志处理

func CloseDebug

func CloseDebug()

CloseDebug 设置关闭debug

func Debug

func Debug(v ...interface{})

Debug Debug

func Debugf

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

Debugf ====> Debug <====

func Error

func Error(v ...interface{})

func Errorf

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

====> Error <====

func Fatal

func Fatal(v ...interface{})

func Fatalf

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

====> Fatal 需要终止程序 <====

func Flags

func Flags() int

Flags 获取StdZinxLog 标记位

func Info

func Info(v ...interface{})

Info -

func Infof

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

Infof ====> Info <====

func Ins added in v1.1.0

func Ins() ziface.ILogger

func OpenDebug

func OpenDebug()

OpenDebug 设置打开debug

func Panic

func Panic(v ...interface{})

func Panicf

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

====> Panic <====

func ResetFlags

func ResetFlags(flag int)

ResetFlags 设置StdZinxLog标记位

func SetLogFile

func SetLogFile(fileDir string, fileName string)

SetLogFile 设置StdZinxLog绑定的日志文件

func SetLogger added in v1.1.0

func SetLogger(newlog ziface.ILogger)

func SetPrefix

func SetPrefix(prefix string)

SetPrefix 设置StdZinxLog 日志头前缀

func Stack

func Stack(v ...interface{})

====> Stack <====

func Warn

func Warn(v ...interface{})

func Warnf

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

====> Warn <====

Types

type ZinxLoggerCore added in v1.1.0

type ZinxLoggerCore struct {
	// contains filtered or unexported fields
}

func NewZinxLog

func NewZinxLog(out io.Writer, prefix string, flag int) *ZinxLoggerCore

创建一个日志 out: 标准输出的文件io prefix: 日志的前缀 flag: 当前日志头部信息的标记位

func (*ZinxLoggerCore) AddFlag added in v1.1.0

func (log *ZinxLoggerCore) AddFlag(flag int)

添加flag标记

func (*ZinxLoggerCore) CloseDebug added in v1.1.0

func (log *ZinxLoggerCore) CloseDebug()

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

====> Debug <====

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

====> Error <====

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

====> Fatal 需要终止程序 <====

func (*ZinxLoggerCore) Flags added in v1.1.0

func (log *ZinxLoggerCore) Flags() int

获取当前日志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{})

====> Info <====

func (*ZinxLoggerCore) OpenDebug added in v1.1.0

func (log *ZinxLoggerCore) OpenDebug()

func (*ZinxLoggerCore) OutPut added in v1.1.0

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

输出日志文件,原方法

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

====> Panic <====

func (*ZinxLoggerCore) ResetFlags added in v1.1.0

func (log *ZinxLoggerCore) ResetFlags(flag int)

重新设置日志Flags bitMap 标记位

func (*ZinxLoggerCore) SetLogFile added in v1.1.0

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

设置日志文件输出

func (*ZinxLoggerCore) SetPrefix added in v1.1.0

func (log *ZinxLoggerCore) SetPrefix(prefix string)

设置日志的 用户自定义前缀字符串

func (*ZinxLoggerCore) Stack added in v1.1.0

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

====> Stack <====

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

====> Warn <====

Jump to

Keyboard shortcuts

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