log

package
v0.0.0-...-2692626 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TraceIDKey = "TraceID" // 日志traceId key
	UserIDKey  = "UID"     // 日志用户ID key

)

Variables

This section is empty.

Functions

func IsEnable

func IsEnable() bool

IsEnable 是否 开启

func PrintErr

func PrintErr(v ...interface{})

PrintErr 输出到os.Stderr

func PrintInfo

func PrintInfo(v ...interface{})

PrintInfo 输出到os.Stdout

func PrintfErr

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

PrintfErr 输出到os.Stderr

func PrintfInfo

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

PrintfInfo 输出到os.Stdout

Types

type Entry

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

Entry 日志数据信息

func (*Entry) Debug

func (p *Entry) Debug(v ...interface{})

Debug 调试日志

func (*Entry) Debugf

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

Debugf 调试日志

func (*Entry) Error

func (p *Entry) Error(v ...interface{})

Error 错误日志

func (*Entry) Errorf

func (p *Entry) Errorf(format string, v ...interface{})

Errorf 错误日志

func (*Entry) Fatal

func (p *Entry) Fatal(v ...interface{})

Fatal 致命日志

func (*Entry) Fatalf

func (p *Entry) Fatalf(format string, v ...interface{})

Fatalf 致命日志

func (*Entry) Info

func (p *Entry) Info(v ...interface{})

Info 信息日志

func (*Entry) Infof

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

Infof 信息日志

func (*Entry) Trace

func (p *Entry) Trace(v ...interface{})

Trace 追踪日志

func (*Entry) Tracef

func (p *Entry) Tracef(format string, v ...interface{})

Tracef 追踪日志

func (*Entry) Warn

func (p *Entry) Warn(v ...interface{})

Warn 警告日志

func (*Entry) Warnf

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

Warnf 警告日志

func (*Entry) WithContext

func (p *Entry) WithContext(ctx context.Context) *Entry

WithContext 由ctx创建Entry

func (*Entry) WithField

func (p *Entry) WithField(key string, value interface{}) *Entry

WithField 由field创建Entry

func (*Entry) WithFields

func (p *Entry) WithFields(fields fields) *Entry

WithFields 由多个field创建Entry

type Hook

type Hook interface {
	Levels() []Level         //需要hook的等级列表
	Fire(entry *Entry) error //执行的方法
}

Hook 钩子

type Level

type Level int
const (
	LevelOff   Level = 0 //关闭
	LevelFatal Level = 1
	LevelError Level = 2
	LevelWarn  Level = 3
	LevelInfo  Level = 4
	LevelDebug Level = 5
	LevelTrace Level = 6
	LevelOn    Level = 7 //7 全部打开
)

日志等级

type LevelHooks

type LevelHooks map[Level][]Hook

type Mgr

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

Mgr 日志

func GetInstance

func GetInstance() *Mgr

GetInstance 获取

func (*Mgr) Debug

func (p *Mgr) Debug(v ...interface{})

Debug 调试日志

func (*Mgr) Debugf

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

Debugf 调试日志

func (*Mgr) Error

func (p *Mgr) Error(v ...interface{})

Error 错误日志

func (*Mgr) Errorf

func (p *Mgr) Errorf(format string, v ...interface{})

Errorf 错误日志

func (*Mgr) Fatal

func (p *Mgr) Fatal(v ...interface{})

Fatal 致命日志

func (*Mgr) Fatalf

func (p *Mgr) Fatalf(format string, v ...interface{})

Fatalf 致命日志

func (*Mgr) GetLevel

func (p *Mgr) GetLevel() Level

GetLevel 获取日志等级

func (*Mgr) Info

func (p *Mgr) Info(v ...interface{})

Info 信息日志

func (*Mgr) Infof

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

Infof 信息日志

func (*Mgr) SetLevel

func (p *Mgr) SetLevel(lv Level) error

SetLevel 设置日志等级

func (*Mgr) Start

func (p *Mgr) Start(_ context.Context, opts ...*Options) error

Start 开始

参数:
	absPath:日志绝对路径
	namePrefix:日志名 前缀

func (*Mgr) Stop

func (p *Mgr) Stop() error

Stop 停止

func (*Mgr) Trace

func (p *Mgr) Trace(v ...interface{})

Trace 踪迹日志

func (*Mgr) Tracef

func (p *Mgr) Tracef(format string, v ...interface{})

Tracef 踪迹日志

func (*Mgr) Warn

func (p *Mgr) Warn(v ...interface{})

Warn 警告日志

func (*Mgr) Warnf

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

Warnf 警告日志

func (*Mgr) WithContext

func (p *Mgr) WithContext(ctx context.Context) *Entry

WithContext 由ctx创建日志信息

func (*Mgr) WithField

func (p *Mgr) WithField(key string, value interface{}) *Entry

WithField 由field创建日志信息 默认大小2(cap:2*2=4)

func (*Mgr) WithFields

func (p *Mgr) WithFields(f fields) *Entry

WithFields 由fields创建日志信息 默认大小4(cap:4*2=8)

type Options

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

Options contains Options to configure a server instance. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.

func NewOptions

func NewOptions() *Options

NewOptions 新的Options

func (*Options) AddHooks

func (p *Options) AddHooks(hook Hook) *Options

AddHooks 添加钩子

func (*Options) IsEnablePool

func (p *Options) IsEnablePool() bool

func (*Options) WithAbsPath

func (p *Options) WithAbsPath(absPath string) *Options

func (*Options) WithEnablePool

func (p *Options) WithEnablePool(enablePool bool) *Options

func (*Options) WithHooks

func (p *Options) WithHooks(hooks LevelHooks) *Options

func (*Options) WithIsReportCaller

func (p *Options) WithIsReportCaller(isReportCaller bool) *Options

func (*Options) WithIsWriteFile

func (p *Options) WithIsWriteFile(isWriteFile bool) *Options

func (*Options) WithLevel

func (p *Options) WithLevel(level Level) *Options

func (*Options) WithNamePrefix

func (p *Options) WithNamePrefix(namePrefix string) *Options

Jump to

Keyboard shortcuts

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