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 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 Register(builder WriterBuilder)
- 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) ConfigDir() string
- func (logger *Component) ConfigName() 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) 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) 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
- func (logger *Component) WithCallerSkip(callerSkip int, fields ...Field) *Component
- func (logger *Component) ZapLogger() *zap.Logger
- func (logger *Component) ZapSugaredLogger() *zap.SugaredLogger
- 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 FieldCtxTid(ctx context.Context) Field
- func FieldCustomKeyValue(key string, value string) 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 FieldLogName(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 FieldUniformCode(value int32) Field
- func FieldValue(value string) Field
- func FieldValueAny(value interface{}) Field
- type Level
- type Option
- func WithDebug(debug bool) Option
- func WithEnableAddCaller(enableAddCaller bool) Option
- func WithEnableAsync(enableAsync bool) Option
- func WithEncoderConfig(encoderConfig *zapcore.EncoderConfig) Option
- func WithFileName(name string) Option
- func WithLevel(level string) Option
- func WithZapCore(core zapcore.Core) Option
- type Writer
- type WriterBuilder
Constants ¶
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 ( // DefaultLoggerName 业务日志名 DefaultLoggerName = "default.log" // EgoLoggerName 系统文件名 EgoLoggerName = "ego.sys" )
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 DPanicf ¶
func DPanicf(msg string, args ...interface{})
DPanicf ... Deprecated: Will be removed in future versions, use DPanic instead.
func DPanicw ¶
func DPanicw(msg string, keysAndValues ...interface{})
DPanicw ... Deprecated: Will be removed in future versions, use DPanic instead.
func Debugf ¶
func Debugf(msg string, args ...interface{})
Debugf ... Deprecated: Will be removed in future versions, use Debug instead.
func Debugw ¶
func Debugw(msg string, keysAndValues ...interface{})
Debugw ... Deprecated: Will be removed in future versions, use Debug instead.
func Errorf ¶
func Errorf(msg string, args ...interface{})
Errorf ... Deprecated: Will be removed in future versions, use Error instead.
func Errorw ¶
func Errorw(msg string, keysAndValues ...interface{})
Errorw ... Deprecated: Will be removed in future versions, use Error instead.
func Fatalf ¶
func Fatalf(msg string, args ...interface{})
Fatalf ... Deprecated: Will be removed in future versions, use Fatal instead.
func Fatalw ¶
func Fatalw(msg string, keysAndValues ...interface{})
Fatalw ... Deprecated: Will be removed in future versions, use Fatal instead.
func Infof ¶
func Infof(msg string, args ...interface{})
Infof ... Deprecated: Will be removed in future versions, use Info instead.
func Infow ¶
func Infow(msg string, keysAndValues ...interface{})
Infow ... Deprecated: Will be removed in future versions, use Info instead.
func Panicf ¶
func Panicf(msg string, args ...interface{})
Panicf ... Deprecated: Will be removed in future versions, use Panic instead.
func Panicw ¶
func Panicw(msg string, keysAndValues ...interface{})
Panicw ... Deprecated: Will be removed in future versions, use Panic instead.
func Register ¶ added in v0.6.0
func Register(builder WriterBuilder)
Register registers a dataSource creator function to the registry
Types ¶
type CloseFunc ¶
type CloseFunc func() error
CloseFunc should be called when the caller exits to clean up buffers.
type Component ¶
type Component struct {
// contains filtered or unexported fields
}
Component defines ego logger component wraps zap.Logger and zap.SugaredLogger
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) ConfigDir ¶ added in v0.6.0
ConfigDir returns log directory path if a fileWriter logger is set.
func (*Component) ConfigName ¶ added in v0.6.0
ConfigName returns logger name.
func (*Component) DPanicf ¶
DPanicf ... Deprecated: Will be removed in future versions, use *Component.DPanic instead.
func (*Component) DPanicw ¶
DPanicw ... Deprecated: Will be removed in future versions, use *Component.DPanic instead.
func (*Component) Debugf ¶
Debugf ... Deprecated: Will be removed in future versions, use *Component.Debug instead.
func (*Component) Debugw ¶
Debugw ... Deprecated: Will be removed in future versions, use *Component.Debug instead.
func (*Component) Errorf ¶
Errorf ... Deprecated: Will be removed in future versions, use *Component.Error instead.
func (*Component) Errorw ¶
Errorw ... Deprecated: Will be removed in future versions, use *Component.Error instead.
func (*Component) Fatalf ¶
Fatalf ... Deprecated: Will be removed in future versions, use *Component.Fatal instead.
func (*Component) Fatalw ¶
Fatalw ... Deprecated: Will be removed in future versions, use *Component.Fatal instead.
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) Infof ¶
Infof ... Deprecated: Will be removed in future versions, use *Component.Info instead.
func (*Component) Infow ¶
Infow ... Deprecated: Will be removed in future versions, use *Component.Info instead.
func (*Component) Panicf ¶
Panicf ... Deprecated: Will be removed in future versions, use *Component.Panic instead.
func (*Component) Panicw ¶
Panicw ... Deprecated: Will be removed in future versions, use *Component.Panic instead.
func (*Component) Warnf ¶
Warnf ... Deprecated: Will be removed in future versions, use *Component.Warn instead.
func (*Component) Warnw ¶
Warnw ... Deprecated: Will be removed in future versions, use *Component.Warn instead.
func (*Component) WithCallerSkip ¶ added in v0.5.5
WithCallerSkip ...
func (*Component) ZapSugaredLogger ¶ added in v0.7.0
func (logger *Component) ZapSugaredLogger() *zap.SugaredLogger
ZapSugaredLogger returns *zap.SugaredLogger
type Config ¶
type Config struct { Debug bool // 是否双写至文件控制日志输出到终端 Level string // 日志初始等级,默认info级别 Dir string // [fileWriter]日志输出目录,默认logs Name string // [fileWriter]日志文件名称,默认框架日志ego.sys,业务日志default.log EnableAddCaller bool // 是否添加调用者信息,默认不加调用者信息 EnableAsync bool // 是否异步,默认异步 Writer string // 使用哪种Writer,可选[file|stderr],默认file CallerSkip int // contains filtered or unexported fields }
Config ...
func (*Config) AtomicLevel ¶ added in v0.6.0
func (c *Config) AtomicLevel() zap.AtomicLevel
AtomicLevel 获取AtomicLevel配置
func (*Config) EncoderConfig ¶
func (c *Config) EncoderConfig() *zapcore.EncoderConfig
EncoderConfig 获取zap encoder配置
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container defines a component instance.
func DefaultContainer ¶
func DefaultContainer() *Container
DefaultContainer returns an default container.
type Field ¶
Field ...
func FieldComponent ¶
FieldComponent constructs an elog Field with component type name
func FieldComponentName ¶
FieldComponentName constructs an elog Field with component name
func FieldCtxTid ¶ added in v0.5.5
FieldCtxTid constructs an elog Field with traceID which extracted from context
func FieldCustomKeyValue ¶ added in v0.5.7
FieldCustomKeyValue constructs a custom Key and value
func FieldDescription ¶ added in v0.3.4
FieldDescription ...
func FieldLogName ¶ added in v0.8.2
FieldLogName constructs a field log name
func FieldUniformCode ¶ added in v0.6.12
FieldUniformCode uniform code
type Option ¶
type Option func(c *Container)
Option overrides a Container's default configuration.
func WithEnableAddCaller ¶ added in v0.3.11
WithEnableAddCaller 是否添加行号,默认不添加行号
func WithEnableAsync ¶ added in v0.3.9
WithEnableAsync 是否异步执行,默认异步
func WithEncoderConfig ¶ added in v1.1.3
func WithEncoderConfig(encoderConfig *zapcore.EncoderConfig) Option
WithEncoderConfig 加入encode config
type WriterBuilder ¶ added in v0.6.0
WriterBuilder 根据key初始化writer