xlog

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultLevel       = "info"
	DefaultPath        = "./logs"
	DefaultFileName    = "app.log"
	DefaultCataLog     = "app"
	DefaultCaller      = false
	DefaultMaxFileSize = 1024 // 日志文件大小限制默认值,单位MB,超过该大小会自动压缩归档
	DefaultMaxBackups  = 3    // 日志归档文件个数默认值,超过后会滚动清理,仅当MaxBackups与MaxAge均为0时不再自动清理日志文件
	DefaultMaxAge      = 7    // 日志归档文件保留天数默认值,超过后会滚动清理,仅当MaxBackups与MaxAge均为0时不再自动清理日志文件
)

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

Debug 使用方法:log.Debug("test")

func Debugf

func Debugf(template string, args ...interface{})

Debugf 使用方法:log.Debugf("test:%s", err)

func Debugw

func Debugw(msg string, keysAndValues ...interface{})

Debugw 使用方法:log.Debugw("test", "field1", "value1", "field2", "value2")

func Error

func Error(args ...interface{})

func Errorf

func Errorf(template string, args ...interface{})

func Errorw

func Errorw(msg string, keysAndValues ...interface{})

func Fatal

func Fatal(args ...interface{})

func Fatalf

func Fatalf(template string, args ...interface{})

func Fatalw

func Fatalw(msg string, keysAndValues ...interface{})

func Info

func Info(args ...interface{})

func Infof

func Infof(template string, args ...interface{})

func Infow

func Infow(msg string, keysAndValues ...interface{})

func Init

func Init(settings *LogSettings) error

==========================logger初始化相关beging=============================== Init init logger

func Panic

func Panic(args ...interface{})

func Panicf

func Panicf(template string, args ...interface{})

func Panicw

func Panicw(msg string, keysAndValues ...interface{})

func ParseLevel

func ParseLevel(lv string) (zapcore.Level, error)

ParseLevel 解析日志级别

func Sync

func Sync()

Sync flushes buffer, if any

func Warn

func Warn(args ...interface{})

func Warnf

func Warnf(template string, args ...interface{})

func Warnw

func Warnw(msg string, keysAndValues ...interface{})

Types

type ILogger

type ILogger interface {
	Debug(args ...interface{})
	Info(args ...interface{})
	Warn(args ...interface{})
	Error(args ...interface{})
	Panic(args ...interface{})
	Fatal(args ...interface{})
	Debugf(template string, args ...interface{})
	Infof(template string, args ...interface{})
	Warnf(template string, args ...interface{})
	Errorf(template string, args ...interface{})
	Panicf(template string, args ...interface{})
	Fatalf(template string, args ...interface{})
	Debugw(msg string, keysAndValues ...interface{})
	Infow(msg string, keysAndValues ...interface{})
	Warnw(msg string, keysAndValues ...interface{})
	Errorw(msg string, keysAndValues ...interface{})
	Panicw(msg string, keysAndValues ...interface{})
	Fatalw(msg string, keysAndValues ...interface{})
	WithContext(context xcontext.XContext) ILogger
	WithFields(args map[string]interface{}) ILogger
}

func WithContext

func WithContext(context xcontext.XContext) ILogger

type LogSettings

type LogSettings struct {
	FileName    string // 文件名称
	Path        string // 文件绝对地址,如:/home/homework/neso/file.log
	Level       string // 日志输出的级别
	CataLog     string // 日志类别
	MaxFileSize int    // 日志文件大小的最大值,单位(M)
	MaxBackups  int    // 最多保留备份数
	MaxAge      int    // 日志文件保存的时间,单位(天)
	Compress    bool   // 是否压缩
	Caller      bool   // 日志是否需要显示调用位置
}

type ZapAdapter

type ZapAdapter struct {
	*LogSettings
	// contains filtered or unexported fields
}

func NewZapAdapter

func NewZapAdapter(path string, level string, catalog string, maxFileSize, maxBackups, maxAge int) *ZapAdapter

func SetCataLog

func SetCataLog(catalog string, addCaller bool) *ZapAdapter

SetCataLog 获取带catalog的日志对象 Deprecated: addCaller参数现在由配置项log.caller指定,不再支持单独为catalog设置,建议改用WithCataLog方法

func WithCataLog

func WithCataLog(catalog string) *ZapAdapter

WithCataLog 获取带catalog的日志对象

func (*ZapAdapter) Build

func (adapter *ZapAdapter) Build()

func (*ZapAdapter) Debug

func (adapter *ZapAdapter) Debug(args ...interface{})

func (*ZapAdapter) Debugf

func (adapter *ZapAdapter) Debugf(template string, args ...interface{})

func (*ZapAdapter) Debugw

func (adapter *ZapAdapter) Debugw(msg string, keysAndValues ...interface{})

func (*ZapAdapter) Error

func (adapter *ZapAdapter) Error(args ...interface{})

func (*ZapAdapter) Errorf

func (adapter *ZapAdapter) Errorf(template string, args ...interface{})

func (*ZapAdapter) Errorw

func (adapter *ZapAdapter) Errorw(msg string, keysAndValues ...interface{})

func (*ZapAdapter) Fatal

func (adapter *ZapAdapter) Fatal(args ...interface{})

func (*ZapAdapter) Fatalf

func (adapter *ZapAdapter) Fatalf(template string, args ...interface{})

func (*ZapAdapter) Fatalw

func (adapter *ZapAdapter) Fatalw(msg string, keysAndValues ...interface{})

func (*ZapAdapter) Info

func (adapter *ZapAdapter) Info(args ...interface{})

func (*ZapAdapter) Infof

func (adapter *ZapAdapter) Infof(template string, args ...interface{})

func (*ZapAdapter) Infow

func (adapter *ZapAdapter) Infow(msg string, keysAndValues ...interface{})

func (*ZapAdapter) Panic

func (adapter *ZapAdapter) Panic(args ...interface{})

func (*ZapAdapter) Panicf

func (adapter *ZapAdapter) Panicf(template string, args ...interface{})

func (*ZapAdapter) Panicw

func (adapter *ZapAdapter) Panicw(msg string, keysAndValues ...interface{})

func (*ZapAdapter) SetCataLog

func (adapter *ZapAdapter) SetCataLog(catalog string) *zap.SugaredLogger

func (*ZapAdapter) Warn

func (adapter *ZapAdapter) Warn(args ...interface{})

func (*ZapAdapter) Warnf

func (adapter *ZapAdapter) Warnf(template string, args ...interface{})

func (*ZapAdapter) Warnw

func (adapter *ZapAdapter) Warnw(msg string, keysAndValues ...interface{})

func (*ZapAdapter) With

func (adapter *ZapAdapter) With(args ...interface{}) ILogger

==========================zapAdapter实现ILogger相关方法being================

func (*ZapAdapter) WithContext

func (adapter *ZapAdapter) WithContext(ctx xcontext.XContext) ILogger

func (*ZapAdapter) WithFields

func (adapter *ZapAdapter) WithFields(args map[string]interface{}) ILogger

Jump to

Keyboard shortcuts

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