Documentation
¶
Overview ¶
Package log is the log package based on zap.
Index ¶
- Variables
- func Debug(msg string, keysAndValues ...interface{})
- func Debugf(format string, v ...interface{})
- func Error(msg string, keysAndValues ...interface{})
- func Errorf(format string, v ...interface{})
- func Fatal(msg string, keysAndValues ...interface{})
- func Fatalf(format string, v ...interface{})
- func Flush()
- func Info(msg string, keysAndValues ...interface{})
- func Infof(format string, v ...interface{})
- func Init(opts *Options)
- func Panic(msg string, keysAndValues ...interface{})
- func Panicf(format string, v ...interface{})
- func StdLogger(level Level) *log.Logger
- func Warn(msg string, keysAndValues ...interface{})
- func Warnf(format string, v ...interface{})
- func WithContext(ctx context.Context) context.Context
- type InfoLogger
- type Level
- type Logger
- type Options
Constants ¶
This section is empty.
Variables ¶
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 )
Functions ¶
func Debug ¶
func Debug(msg string, keysAndValues ...interface{})
Debug method output debug level log.
func Error ¶
func Error(msg string, keysAndValues ...interface{})
Error method output error level log.
func Fatal ¶
func Fatal(msg string, keysAndValues ...interface{})
Fatal method output Fatalw level log.
func Flush ¶
func Flush()
Flush flushes any buffered log entries. Applications should take care to call before exiting.
func Panic ¶
func Panic(msg string, keysAndValues ...interface{})
Panic method output panic level log.
func Panicf ¶
func Panicf(format string, v ...interface{})
Panicf method output panic level log and shutdown application.
func StdLogger ¶
StdLogger returns logger of standard library which writes to supplied zap logger at specified level.
Types ¶
type InfoLogger ¶
type InfoLogger interface { // Info logs a non-error message with the given key/value pairs as context. Info(msg string, keysAndValues ...interface{}) // Infof logs a non-error format message. Infof(format string, v ...interface{}) // Enabled checks whether this InfoLogger is enabled. Enabled() bool }
InfoLogger represents the ability to log non-error messages, at a particular verbosity.
type Logger ¶
type Logger interface { // InfoLogger All Loggers implement InfoLogger. Calling InfoLogger methods directly on // a Logger value is equivalent to calling them on a V(0) InfoLogger. For // example, logger.Info() produces the same result as logger.V(0).Info. InfoLogger Debug(msg string, keysAndValues ...interface{}) Debugf(format string, v ...interface{}) Warn(msg string, keysAndValues ...interface{}) Warnf(format string, v ...interface{}) Error(msg string, keysAndValues ...interface{}) Errorf(format string, v ...interface{}) Panic(msg string, keysAndValues ...interface{}) Panicf(format string, v ...interface{}) Fatal(msg string, keysAndValues ...interface{}) Fatalf(format string, v ...interface{}) // V returns an InfoLogger value for a specific verbosity level. V(level Level) InfoLogger // WithValues adds some key-value pairs of context to a logger. WithValues(keysAndValues ...interface{}) Logger // WithContext returns a copy of context in which the log value is set. WithContext(ctx context.Context) context.Context // Flush flushes any buffered log entries. Applications should take care to call before exiting. Flush() }
Logger represents the ability to log messages, both errors and not.
func FromContext ¶
FromContext returns the value of the log key on the ctx.
func WithValues ¶
func WithValues(keysAndValues ...interface{}) Logger
WithValues creates a child logger and adds extra key-values to it.
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"` DisableCaller bool `json:"disable-caller" mapstructure:"disable-caller"` DisableStacktrace bool `json:"disable-stacktrace" mapstructure:"disable-stacktrace"` EnableColor bool `json:"enable-color" mapstructure:"enable-color"` Name string `json:"name" mapstructure:"name"` }
Options contains configuration items related to log.
func NewOptions ¶
func NewOptions() *Options
NewOptions creates an Options object with default parameters.