ylog

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: MIT Imports: 13 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/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 StdYLog = NewYLog("", BitDefault)

StdYLog creates a global log

Functions

func AddFlag

func AddFlag(flag int)

AddFlag adds a flag to StdYLog

func CleanYLog

func CleanYLog(log *YLoggerCore)

CleanYLog 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 StdYLog

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 StdYLog

func SetCons added in v1.0.3

func SetCons(b bool)

SetCons 同时输出控制台

func SetLogFile

func SetLogFile(fileDir string, fileName string)

SetLogFile sets the log file of StdYLog

func SetLogLevel added in v1.0.3

func SetLogLevel(logLevel int)

SetLogLevel sets the log level of StdYLog

func SetLogger added in v1.0.3

func SetLogger(newlog ILogger)

func SetMaxAge added in v1.0.3

func SetMaxAge(ma int)

SetMaxAge 最大保留天数

func SetMaxSize added in v1.0.3

func SetMaxSize(ms int64)

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

func SetPrefix

func SetPrefix(prefix string)

SetPrefix sets the log prefix of StdYLog

func Stack

func Stack(v ...interface{})

func Warn

func Warn(v ...interface{})

func Warnf

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

func Zip added in v1.0.3

func Zip(dst io.Writer, src string) error

Zip 压缩文件或目录 @params dst io.Writer 压缩文件可写流 @params src string 待压缩源文件/目录路径

func ZipToFile added in v1.0.3

func ZipToFile(dst, src string) error

ZipToFile 压缩至文件 @params dst string 压缩文件目标路径 @params src string 待压缩源文件/目录路径 @return error 错误信息

Types

type ILogger added in v1.0.3

type ILogger interface {
	//without context
	InfoF(format string, v ...interface{})
	ErrorF(format string, v ...interface{})
	DebugF(format string, v ...interface{})

	//with context
	InfoFX(ctx context.Context, format string, v ...interface{})
	ErrorFX(ctx context.Context, format string, v ...interface{})
	DebugFX(ctx context.Context, format string, v ...interface{})
}

func Ins added in v1.0.3

func Ins() ILogger

type Writer added in v1.0.3

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

func New added in v1.0.3

func New(path string) *Writer

func (*Writer) Close added in v1.0.3

func (w *Writer) Close() error

func (*Writer) SetCons added in v1.0.3

func (w *Writer) SetCons(b bool)

SetCons 同时输出控制台

func (*Writer) SetMaxAge added in v1.0.3

func (w *Writer) SetMaxAge(ma int)

SetMaxAge 最大保留天数

func (*Writer) SetMaxSize added in v1.0.3

func (w *Writer) SetMaxSize(ms int64)

SetMaxSize 单个日志最大容量

func (*Writer) Write added in v1.0.3

func (w *Writer) Write(p []byte) (n int, err error)

type YLoggerCore added in v1.0.3

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

func NewYLog

func NewYLog(prefix string, flag int) *YLoggerCore

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 (*YLoggerCore) AddFlag added in v1.0.3

func (log *YLoggerCore) AddFlag(flag int)

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

func (*YLoggerCore) Debug added in v1.0.3

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

func (*YLoggerCore) Debugf added in v1.0.3

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

func (*YLoggerCore) Error added in v1.0.3

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

func (*YLoggerCore) Errorf added in v1.0.3

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

func (*YLoggerCore) Fatal added in v1.0.3

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

func (*YLoggerCore) Fatalf added in v1.0.3

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

func (*YLoggerCore) Flags added in v1.0.3

func (log *YLoggerCore) Flags() int

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

func (*YLoggerCore) Info added in v1.0.3

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

func (*YLoggerCore) Infof added in v1.0.3

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

func (*YLoggerCore) OutPut added in v1.0.3

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

OutPut outputs log file, the original method

func (*YLoggerCore) Panic added in v1.0.3

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

func (*YLoggerCore) Panicf added in v1.0.3

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

func (*YLoggerCore) ResetFlags added in v1.0.3

func (log *YLoggerCore) ResetFlags(flag int)

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

func (*YLoggerCore) SetCons added in v1.0.3

func (log *YLoggerCore) SetCons(b bool)

SetCons 同时输出控制台

func (*YLoggerCore) SetLogFile added in v1.0.3

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

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

func (*YLoggerCore) SetLogHook added in v1.0.3

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

func (*YLoggerCore) SetLogLevel added in v1.0.3

func (log *YLoggerCore) SetLogLevel(logLevel int)

func (*YLoggerCore) SetMaxAge added in v1.0.3

func (log *YLoggerCore) SetMaxAge(ma int)

SetMaxAge 最大保留天数

func (*YLoggerCore) SetMaxSize added in v1.0.3

func (log *YLoggerCore) SetMaxSize(ms int64)

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

func (*YLoggerCore) SetPrefix added in v1.0.3

func (log *YLoggerCore) SetPrefix(prefix string)

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

func (*YLoggerCore) Stack added in v1.0.3

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

func (*YLoggerCore) Warn added in v1.0.3

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

func (*YLoggerCore) Warnf added in v1.0.3

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

Jump to

Keyboard shortcuts

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