Documentation ¶
Index ¶
- Constants
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func NewLogger(cfg *Config, loggerInstance int) error
- func Panicf(format string, args ...interface{})
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- type Config
- type Fields
- type Logger
Constants ¶
View Source
const ( // WriterStdOut WriterStdOut = "stdout" // WriterFile WriterFile = "file" )
View Source
const ( // RotateTimeDaily RotateTimeDaily = "daily" // RotateTimeHourly RotateTimeHourly = "hourly" )
View Source
const ( // InstanceZapLogger zap logger InstanceZapLogger int = iota )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Writers string `yaml:"writers"` LoggerLevel string `yaml:"logger_level"` LoggerFile string `yaml:"logger_file"` LoggerWarnFile string `yaml:"logger_warn_file"` LoggerErrorFile string `yaml:"logger_error_file"` LogFormatText bool `yaml:"log_format_text"` LogRollingPolicy string `yaml:"log_rolling_policy"` LogRotateDate int `yaml:"log_rotate_date"` LogRotateSize int `yaml:"log_rotate_size"` LogBackupCount int `yaml:"log_backup_count"` }
Config is the struct for logger information
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{}) Info(args ...interface{}) Warn(args ...interface{}) Error(args ...interface{}) Fatal(args ...interface{}) Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Fatalf(format string, args ...interface{}) Panicf(format string, args ...interface{}) WithFields(keyValues Fields) Logger }
Logger is our contract for the logger
func WithFields ¶
WithFields logger output more field, eg:
contextLogger := coloredoutput.WithFields(coloredoutput.Fields{"key1": "value1"}) contextLogger.Info("print multi field")
or more sample to use:
coloredoutput.WithFields(coloredoutput.Fields{"key1": "value1"}).Info("this is a test coloredoutput") coloredoutput.WithFields(coloredoutput.Fields{"key1": "value1"}).Infof("this is a test coloredoutput, user_id: %d", userID)
Click to show internal directories.
Click to hide internal directories.