Documentation ¶
Index ¶
- Constants
- func DPanic(v ...any)
- func DPanicf(format string, v ...any)
- func DPanicw(msg string, vars V)
- func Debug(v ...any)
- func Debugf(format string, v ...any)
- func Debugw(msg string, vars V)
- func DevelopmentMode()
- func Error(v ...any)
- func Errorf(format string, v ...any)
- func Errorw(msg string, vars V)
- func Fatal(v ...any)
- func Fatalf(format string, v ...any)
- func Fatalw(msg string, vars V)
- func Info(v ...any)
- func Infof(format string, v ...any)
- func Infow(msg string, vars V)
- func Log(level zapcore.Level, v []any)
- func Logf(level zapcore.Level, format string, v []any)
- func Logw(level zapcore.Level, msg string, vars V)
- func Panic(v ...any)
- func Panicf(format string, v ...any)
- func Panicw(msg string, vars V)
- func RegisterHandler(name string, h *Handler)
- func UnregisterHandler(name string)
- func UseDefaultConsoleHandler()
- func UseDefaultFileHandler(path string)
- func UseOptions(opts ...zap.Option)
- func Warn(v ...any)
- func Warnf(format string, v ...any)
- func Warnw(msg string, vars V)
- func WithCaller()
- func WithStacktrace()
- type Handler
- type HandlerConfig
- type HandlerEncoders
- type HandlerKeys
- type HandlerType
- type V
Constants ¶
View Source
const ( DefaultConsoleStdoutHandlerName = "default-console-stdout-handler" DefaultConsoleStderrHandlerName = "default-console-stderr-handler" DefaultFileHandlerName = "default-file-handler" )
Variables ¶
This section is empty.
Functions ¶
func DevelopmentMode ¶
func DevelopmentMode()
DevelopmentMode puts the logger in development mode, which makes DPanic-level logs panic instead of simply logging an error.
func RegisterHandler ¶
RegisterHandler allows to register new logging handler.
func UnregisterHandler ¶
func UnregisterHandler(name string)
UnregisterHandler allows to unregister existing logging handler.
func UseDefaultConsoleHandler ¶
func UseDefaultConsoleHandler()
func UseDefaultFileHandler ¶
func UseDefaultFileHandler(path string)
func UseOptions ¶
func WithCaller ¶
func WithCaller()
WithCaller configures the logger to annotate each message with the filename, line number, and function name (it needs to be enabled by setting function key).
func WithStacktrace ¶
func WithStacktrace()
WithStacktrace configures the logger to record a stack trace for all messages at or above Error level.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func NewHandler(c HandlerConfig) *Handler
type HandlerConfig ¶
type HandlerConfig struct { // Type allows to choose how messages should be encoded. // // Default: HandlerTypeText Type HandlerType // Writer defines where to write messages. Writer io.Writer // WriterSynced defines if writer is already synced. // If false, it is wrapped with mutex to make it safe for concurrent use. // *os.Files must have this set to false. WriterSynced bool // Define how to name logger keys. // Empty string is treated as default value. // If You want to diable some key, set its value to "-". Keys HandlerKeys // Define how to encode logger fields. // nil value falls back to default value. // if You want to disable some encoder, You have to disable its key. Encoders HandlerEncoders // ConsoleSeparator between line elements. Default " : " (TIME : LEVEL : MESSAGE). ConsoleSeparator string // When to log message. Most of the times it simply will be log level. Default to info level. Enabler zapcore.LevelEnabler }
type HandlerEncoders ¶
type HandlerEncoders struct { Level zapcore.LevelEncoder // Default: zapcore.CapitalLevelEncoder Time zapcore.TimeEncoder // Default: zapcore.ISO8601TimeEncoder Duration zapcore.DurationEncoder // Default: zapcore.StringDurationEncoder Caller zapcore.CallerEncoder // Default: zapcore.ShortCallerEncoder Name zapcore.NameEncoder // Optional }
type HandlerKeys ¶
type HandlerType ¶
type HandlerType int
const ( HandlerTypeText HandlerType = iota HandlerTypeJSON )
Click to show internal directories.
Click to hide internal directories.