Documentation ¶
Overview ¶
Package log span logger for trace reference: https://github.com/jaegertracing/jaeger/tree/master/examples/hotrod/pkg/log
Index ¶
- Constants
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func GetZapLogger() *zap.Logger
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- type Config
- type Fields
- type Logger
Constants ¶
View Source
const ( // WriterConsole console输出 WriterConsole = "console" // WriterFile 文件输出 WriterFile = "file" )
View Source
const ( // RotateTimeDaily 按天切割 RotateTimeDaily = "daily" // RotateTimeHourly 按小时切割 RotateTimeHourly = "hourly" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Development bool DisableCaller bool DisableStacktrace bool Encoding string Level string Name string Writers string LoggerFile string LoggerWarnFile string LoggerErrorFile string LogFormatText bool LogRollingPolicy string LogBackupCount uint }
Config log config
type Fields ¶
type Fields map[string]interface{}
Fields Type to pass when we want to call WithFields for structured logging
type Logger ¶
type Logger interface { Debug(args ...interface{}) Debugf(format string, args ...interface{}) Info(args ...interface{}) Infof(format string, args ...interface{}) Warn(args ...interface{}) Warnf(format string, args ...interface{}) Error(args ...interface{}) Errorf(format string, args ...interface{}) WithFields(keyValues Fields) Logger }
Logger is a contract for the logger
func WithContext ¶
WithContext is a logger that can log msg and log span for trace
func WithFields ¶
WithFields logger output more field, eg:
contextLogger := log.WithFields(log.Fields{"key1": "value1"}) contextLogger.Info("print multi field")
or more sample to use:
log.WithFields(log.Fields{"key1": "value1"}).Info("this is a test log") log.WithFields(log.Fields{"key1": "value1"}).Infof("this is a test log, user_id: %d", userID)
Click to show internal directories.
Click to hide internal directories.