zlog

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

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对外句柄,可以直接使用API系列调用

Functions

func AddFlag

func AddFlag(flag int)

添加flag标记

func CleanZinxLog

func CleanZinxLog(log *ZinxLogger)

CleanZinxLog 回收日志处理

func CloseDebug

func CloseDebug()

设置关闭debug

func Debug

func Debug(v ...interface{})

func Debugf

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

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

func Infof

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

====> Info <====

func OpenDebug

func OpenDebug()

设置打开debug

func Panic

func Panic(v ...interface{})

func Panicf

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

====> Panic <====

func ResetFlags

func ResetFlags(flag int)

设置StdZinxLog标记位

func SetLogFile

func SetLogFile(fileDir string, fileName string)

设置StdZinxLog绑定的日志文件

func SetPrefix

func SetPrefix(prefix string)

设置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 ZinxLogger

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

func NewZinxLog

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

NewZinxLog 创建一个日志

@out 标准输出的文件io
@prefix 日志的前缀
@flag 当前日志头部信息的标记位

func (*ZinxLogger) AddFlag

func (log *ZinxLogger) AddFlag(flag int)

AddFlag 添加flag标记

func (*ZinxLogger) CloseDebug

func (log *ZinxLogger) CloseDebug()

func (*ZinxLogger) Debug

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

func (*ZinxLogger) Debugf

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

====> Debug <====

func (*ZinxLogger) Error

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

func (*ZinxLogger) Errorf

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

====> Error <====

func (*ZinxLogger) Fatal

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

func (*ZinxLogger) Fatalf

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

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

func (*ZinxLogger) Flags

func (log *ZinxLogger) Flags() int

Flags 获取当前日志bitmap标记

func (*ZinxLogger) Info

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

func (*ZinxLogger) Infof

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

====> Info <====

func (*ZinxLogger) OpenDebug

func (log *ZinxLogger) OpenDebug()

func (*ZinxLogger) OutPut

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

OutPut 输出日志文件,原方法

func (*ZinxLogger) Panic

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

func (*ZinxLogger) Panicf

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

====> Panic <====

func (*ZinxLogger) ResetFlags

func (log *ZinxLogger) ResetFlags(flag int)

ResetFlags 重新设置日志Flags bitMap 标记位

func (*ZinxLogger) SetLogFile

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

SetLogFile 设置日志文件输出

func (*ZinxLogger) SetPrefix

func (log *ZinxLogger) SetPrefix(prefix string)

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

func (*ZinxLogger) Stack

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

====> Stack <====

func (*ZinxLogger) Warn

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

func (*ZinxLogger) Warnf

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

====> Warn <====

Jump to

Keyboard shortcuts

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