Documentation ¶
Index ¶
- Constants
- Variables
- func CheckIntLevel(level int32) bool
- func Debug(msg string, fields ...Field)
- func DebugC(ctx context.Context, msg string, fields ...Field)
- func Debugf(format string, v ...interface{})
- func DebugfC(ctx context.Context, format string, v ...interface{})
- func Debugw(msg string, keysAndValues ...interface{})
- func DebugwC(ctx context.Context, msg string, keysAndValues ...interface{})
- func Error(msg string, fields ...Field)
- func ErrorC(ctx context.Context, msg string, fields ...Field)
- func Errorf(format string, v ...interface{})
- func ErrorfC(ctx context.Context, format string, v ...interface{})
- func Fatal(msg string, fields ...Field)
- func FatalC(ctx context.Context, msg string, fields ...Field)
- func Fatalf(format string, v ...interface{})
- func FatalfC(ctx context.Context, format string, v ...interface{})
- func Flush()
- func Info(msg string, fields ...Field)
- func InfoC(ctx context.Context, msg string, fields ...Field)
- func Infof(format string, v ...interface{})
- func InfofC(ctx context.Context, format string, v ...interface{})
- func Init(opts *Options)
- func Panic(msg string, fields ...Field)
- func PanicC(ctx context.Context, msg string, fields ...Field)
- func Panicf(format string, v ...interface{})
- func PanicfC(ctx context.Context, format string, v ...interface{})
- func StdInfoLogger() *stdlog.Logger
- func Warn(msg string, fields ...Field)
- func WarnC(ctx context.Context, msg string, fields ...Field)
- func Warnf(format string, v ...interface{})
- func WarnfC(ctx context.Context, format string, v ...interface{})
- func ZapLogger() *zap.Logger
- type Field
- type Level
- type LogHelper
- type Logger
- func (l *Logger) Clone(opts ...Option) *Logger
- func (l *Logger) Ctx(ctx context.Context) LoggerWithCtx
- func (l *Logger) DPanicContext(ctx context.Context, msg string, fields ...zapcore.Field)
- func (l *Logger) DPanicfContext(ctx context.Context, format string, v ...interface{})
- func (l *Logger) DebugContext(ctx context.Context, msg string, fields ...zapcore.Field)
- func (l *Logger) DebugfContext(ctx context.Context, format string, v ...interface{})
- func (l *Logger) DebugwContext(ctx context.Context, format string, v ...interface{})
- func (l *Logger) ErrorContext(ctx context.Context, msg string, fields ...zapcore.Field)
- func (l *Logger) ErrorfContext(ctx context.Context, format string, v ...interface{})
- func (l *Logger) FatalContext(ctx context.Context, msg string, fields ...zapcore.Field)
- func (l *Logger) FatalfContext(ctx context.Context, format string, v ...interface{})
- func (l *Logger) Flush()
- func (l *Logger) InfoContext(ctx context.Context, msg string, fields ...zapcore.Field)
- func (l *Logger) InfofContext(ctx context.Context, format string, v ...interface{})
- func (l *Logger) PanicContext(ctx context.Context, msg string, fields ...zapcore.Field)
- func (l *Logger) PanicfContext(ctx context.Context, format string, v ...interface{})
- func (l *Logger) Sugar() *SugaredLogger
- func (l *Logger) WarnContext(ctx context.Context, msg string, fields ...zapcore.Field)
- func (l *Logger) WarnfContext(ctx context.Context, format string, v ...interface{})
- func (l *Logger) WithOptions(opts ...zap.Option) *Logger
- type LoggerWithCtx
- func (l LoggerWithCtx) Clone() LoggerWithCtx
- func (l LoggerWithCtx) Context() context.Context
- func (l LoggerWithCtx) DPanic(msg string, fields ...zapcore.Field)
- func (l LoggerWithCtx) Debug(msg string, fields ...zapcore.Field)
- func (l LoggerWithCtx) Error(msg string, fields ...zapcore.Field)
- func (l LoggerWithCtx) Fatal(msg string, fields ...zapcore.Field)
- func (l LoggerWithCtx) Info(msg string, fields ...zapcore.Field)
- func (l LoggerWithCtx) Logger() *Logger
- func (l LoggerWithCtx) Panic(msg string, fields ...zapcore.Field)
- func (l LoggerWithCtx) Sugar() SugaredLoggerWithCtx
- func (l LoggerWithCtx) Warn(msg string, fields ...zapcore.Field)
- func (l LoggerWithCtx) WithOptions(opts ...zap.Option) LoggerWithCtx
- func (l LoggerWithCtx) ZapLogger() *zap.Logger
- type Option
- type Options
- type SugaredLogger
- func (s *SugaredLogger) Ctx(ctx context.Context) SugaredLoggerWithCtx
- func (s *SugaredLogger) DPanicfContext(ctx context.Context, template string, args ...interface{})
- func (s *SugaredLogger) DPanicwContext(ctx context.Context, msg string, keysAndValues ...interface{})
- func (s *SugaredLogger) DebugfContext(ctx context.Context, template string, args ...interface{})
- func (s *SugaredLogger) DebugwContext(ctx context.Context, msg string, keysAndValues ...interface{})
- func (s *SugaredLogger) Desugar() *Logger
- func (s *SugaredLogger) ErrorfContext(ctx context.Context, template string, args ...interface{})
- func (s *SugaredLogger) ErrorwContext(ctx context.Context, msg string, keysAndValues ...interface{})
- func (s *SugaredLogger) FatalfContext(ctx context.Context, template string, args ...interface{})
- func (s *SugaredLogger) FatalwContext(ctx context.Context, msg string, keysAndValues ...interface{})
- func (s *SugaredLogger) InfofContext(ctx context.Context, template string, args ...interface{})
- func (s *SugaredLogger) InfowContext(ctx context.Context, msg string, keysAndValues ...interface{})
- func (s *SugaredLogger) PanicfContext(ctx context.Context, template string, args ...interface{})
- func (s *SugaredLogger) PanicwContext(ctx context.Context, msg string, keysAndValues ...interface{})
- func (s *SugaredLogger) WarnfContext(ctx context.Context, template string, args ...interface{})
- func (s *SugaredLogger) WarnwContext(ctx context.Context, msg string, keysAndValues ...interface{})
- func (s *SugaredLogger) With(args ...interface{}) *SugaredLogger
- type SugaredLoggerWithCtx
- func (s SugaredLoggerWithCtx) DPanicf(template string, args ...interface{})
- func (s SugaredLoggerWithCtx) DPanicw(msg string, keysAndValues ...interface{})
- func (s SugaredLoggerWithCtx) Debugf(template string, args ...interface{})
- func (s SugaredLoggerWithCtx) Debugw(msg string, keysAndValues ...interface{})
- func (s SugaredLoggerWithCtx) Desugar() *Logger
- func (s SugaredLoggerWithCtx) Errorf(template string, args ...interface{})
- func (s SugaredLoggerWithCtx) Errorw(msg string, keysAndValues ...interface{})
- func (s SugaredLoggerWithCtx) Fatalf(template string, args ...interface{})
- func (s SugaredLoggerWithCtx) Fatalw(msg string, keysAndValues ...interface{})
- func (s SugaredLoggerWithCtx) Infof(template string, args ...interface{})
- func (s SugaredLoggerWithCtx) Infow(msg string, keysAndValues ...interface{})
- func (s SugaredLoggerWithCtx) Panicf(template string, args ...interface{})
- func (s SugaredLoggerWithCtx) Panicw(msg string, keysAndValues ...interface{})
- func (s SugaredLoggerWithCtx) Warnf(template string, args ...interface{})
- func (s SugaredLoggerWithCtx) Warnw(msg string, keysAndValues ...interface{})
Constants ¶
View Source
const ( FormatConsole = "console" FormatJson = "json" )
View Source
const ( KeyRequestID string = "requestID" KeyUsername string = "username" KeyUserID string = "userid" )
Variables ¶
View Source
var ( // DebugLevel logs are typically voluminous, and are usually disabled in // production. DebugLevel = zapcore.DebugLevel // InfoLevel is the default logging priority. InfoLevel = zapcore.InfoLevel // WarnLevel logs are more important than Info, but don't need individual // human review. WarnLevel = zapcore.WarnLevel // ErrorLevel logs are high-priority. If an application is running smoothly, // it shouldn't generate any error-level logs. ErrorLevel = zapcore.ErrorLevel // PanicLevel logs a message, then panics. PanicLevel = zapcore.PanicLevel // FatalLevel logs a message, then calls os.Exit(1). FatalLevel = zapcore.FatalLevel )
View Source
var ( Any = zap.Any Array = zap.Array Object = zap.Object Binary = zap.Binary Bool = zap.Bool Bools = zap.Bools ByteString = zap.ByteString ByteStrings = zap.ByteStrings Complex64 = zap.Complex64 Complex64s = zap.Complex64s Complex128 = zap.Complex128 Complex128s = zap.Complex128s Duration = zap.Duration Durations = zap.Durations Err = zap.Error Errors = zap.Errors Float32 = zap.Float32 Float32s = zap.Float32s Float64 = zap.Float64 Float64s = zap.Float64s Int = zap.Int Ints = zap.Ints Int8 = zap.Int8 Int8s = zap.Int8s Int16 = zap.Int16 Int16s = zap.Int16s Int32 = zap.Int32 Int32s = zap.Int32s Int64 = zap.Int64 Int64s = zap.Int64s Namespace = zap.Namespace Reflect = zap.Reflect Stack = zap.Stack String = zap.String Stringer = zap.Stringer Strings = zap.Strings Time = zap.Time Times = zap.Times Uint = zap.Uint Uints = zap.Uints Uint8 = zap.Uint8 Uint8s = zap.Uint8s Uint16 = zap.Uint16 Uint16s = zap.Uint16s Uint32 = zap.Uint32 Uint32s = zap.Uint32s Uint64 = zap.Uint64 Uint64s = zap.Uint64s Uintptr = zap.Uintptr Uintptrs = zap.Uintptrs )
Alias for zap type functions.
Functions ¶
func CheckIntLevel ¶
func StdInfoLogger ¶
Types ¶
type Logger ¶
Logger 封装了zap.Logger
func (*Logger) DPanicContext ¶
func (*Logger) DPanicfContext ¶
func (*Logger) DebugContext ¶
func (*Logger) DebugfContext ¶
func (*Logger) DebugwContext ¶
func (*Logger) ErrorContext ¶
func (*Logger) ErrorfContext ¶
func (*Logger) FatalContext ¶
func (*Logger) FatalfContext ¶
func (*Logger) InfoContext ¶
func (*Logger) InfofContext ¶
func (*Logger) PanicContext ¶
func (*Logger) PanicfContext ¶
func (*Logger) Sugar ¶
func (l *Logger) Sugar() *SugaredLogger
func (*Logger) WarnContext ¶
func (*Logger) WarnfContext ¶
type LoggerWithCtx ¶
type LoggerWithCtx struct {
// contains filtered or unexported fields
}
LoggerWithCtx 对Logger的封装,加入了context
func (LoggerWithCtx) Clone ¶
func (l LoggerWithCtx) Clone() LoggerWithCtx
func (LoggerWithCtx) Context ¶
func (l LoggerWithCtx) Context() context.Context
func (LoggerWithCtx) Logger ¶
func (l LoggerWithCtx) Logger() *Logger
func (LoggerWithCtx) Sugar ¶
func (l LoggerWithCtx) Sugar() SugaredLoggerWithCtx
Sugar 返回zap的sugared logger
func (LoggerWithCtx) WithOptions ¶
func (l LoggerWithCtx) WithOptions(opts ...zap.Option) LoggerWithCtx
func (LoggerWithCtx) ZapLogger ¶
func (l LoggerWithCtx) ZapLogger() *zap.Logger
type Option ¶
type Option func(l *Logger)
func WithCaller ¶
func WithErrorStatusLevel ¶
func WithMinLevel ¶
func WithStackTrace ¶
func WithTraceIDField ¶
type Options ¶
type Options struct { OutputPaths []string `json:"output-paths" mapstructure:"output-paths"` ErrorOutputPaths []string `json:"error-output-paths" mapstructure:"error-output-paths"` Level string `json:"level" mapstructure:"level"` Format string `json:"format" mapstructure:"format"` Name string `json:"name" mapstructure:"name"` DisableCaller bool `json:"disable-caller" mapstructure:"disable-caller"` DisableStacktrace bool `json:"disable-stacktrace" mapstructure:"disable-stacktrace"` EnableColor bool `json:"enable-color" mapstructure:"enable-color"` Development bool `json:"development" mapstructure:"development"` EnableTraceID bool `json:"enable-trace-id" mapstructure:"enable-trace-id"` //是否开启traceID EnableTraceStack bool `json:"enable-trace-stack" mapstructure:"enable-trace-stack"` //是否开启traceStack }
func NewOptions ¶
func NewOptions() *Options
type SugaredLogger ¶
type SugaredLogger struct { *zap.SugaredLogger // contains filtered or unexported fields }
func (*SugaredLogger) Ctx ¶
func (s *SugaredLogger) Ctx(ctx context.Context) SugaredLoggerWithCtx
func (*SugaredLogger) DPanicfContext ¶
func (s *SugaredLogger) DPanicfContext(ctx context.Context, template string, args ...interface{})
func (*SugaredLogger) DPanicwContext ¶
func (s *SugaredLogger) DPanicwContext( ctx context.Context, msg string, keysAndValues ...interface{}, )
func (*SugaredLogger) DebugfContext ¶
func (s *SugaredLogger) DebugfContext(ctx context.Context, template string, args ...interface{})
func (*SugaredLogger) DebugwContext ¶
func (s *SugaredLogger) DebugwContext( ctx context.Context, msg string, keysAndValues ...interface{}, )
func (*SugaredLogger) Desugar ¶
func (s *SugaredLogger) Desugar() *Logger
func (*SugaredLogger) ErrorfContext ¶
func (s *SugaredLogger) ErrorfContext(ctx context.Context, template string, args ...interface{})
func (*SugaredLogger) ErrorwContext ¶
func (s *SugaredLogger) ErrorwContext( ctx context.Context, msg string, keysAndValues ...interface{}, )
func (*SugaredLogger) FatalfContext ¶
func (s *SugaredLogger) FatalfContext(ctx context.Context, template string, args ...interface{})
func (*SugaredLogger) FatalwContext ¶
func (s *SugaredLogger) FatalwContext( ctx context.Context, msg string, keysAndValues ...interface{}, )
func (*SugaredLogger) InfofContext ¶
func (s *SugaredLogger) InfofContext(ctx context.Context, template string, args ...interface{})
func (*SugaredLogger) InfowContext ¶
func (s *SugaredLogger) InfowContext( ctx context.Context, msg string, keysAndValues ...interface{}, )
func (*SugaredLogger) PanicfContext ¶
func (s *SugaredLogger) PanicfContext(ctx context.Context, template string, args ...interface{})
func (*SugaredLogger) PanicwContext ¶
func (s *SugaredLogger) PanicwContext( ctx context.Context, msg string, keysAndValues ...interface{}, )
func (*SugaredLogger) WarnfContext ¶
func (s *SugaredLogger) WarnfContext(ctx context.Context, template string, args ...interface{})
func (*SugaredLogger) WarnwContext ¶
func (s *SugaredLogger) WarnwContext( ctx context.Context, msg string, keysAndValues ...interface{}, )
func (*SugaredLogger) With ¶
func (s *SugaredLogger) With(args ...interface{}) *SugaredLogger
type SugaredLoggerWithCtx ¶
type SugaredLoggerWithCtx struct {
// contains filtered or unexported fields
}
func (SugaredLoggerWithCtx) DPanicf ¶
func (s SugaredLoggerWithCtx) DPanicf(template string, args ...interface{})
func (SugaredLoggerWithCtx) DPanicw ¶
func (s SugaredLoggerWithCtx) DPanicw(msg string, keysAndValues ...interface{})
func (SugaredLoggerWithCtx) Debugf ¶
func (s SugaredLoggerWithCtx) Debugf(template string, args ...interface{})
func (SugaredLoggerWithCtx) Debugw ¶
func (s SugaredLoggerWithCtx) Debugw(msg string, keysAndValues ...interface{})
func (SugaredLoggerWithCtx) Desugar ¶
func (s SugaredLoggerWithCtx) Desugar() *Logger
func (SugaredLoggerWithCtx) Errorf ¶
func (s SugaredLoggerWithCtx) Errorf(template string, args ...interface{})
func (SugaredLoggerWithCtx) Errorw ¶
func (s SugaredLoggerWithCtx) Errorw(msg string, keysAndValues ...interface{})
func (SugaredLoggerWithCtx) Fatalf ¶
func (s SugaredLoggerWithCtx) Fatalf(template string, args ...interface{})
func (SugaredLoggerWithCtx) Fatalw ¶
func (s SugaredLoggerWithCtx) Fatalw(msg string, keysAndValues ...interface{})
func (SugaredLoggerWithCtx) Infof ¶
func (s SugaredLoggerWithCtx) Infof(template string, args ...interface{})
func (SugaredLoggerWithCtx) Infow ¶
func (s SugaredLoggerWithCtx) Infow(msg string, keysAndValues ...interface{})
func (SugaredLoggerWithCtx) Panicf ¶
func (s SugaredLoggerWithCtx) Panicf(template string, args ...interface{})
func (SugaredLoggerWithCtx) Panicw ¶
func (s SugaredLoggerWithCtx) Panicw(msg string, keysAndValues ...interface{})
func (SugaredLoggerWithCtx) Warnf ¶
func (s SugaredLoggerWithCtx) Warnf(template string, args ...interface{})
func (SugaredLoggerWithCtx) Warnw ¶
func (s SugaredLoggerWithCtx) Warnw(msg string, keysAndValues ...interface{})
Click to show internal directories.
Click to hide internal directories.