xlog

package
v0.0.0-...-63f9c8e Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: Apache-2.0 Imports: 7 Imported by: 6

Documentation

Index

Constants

View Source
const (
	ErrPrintFail        = misc.ErrStr("print failed")
	ErrPushFail         = misc.ErrStr("push failed")
	ErrPushPushDeerFail = misc.ErrStr("push failed")
	ErrPushEmailFail    = misc.ErrStr("push failed")
	ErrPushDingFail     = misc.ErrStr("push failed")
	ErrFileFail         = misc.ErrStr("file failed")
	ErrNoLogWay         = misc.ErrStr("no log way")
)

Variables

This section is empty.

Functions

func GoWaitError

func GoWaitError(log *XLog, c <-chan error, from string, s string)

Types

type Extend

type Extend struct {
	OnLog func(content string)
}

type LogInfo

type LogInfo struct {
	LogAddr string
	LogTag  string // 如果不为空则push时默认加上tag作为来源。用于区分来源
}

type LogLevel

type LogLevel uint8
const (
	LogLevelError LogLevel = iota
	LogLevelWarning
	LogLevelInfo
	LogLevelDebug
	LogLevelMisc
	LogLevelBusiness // TODO: 业务日志,业务日志数量很大,需要后续单独处理,有topic,每个topic对应文件或者数据库,不进行常规处理,并可以进行单独的配置
)

type LogPrint

type LogPrint struct {
	Printer    Printer
	IfUseColor bool
}

type LogRecordStrategy

type LogRecordStrategy struct {
	IfPrint bool
	IfPush  bool
	IfFile  bool
}

type LogSetting

func DefaultSetting

func DefaultSetting() LogSetting

DefaultSetting 默认设置 不包含推送相关

type LogStrategy

type LogStrategy struct {
	IfMisc  bool
	IfDebug bool
}

type Printer

type Printer func(string) bool

type PushInfo

type PushInfo struct {
	PushMgr *xpush.XPush
}

type XLog

type XLog struct {
	LogSetting
	misc.InitTag
}

XLog 日志管理器,支持以对应策略记录日志。目前暂不支持复杂策略,可以考虑组合使用多个xLog来实现

func NewXLog

func NewXLog(setting LogSetting) (*XLog, error)

NewXLog 创建一个日志管理器

func (*XLog) Debug

func (receiver *XLog) Debug(from string, format string, a ...interface{})

func (*XLog) Error

func (receiver *XLog) Error(from string, format string, a ...interface{})

func (*XLog) ErrorErr

func (receiver *XLog) ErrorErr(from string, err error)

func (*XLog) Info

func (receiver *XLog) Info(from string, format string, a ...interface{})

func (*XLog) Init

func (receiver *XLog) Init(setting LogSetting) error

func (*XLog) Log

func (receiver *XLog) Log(level LogLevel, from string, info string)

Log 记录一条日志, from 中应填入来源模块的大写, 例如from = "TEST",则日志中会显示[TEST],用于区分来源 因为别的模块的error处理等都是通过日志模块来进行的,所以日志模块的错误处理只能通过print来进行

func (*XLog) Misc

func (receiver *XLog) Misc(from string, format string, a ...interface{})

func (*XLog) Warning

func (receiver *XLog) Warning(from string, format string, a ...interface{})

func (*XLog) WarningErr

func (receiver *XLog) WarningErr(from string, err error)

Jump to

Keyboard shortcuts

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