xlog

package
v0.0.0-...-427d7b6 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

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/fastnet2/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 (默认日志头部格式)
)

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

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

Log Level

View Source
const (
	LogMaxBuf = 1024 * 1024
)

Variables

This section is empty.

Functions

func AddFlag

func AddFlag(flag int)

AddFlag adds a flag to xlog

func CleanLog

func CleanLog(log *LoggerCore)

CleanLog 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 xlog

func Info

func Info(v ...interface{})

func InfoF

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

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 xlog

func SetCons

func SetCons(b bool)

SetCons 同时输出控制台

func SetLogFile

func SetLogFile(fileDir string, fileName string)

SetLogFile sets the log file of xlog

func SetLogLevel

func SetLogLevel(logLevel int)

SetLogLevel sets the log level of xlog

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 xlog

func Stack

func Stack(v ...interface{})

func Warn

func Warn(v ...interface{})

func WarnF

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

Types

type ILogger

type ILogger interface {
	InfoF(format string, v ...interface{})
	ErrorF(format string, v ...interface{})
	DebugF(format string, v ...interface{})
	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 LoggerCore

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

func NewLog

func NewLog(prefix string, flag int) *LoggerCore

func (*LoggerCore) AddFlag

func (log *LoggerCore) AddFlag(flag int)

AddFlag 添加flag标记

func (*LoggerCore) Debug

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

func (*LoggerCore) DebugF

func (log *LoggerCore) DebugF(format string, v ...interface{})

func (*LoggerCore) Error

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

func (*LoggerCore) ErrorF

func (log *LoggerCore) ErrorF(format string, v ...interface{})

func (*LoggerCore) Fatal

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

func (*LoggerCore) FatalF

func (log *LoggerCore) FatalF(format string, v ...interface{})

func (*LoggerCore) Flags

func (log *LoggerCore) Flags() int

Flags 获取当前日志bitmap标记

func (*LoggerCore) Info

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

func (*LoggerCore) InfoF

func (log *LoggerCore) InfoF(format string, v ...interface{})

func (*LoggerCore) OutPut

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

OutPut outputs log file, the original method

func (*LoggerCore) Panic

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

func (*LoggerCore) PanicF

func (log *LoggerCore) PanicF(format string, v ...interface{})

func (*LoggerCore) ResetFlags

func (log *LoggerCore) ResetFlags(flag int)

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

func (*LoggerCore) SetConsole

func (log *LoggerCore) SetConsole(b bool)

SetConsole 同时输出控制台

func (*LoggerCore) SetLogFile

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

SetLogFile 设置日志文件输出

func (*LoggerCore) SetLogHook

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

func (*LoggerCore) SetLogLevel

func (log *LoggerCore) SetLogLevel(logLevel int)

func (*LoggerCore) SetMaxAge

func (log *LoggerCore) SetMaxAge(ma int)

SetMaxAge 最大保留天数

func (*LoggerCore) SetMaxSize

func (log *LoggerCore) SetMaxSize(ms int64)

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

func (*LoggerCore) SetPrefix

func (log *LoggerCore) SetPrefix(prefix string)

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

func (*LoggerCore) Stack

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

func (*LoggerCore) Warn

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

func (*LoggerCore) WarnF

func (log *LoggerCore) WarnF(format string, v ...interface{})

Jump to

Keyboard shortcuts

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