elog

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: MIT Imports: 16 Imported by: 169

Documentation

Index

Constants

View Source
const (
	DefaultLoggerName = "default.log" // 默认业务日志名称
	EgoLoggerName     = "ego.sys"     // 框架日志名称
)
View Source
const (
	// DebugLevel logs are typically voluminous, and are usually disabled in
	// production.
	DebugLevel = zap.DebugLevel
	// InfoLevel is the default logging priority.
	InfoLevel = zap.InfoLevel
	// WarnLevel logs are more important than Info, but don't need individual
	// human review.
	WarnLevel = zap.WarnLevel
	// ErrorLevel logs are high-priority. If an application is running smoothly,
	// it shouldn't generate any error-Level logs.
	ErrorLevel = zap.ErrorLevel
	// PanicLevel logs a message, then panics.
	PanicLevel = zap.PanicLevel
	// FatalLevel logs a message, then calls os.Exit(1).
	FatalLevel = zap.FatalLevel
)
View Source
const PackageName = "core.elog"

Variables

View Source
var (
	// String ...
	String = zap.String
	// Any ...
	Any = zap.Any
	// Int64 ...
	Int64 = zap.Int64
	// Int ...
	Int = zap.Int
	// Int32 ...
	Int32 = zap.Int32
	// Uint ...
	Uint = zap.Uint
	// Duration ...
	Duration = zap.Duration
	// Durationp ...
	Durationp = zap.Durationp
	// Object ...
	Object = zap.Object
	// Namespace ...
	Namespace = zap.Namespace
	// Reflect ...
	Reflect = zap.Reflect
	// Skip ...
	Skip = zap.Skip()
	// ByteString ...
	ByteString = zap.ByteString
)

Functions

func DPanic

func DPanic(msg string, fields ...Field)

DPanic ...

func DPanicf

func DPanicf(msg string, args ...interface{})

DPanicf ...

func DPanicw

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

DPanicw ...

func Debug

func Debug(msg string, fields ...Field)

Debug ...

func DebugEncodeLevel

func DebugEncodeLevel(lv zapcore.Level, enc zapcore.PrimitiveArrayEncoder)

DebugEncodeLevel ...

func Debugf

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

Debugf ...

func Debugw

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

Debugw ...

func DefaultDebugConfig

func DefaultDebugConfig() *zapcore.EncoderConfig

func DefaultZapConfig

func DefaultZapConfig() *zapcore.EncoderConfig

DefaultZapConfig ...

func Error

func Error(msg string, fields ...Field)

Error ...

func Errorf

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

Errorf ...

func Errorw

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

Errorw ...

func Fatal

func Fatal(msg string, fields ...Field)

Fatal ...

func Fatalf

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

Fatalf ...

func Fatalw

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

Fatalw ...

func Info

func Info(msg string, fields ...Field)

Info ...

func Infof

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

Infof ...

func Infow

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

Infow ...

func InjectTraceMD

func InjectTraceMD(ctx interface{ Set(string, interface{}) }, md *Tracer)

InjectTraceMD ...

func NewContext

func NewContext(ctx context.Context, tracer Tracer) context.Context

NewContext ...

func Panic

func Panic(msg string, fields ...Field)

Panic ...

func Panicf

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

Panicf ...

func Panicw

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

Panicw ...

func Warn

func Warn(msg string, fields ...Field)

Warn ...

func Warnf

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

Warnf ...

func Warnw

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

Warnw ...

Types

type CloseFunc

type CloseFunc func() error

CloseFunc should be called when the caller exits to clean up buffers.

func Buffer

func Buffer(ws zapcore.WriteSyncer, bufferSize int, flushInterval time.Duration) (zapcore.WriteSyncer, CloseFunc)

Buffer wraps a WriteSyncer in a buffer to improve performance, if bufferSize = 0, we set it to defaultBufferSize if flushInterval = 0, we set it to defaultFlushInterval

type Component

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

Func ...

var DefaultLogger *Component

DefaultLogger default logger Biz Log debug=true as default, will be

var EgoLogger *Component

frame logger

func With

func With(fields ...Field) *Component

With ...

func (*Component) AutoLevel

func (logger *Component) AutoLevel(confKey string)

AutoLevel ...

func (*Component) DPanic

func (logger *Component) DPanic(msg string, fields ...Field)

DPanic ...

func (*Component) DPanicf

func (logger *Component) DPanicf(template string, args ...interface{})

DPanicf ...

func (*Component) DPanicw

func (logger *Component) DPanicw(msg string, keysAndValues ...interface{})

DPanicw ...

func (*Component) Debug

func (logger *Component) Debug(msg string, fields ...Field)

Debug ...

func (*Component) Debugf

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

Debugf ...

func (*Component) Debugw

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

Debugw ...

func (*Component) Error

func (logger *Component) Error(msg string, fields ...Field)

Error ...

func (*Component) Errorf

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

Errorf ...

func (*Component) Errorw

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

Errorw ...

func (*Component) Fatal

func (logger *Component) Fatal(msg string, fields ...Field)

Fatal ...

func (*Component) Fatalf

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

Fatalf ...

func (*Component) Fatalw

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

Fatalw ...

func (*Component) Flush

func (logger *Component) Flush() error

Flush ...

func (*Component) Info

func (logger *Component) Info(msg string, fields ...Field)

Info ...

func (*Component) Infof

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

Infof ...

func (*Component) Infow

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

Infow ...

func (*Component) IsDebugMode

func (logger *Component) IsDebugMode() bool

IsDebugMode ...

func (*Component) Panic

func (logger *Component) Panic(msg string, fields ...Field)

Panic ...

func (*Component) Panicf

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

Panicf ...

func (*Component) Panicw

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

Panicw ...

func (*Component) SetLevel

func (logger *Component) SetLevel(lv Level)

SetLevel ...

func (*Component) StdLog

func (logger *Component) StdLog() *log.Logger

StdLog ...

func (*Component) Warn

func (logger *Component) Warn(msg string, fields ...Field)

Warn ...

func (*Component) Warnf

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

Warnf ...

func (*Component) Warnw

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

Warnw ...

func (*Component) With

func (logger *Component) With(fields ...Field) *Component

With ...

type Config

type Config struct {
	Debug               bool          // 配置文件控制日志输出到终端还是文件,true到终端,false到文件
	Dir                 string        // 日志输出目录,默认logs
	Name                string        // 日志文件名称,默认框架日志mocro.sys,业务日志default.log
	Level               string        // 日志初始等级,默认info级别
	AddCaller           bool          // 是否添加调用者信息,默认不加调用者信息
	MaxSize             int           // 日志输出文件最大长度,超过改值则截断,默认500M
	MaxAge              int           // 日志存储最大时间,默认最大保存天数为7天
	MaxBackup           int           // 日志存储最大数量,默认最大保存文件个数为10个
	Interval            time.Duration // 日志轮转时间,默认1天
	Async               bool          // 是否异步,默认异步
	FlushBufferSize     int           // 缓冲大小,默认256 * 1024B
	FlushBufferInterval time.Duration // 缓冲时间,默认5秒
	Fields              []zap.Field   // 日志初始化字段
	CallerSkip          int
	Core                zapcore.Core
	EncoderConfig       *zapcore.EncoderConfig
	// contains filtered or unexported fields
}

Config ...

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig ...

func (*Config) Filename

func (config *Config) Filename() string

Filename ...

type Container

type Container struct {
	Config *Config
	// contains filtered or unexported fields
}

func DefaultContainer

func DefaultContainer() *Container

func Load

func Load(key string) *Container

func (*Container) Build

func (c *Container) Build(options ...Option) *Component

type Field

type Field = zap.Field

Func ...

func FieldAddr

func FieldAddr(value string) Field

func FieldCode

func FieldCode(value int32) Field

FieldCode ...

func FieldComponent

func FieldComponent(value string) Field

func FieldComponentName

func FieldComponentName(value string) Field

func FieldCost

func FieldCost(value time.Duration) Field

耗时时间

func FieldErr

func FieldErr(err error) Field

FieldErr ...

func FieldErrKind

func FieldErrKind(value string) Field

FieldErrKind ...

func FieldEvent

func FieldEvent(value string) Field

FieldEvent ...

func FieldExtMessage

func FieldExtMessage(vals ...interface{}) Field

FieldExtMessage ...

func FieldKey

func FieldKey(value string) Field

FieldKey ...

func FieldMethod

func FieldMethod(value string) Field

FieldMethod ...

func FieldName

func FieldName(value string) Field

FieldName ...

func FieldStack

func FieldStack(value []byte) Field

FieldStack ...

func FieldStringErr

func FieldStringErr(err string) Field

FieldErr ...

func FieldType

func FieldType(value string) Field

FieldType ...

func FieldValue

func FieldValue(value string) Field

FieldValue ...

func FieldValueAny

func FieldValueAny(value interface{}) Field

FieldValueAny ...

type Func

type Func func(string, ...zap.Field)

Func ...

func Auto

func Auto(err error) Func

Auto ...

func (Func) Log

func (fn Func) Log(msg string, fields ...Field)

Log ...

type Level

type Level = zapcore.Level

Func ...

type Option

type Option func(c *Container)

func WithFileName

func WithFileName(name string) Option

type Tracer

type Tracer struct {
	BeginTime time.Time
	// contains filtered or unexported fields
}

Tracer ...

func ExtractTraceMD

func ExtractTraceMD(ctx interface{ Get(string) interface{} }) (md *Tracer, ok bool)

ExtractTraceMD ...

func NewTracer

func NewTracer() *Tracer

NewTracer ...

func (*Tracer) Error

func (t *Tracer) Error(fields ...Field)

Error ...

func (*Tracer) Flush

func (t *Tracer) Flush(msg string, logger *Component)

Flush ...

func (*Tracer) Info

func (t *Tracer) Info(fields ...Field)

Info ...

func (*Tracer) Warn

func (t *Tracer) Warn(fields ...Field)

Warn ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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