golog

package
v1.2.24041 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultMultiFile = NewMultiFile()
)

Functions

func AddLogger

func AddLogger(id string, typestr string, onMsg func(rec *GoLogRecord) bool)

回调中onMsg函数中rec参数不能进行异步使用

func ConsoleLogMsg

func ConsoleLogMsg(rec *GoLogRecord) bool

打印到控制台

func DelLogger

func DelLogger(id string, typestr string)

typestr 是add时, 传入的typestr

func FormatLogRecord

func FormatLogRecord(format string, rec *GoLogRecord) []byte

Ignores unknown formats Recommended: "[%D %T] [%L] (%S) %M"

func Log3Msgf

func Log3Msgf(callskip int, s string, args ...interface{})

func LogMsg

func LogMsg(typestr string, lvl int8, callskip int, msg interface{})

func LogMsgf

func LogMsgf(typestr string, lvl int8, callskip int, s string, args ...interface{})

func RenameLogFile

func RenameLogFile(filename string) (newfile string, err error)

重命名, 确保源文件存在

Types

type CacheMultiFileWriter

type CacheMultiFileWriter struct {
	MsgLvl int8 // 大于该值的lvl 才会记录(默认为:0)

	// 一个文件完成写入后事件
	OnFileEof func(filename string)
	// contains filtered or unexported fields
}

func NewCacheMultiFileWriter

func NewCacheMultiFileWriter(filename string) *CacheMultiFileWriter

func (*CacheMultiFileWriter) Close

func (this *CacheMultiFileWriter) Close() error

Close后, 实例不再使用

func (*CacheMultiFileWriter) OnLogMsg

func (this *CacheMultiFileWriter) OnLogMsg(rec *GoLogRecord) bool

func (*CacheMultiFileWriter) SetMaxSize

func (this *CacheMultiFileWriter) SetMaxSize(v int)

func (*CacheMultiFileWriter) SetMsgFmt

func (this *CacheMultiFileWriter) SetMsgFmt(s string)

func (*CacheMultiFileWriter) WaitIdle

func (this *CacheMultiFileWriter) WaitIdle()

type GoLog

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

func NewGoLog

func NewGoLog() *GoLog

func (*GoLog) AddLogger

func (this *GoLog) AddLogger(id string, typestr string, onMsg func(rec *GoLogRecord) bool)

id: 唯一, typestr下id是唯一的, 重复添加会覆盖id的上一次回调 typestr : * 代表所有

func (*GoLog) DelLogger

func (this *GoLog) DelLogger(id string, typestr string)

typestr 是add时, 传入的typestr

func (*GoLog) LogMsg

func (this *GoLog) LogMsg(typestr string, lvl int8, callskip int, msg interface{})

func (*GoLog) LogMsgf

func (this *GoLog) LogMsgf(typestr string, lvl int8, callskip int, s string, args ...interface{})

type GoLogRecord

type GoLogRecord struct {
	Level       int8      // The log level
	CreatedTime time.Time // The time at which the log message was created (nanoseconds)
	Source      string    // The message source
	Typestr     string    // typestr
	Msg         interface{}
}

type MultiFile

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

func NewMultiFile

func NewMultiFile() *MultiFile

func (*MultiFile) CheckGet

func (this *MultiFile) CheckGet(filename string) *SingleCacheFileWriter

func (*MultiFile) Close

func (this *MultiFile) Close()

type SingleCacheFileWriter

type SingleCacheFileWriter struct {
	MsgLvl int8 // 大于该值的lvl 才会记录(默认为:0)

	// 一个文件完成写入后事件
	OnFileEof func(filename string)
	// contains filtered or unexported fields
}

func NewSingleCacheFileWriter

func NewSingleCacheFileWriter(filename string) *SingleCacheFileWriter

func (*SingleCacheFileWriter) Close

func (this *SingleCacheFileWriter) Close() error

Close后, 实例不再使用

func (*SingleCacheFileWriter) GetFileName added in v1.2.24041

func (this *SingleCacheFileWriter) GetFileName() string

func (*SingleCacheFileWriter) GetTotleCount

func (this *SingleCacheFileWriter) GetTotleCount() int

func (*SingleCacheFileWriter) OnLogMsg

func (this *SingleCacheFileWriter) OnLogMsg(rec *GoLogRecord) bool

AddLogger 函数

func (*SingleCacheFileWriter) SetMaxSize

func (this *SingleCacheFileWriter) SetMaxSize(v int)

func (*SingleCacheFileWriter) SetMsgFmt

func (this *SingleCacheFileWriter) SetMsgFmt(s string)

func (*SingleCacheFileWriter) WaitIdle

func (this *SingleCacheFileWriter) WaitIdle()

func (*SingleCacheFileWriter) WriteMsgf

func (this *SingleCacheFileWriter) WriteMsgf(msglvl int8, s string, args ...interface{}) bool

直接写入数据

Jump to

Keyboard shortcuts

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