Documentation
¶
Index ¶
- Variables
- func AppendContextFields(parent context.Context, fields ...zap.Field) context.Context
- func DefaultSamplingConfig() *zap.SamplingConfig
- func DynamicDebugLogging(parent context.Context) context.Context
- func GetContextFields(ctx context.Context) []zap.Field
- type Logger
- func (l *Logger) Check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry
- func (l *Logger) Core() zapcore.Core
- func (l *Logger) DPanic(msg string, fields ...zap.Field)
- func (l *Logger) DPanicCtx(ctx context.Context, msg string, fields ...zap.Field)
- func (l *Logger) Debug(msg string, fields ...zap.Field)
- func (l *Logger) DebugCtx(ctx context.Context, msg string, fields ...zap.Field)
- func (l *Logger) Error(msg string, fields ...zap.Field)
- func (l *Logger) ErrorCtx(ctx context.Context, msg string, fields ...zap.Field)
- func (l *Logger) Fatal(msg string, fields ...zap.Field)
- func (l *Logger) FatalCtx(ctx context.Context, msg string, fields ...zap.Field)
- func (l *Logger) GetZapLogger() *zap.Logger
- func (l *Logger) Info(msg string, fields ...zap.Field)
- func (l *Logger) InfoCtx(ctx context.Context, msg string, fields ...zap.Field)
- func (l *Logger) IsDynamicDebugEnabled(ctx context.Context) bool
- func (l *Logger) Named(s string) *Logger
- func (l *Logger) Panic(msg string, fields ...zap.Field)
- func (l *Logger) PanicCtx(ctx context.Context, msg string, fields ...zap.Field)
- func (l *Logger) Sync() error
- func (l *Logger) Warn(msg string, fields ...zap.Field)
- func (l *Logger) WarnCtx(ctx context.Context, msg string, fields ...zap.Field)
- func (l *Logger) With(fields ...zap.Field) *Logger
- func (l *Logger) WithOptions(opts ...zap.Option) *Logger
Constants ¶
This section is empty.
Variables ¶
var ErrNil = errors.New("the value is null")
Functions ¶
func AppendContextFields ¶
func DefaultSamplingConfig ¶
func DefaultSamplingConfig() *zap.SamplingConfig
DefaultSamplingConfig return the default sampling config for the zap logger. it would start sampling after exceeding initial entries(default was 64) per second and only sample the Thereafter(default was 10 which means sampling 10%) th entry.
func DynamicDebugLogging ¶
DynamicDebugLogging open the debug level logging in dynamically
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func GlobalLogger ¶
func GlobalLogger() *Logger
func (*Logger) Check ¶
Check returns a CheckedEntry if logging a message at the specified level is enabled. It's a completely optional optimization; in high-performance applications, Check can help avoid allocating a slice to hold fields.
func (*Logger) DPanic ¶
DPanic logs a message at DPanicLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
If the logger is in development mode, it then panics (DPanic means "development panic"). This is useful for catching errors that are recoverable, but shouldn't ever happen.
func (*Logger) DPanicCtx ¶
DPanicCtx logs a message at DPanicLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
If the logger is in development mode, it then panics (DPanic means "development panic"). This is useful for catching errors that are recoverable, but shouldn't ever happen.
func (*Logger) Debug ¶
Debug logs a message at DebugLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func (*Logger) DebugCtx ¶
DebugCtx logs a message at DebugLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func (*Logger) Error ¶
Warn logs a message at WarnLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func (*Logger) ErrorCtx ¶
ErrorCtx logs a message at ErrorLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func (*Logger) Fatal ¶
Fatal logs a message at FatalLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
The logger then calls os.Exit(1), even if logging at FatalLevel is disabled.
func (*Logger) FatalCtx ¶
FatalCtx logs a message at FatalLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
The logger then calls os.Exit(1), even if logging at FatalLevel is disabled.
func (*Logger) GetZapLogger ¶
GetZapLogger would return the zap logger
func (*Logger) Info ¶
Info logs a message at InfoLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func (*Logger) InfoCtx ¶
InfoCtx logs a message at InfoLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func (*Logger) IsDynamicDebugEnabled ¶
IsDynamicDebugEnabled check whether debug level logging enabled.
func (*Logger) Named ¶
Named adds a new path segment to the logger's name. Segments are joined by periods. By default, Loggers are unnamed.
func (*Logger) Panic ¶
Panic logs a message at PanicLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
The logger then panics, even if logging at PanicLevel is disabled.
func (*Logger) PanicCtx ¶
PanicCtx logs a message at PanicLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
The logger then panics, even if logging at PanicLevel is disabled.
func (*Logger) Sync ¶
Sync calls the underlying Core's Sync method, flushing any buffered log entries. Applications should take care to call Sync before exiting.
func (*Logger) Warn ¶
Warn logs a message at WarnLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func (*Logger) WarnCtx ¶
WarnCtx logs a message at WarnLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.