Documentation ¶
Index ¶
- Constants
- Variables
- func DPanic(msg string, fields ...Field)
- func DPanicf(msg string, args ...interface{})
- func DPanicw(msg string, keysAndValues ...interface{})
- func Debug(msg string, fields ...Field)
- func DebugEncodeLevel(lv zapcore.Level, enc zapcore.PrimitiveArrayEncoder)
- func Debugf(msg string, args ...interface{})
- func Debugw(msg string, keysAndValues ...interface{})
- func Error(msg string, fields ...Field)
- func Errorf(msg string, args ...interface{})
- func Errorw(msg string, keysAndValues ...interface{})
- func Fatal(msg string, fields ...Field)
- func Fatalf(msg string, args ...interface{})
- func Fatalw(msg string, keysAndValues ...interface{})
- func Info(msg string, fields ...Field)
- func Infof(msg string, args ...interface{})
- func Infow(msg string, keysAndValues ...interface{})
- func Panic(msg string, fields ...Field)
- func Panicf(msg string, args ...interface{})
- func Panicw(msg string, keysAndValues ...interface{})
- func Warn(msg string, fields ...Field)
- func Warnf(msg string, args ...interface{})
- func Warnw(msg string, keysAndValues ...interface{})
- type CloseFunc
- type Component
- func (logger *Component) AutoLevel(confKey string)
- func (logger *Component) DPanic(msg string, fields ...Field)
- func (logger *Component) DPanicf(template string, args ...interface{})
- func (logger *Component) DPanicw(msg string, keysAndValues ...interface{})
- func (logger *Component) Debug(msg string, fields ...Field)
- func (logger *Component) Debugf(template string, args ...interface{})
- func (logger *Component) Debugw(msg string, keysAndValues ...interface{})
- func (logger *Component) Error(msg string, fields ...Field)
- func (logger *Component) Errorf(template string, args ...interface{})
- func (logger *Component) Errorw(msg string, keysAndValues ...interface{})
- func (logger *Component) Fatal(msg string, fields ...Field)
- func (logger *Component) Fatalf(template string, args ...interface{})
- func (logger *Component) Fatalw(msg string, keysAndValues ...interface{})
- func (logger *Component) Flush() error
- func (logger *Component) GetConfigDir() string
- func (logger *Component) GetConfigName() string
- func (logger *Component) Info(msg string, fields ...Field)
- func (logger *Component) Infof(template string, args ...interface{})
- func (logger *Component) Infow(msg string, keysAndValues ...interface{})
- func (logger *Component) IsDebugMode() bool
- func (logger *Component) Panic(msg string, fields ...Field)
- func (logger *Component) Panicf(template string, args ...interface{})
- func (logger *Component) Panicw(msg string, keysAndValues ...interface{})
- func (logger *Component) SetLevel(lv Level)
- func (logger *Component) StdLog() *log.Logger
- func (logger *Component) Warn(msg string, fields ...Field)
- func (logger *Component) Warnf(template string, args ...interface{})
- func (logger *Component) Warnw(msg string, keysAndValues ...interface{})
- func (logger *Component) With(fields ...Field) *Component
- type Config
- type Container
- type Field
- func FieldAddr(value string) Field
- func FieldApp(value string) Field
- func FieldCode(value int32) Field
- func FieldComponent(value string) Field
- func FieldComponentName(value string) Field
- func FieldCost(value time.Duration) Field
- func FieldDescription(value string) Field
- func FieldErr(err error) Field
- func FieldErrAny(err interface{}) Field
- func FieldErrKind(value string) Field
- func FieldEvent(value string) Field
- func FieldExtMessage(vals ...interface{}) Field
- func FieldIP(value string) Field
- func FieldKey(value string) Field
- func FieldKind(value string) Field
- func FieldMethod(value string) Field
- func FieldName(value string) Field
- func FieldPeerIP(value string) Field
- func FieldPeerName(value string) Field
- func FieldSize(value int32) Field
- func FieldStack(value []byte) Field
- func FieldTid(value string) Field
- func FieldType(value string) Field
- func FieldValue(value string) Field
- func FieldValueAny(value interface{}) Field
- type Func
- type Level
- type Option
Constants ¶
const ( // DefaultLoggerName 业务日志名 DefaultLoggerName = "default.log" // EgoLoggerName 系统文件名 EgoLoggerName = "ego.sys" )
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 )
const PackageName = "core.elog"
PackageName 包名
Variables ¶
var ( // String alias for zap.String String = zap.String // Any alias for zap.Any Any = zap.Any // Int64 alias for zap.Int64 Int64 = zap.Int64 // Int alias for zap.Int Int = zap.Int // Int32 alias for zap.Int32 Int32 = zap.Int32 // Uint alias for zap.Uint Uint = zap.Uint // Duration alias for zap.Duration Duration = zap.Duration // Durationp alias for zap.Duration Durationp = zap.Durationp // Object alias for zap.Object Object = zap.Object // Namespace alias for zap.Namespace Namespace = zap.Namespace // Reflect alias for zap.Reflect Reflect = zap.Reflect // Skip alias for zap.Skip() Skip = zap.Skip() // ByteString alias for zap.ByteString ByteString = zap.ByteString )
Functions ¶
func DebugEncodeLevel ¶
func DebugEncodeLevel(lv zapcore.Level, enc zapcore.PrimitiveArrayEncoder)
DebugEncodeLevel ...
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
}
Component 组件
var DefaultLogger *Component
DefaultLogger defines default logger, it's usually used in application business logic
var EgoLogger *Component
EgoLogger defines ego framework logger, it's for ego framework only
func (*Component) Flush ¶
Flush ... When use os.Stdout or os.Stderr as zapcore.WriteSyncer logger.desugar.Sync() maybe return an error like this: 'sync /dev/stdout: The handle is invalid.' Because os.Stdout and os.Stderr is a non-normal file, maybe not support 'fsync' in different os platform So ignored Sync() return value About issues: https://github.com/uber-go/zap/issues/328 About 'fsync': https://man7.org/linux/man-pages/man2/fsync.2.html
func (*Component) GetConfigDir ¶ added in v0.3.11
GetConfigDir 获取日志路径
func (*Component) GetConfigName ¶ added in v0.3.11
GetConfigName 获取日志名称
type Config ¶
type Config struct { Debug bool // 是否双写至文件控制日志输出到终端 Level string // 日志初始等级,默认info级别 Dir string // [fileWriter]日志输出目录,默认logs Name string // [fileWriter]日志文件名称,默认框架日志ego.sys,业务日志default.log MaxSize int // [fileWriter]日志输出文件最大长度,超过改值则截断,默认500M MaxAge int // [fileWriter]日志存储最大时间,默认最大保存天数为7天 MaxBackup int // [fileWriter]日志存储最大数量,默认最大保存文件个数为10个 RotateInterval time.Duration // [fileWriter]日志轮转时间,默认1天 EnableAddCaller bool // 是否添加调用者信息,默认不加调用者信息 EnableAsync bool // 是否异步,默认异步 FlushBufferSize int // 缓冲大小,默认256 * 1024B FlushBufferInterval time.Duration // 缓冲时间,默认5秒 Writer string // 使用哪种Writer,可选[file|ali|stderr],默认file AliAccessKeyID string // [aliWriter]阿里云sls AKID,必填 AliAccessKeySecret string // [aliWriter]阿里云sls AKSecret,必填 AliEndpoint string // [aliWriter]阿里云sls endpoint,必填 AliProject string // [aliWriter]阿里云sls Project名称,必填 AliLogstore string // [aliWriter]阿里云sls logstore名称,必填 AliAPIBulkSize int // [aliWriter]阿里云sls API单次请求发送最大日志条数,最少256条,默认256条 AliAPITimeout time.Duration // [aliWriter]阿里云sls API接口超时,默认3秒 AliAPIRetryCount int // [aliWriter]阿里云sls API接口重试次数,默认3次 AliAPIRetryWaitTime time.Duration // [aliWriter]阿里云sls API接口重试默认等待间隔,默认1秒 AliAPIRetryMaxWaitTime time.Duration // [aliWriter]阿里云sls API接口重试最大等待间隔,默认3秒 AliAPIMaxIdleConnsPerHost int // [aliWriter]阿里云sls 单个Host HTTP最大空闲连接数,应当大于AliApiMaxIdleConns AliAPIMaxIdleConns int // [aliWriter]阿里云sls HTTP最大空闲连接数 AliAPIIdleConnTimeout time.Duration // [aliWriter]阿里云sls HTTP空闲连接保活时间 CallerSkip int // contains filtered or unexported fields }
Config ...
type Option ¶
type Option func(c *Container)
Option 可选项
func WithEnableAddCaller ¶ added in v0.3.11
WithEnableAddCaller 是否添加行号,默认不添加行号
func WithEnableAsync ¶ added in v0.3.9
WithEnableAsync 是否异步执行,默认异步