Documentation ¶
Index ¶
- Constants
- Variables
- func DPanic(msg string, fields ...Field)
- func DPanicf(format string, v ...any)
- func DPanicw(msg string, keysAndValues ...any)
- func Debug(msg string, fields ...Field)
- func Debugf(format string, v ...any)
- func Debugw(msg string, keysAndValues ...any)
- func Error(msg string, fields ...Field)
- func Errorf(format string, v ...any)
- func Errorw(msg string, keysAndValues ...any)
- func Fatal(msg string, fields ...Field)
- func Fatalf(format string, v ...any)
- func Fatalln(msg ...any)
- func Fatalw(msg string, keysAndValues ...any)
- func FromContext(ctx context.Context) *zap.Logger
- func GetLogLevel() zapcore.Level
- func Info(msg string, fields ...Field)
- func Infof(format string, v ...any)
- func Infow(msg string, keysAndValues ...any)
- func Log(lvl zapcore.Level, msg string, fields ...Field)
- func Panic(msg string, fields ...Field)
- func Panicf(format string, v ...any)
- func Panicln(msg ...any)
- func Panicw(msg string, keysAndValues ...any)
- func Print(msg ...any)
- func Printf(format string, v ...any)
- func Println(msg ...any)
- func RunProductionMode(logOutputPaths ...string)
- func StdErrLogger() *log.Logger
- func StdFromOptions(o *Options)
- func StdInfoLogger() *log.Logger
- func Sync()
- func Warn(msg string, fields ...Field)
- func Warnf(format string, v ...any)
- func Warnw(msg string, keysAndValues ...any)
- func WithContext(ctx context.Context, l *zap.Logger) context.Context
- type Field
- type Level
- type Logger
- type Options
- type SugaredLogger
Constants ¶
View Source
const ( StdLogOutputPath = "stdout" ConsoleFormat = "console" JsonFormat = "json" )
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 FromContext ¶
FromContext returns the value of the log key on the ctx.
func GetLogLevel ¶
func RunProductionMode ¶
func RunProductionMode(logOutputPaths ...string)
func StdErrLogger ¶
StdErrLogger returns logger of standard library which writes to supplied zap logger at error level.
func StdFromOptions ¶
func StdFromOptions(o *Options)
func StdInfoLogger ¶
StdInfoLogger returns logger of standard library which writes to supplied zap logger at info level.
Types ¶
type Logger ¶
func WithKeyAndValues ¶
WithKeyAndValues creates a child logger and adds Zap fields to it.
type Options ¶
type Options struct { Name string `json:"name" yaml:"name"` OutputPaths []string `json:"output-paths" yaml:"output-paths"` // LogLevel is the minimum enabled logging level. LogLevel string `json:"level" yaml:"level"` // Format sets the logger's encoding. Valid values are "json" and "console" Format string `json:"format" yaml:"format"` // DisableCaller stops annotating logs with the calling function's file // name and line number. By default, all logs are annotated. DisableCaller bool `json:"disable-caller" yaml:"disable-caller"` // DisableStacktrace completely disables automatic stacktrace capturing. By // default, stacktraces are captured for WarnLevel and above logs in // development and ErrorLevel and above in production. DisableStacktrace bool `json:"disable-stacktrace" yaml:"disable-stacktrace"` // Sampling sets a sampling policy. A nil SamplingConfig disables sampling. Sampling *zap.SamplingConfig `json:"sampling" yaml:"sampling"` // EnableColor set the logging level color EnableColor bool `json:"enable-color" yaml:"enable-color"` // Development puts the logger in development mode, which changes the // behavior of DPanicLevel and takes stacktraces more liberally. Development bool `json:"development" yaml:"development"` // StacktraceLevel configures the Logger to record a stack trace for all messages at // or above a given level. StacktraceLevel string `json:"stacktraceLevel" yaml:"stacktraceLevel"` // CallerSkip is the number of callers skipped by caller annotation CallerSkip int `json:"callerSkip" yaml:"callerSkip"` }
Options contains configuration items related to log.
func NewOptions ¶
NewOptions creates a new Options object with default parameters.
func NewProductionOptions ¶
NewProductionOptions creates an Options object in production environment.
func (*Options) AddOutputPath ¶
func (*Options) SetCallerSkip ¶
func (*Options) SetLogLevel ¶
func (*Options) SetStacktraceLevel ¶
type SugaredLogger ¶
type SugaredLogger = zap.SugaredLogger
Click to show internal directories.
Click to hide internal directories.