Documentation
¶
Index ¶
- Constants
- func Debug(args ...interface{})
- func DebugWithFields(msg string, fields map[string]interface{})
- func Debugf(format string, v ...interface{})
- func Debugln(args ...interface{})
- func Error(args ...interface{})
- func ErrorWithFields(msg string, fields map[string]interface{})
- func Errorf(format string, v ...interface{})
- func Errorln(args ...interface{})
- func Errors(err error)
- func Fatal(args ...interface{})
- func FatalWithFields(msg string, fields map[string]interface{})
- func Fatalf(format string, v ...interface{})
- func Fatalln(args ...interface{})
- func Info(args ...interface{})
- func InfoWithFields(msg string, fields map[string]interface{})
- func Infof(format string, v ...interface{})
- func Infoln(args ...interface{})
- func Print(v ...interface{})
- func Printf(format string, v ...interface{})
- func Println(v ...interface{})
- func SetConfig(config *Config) error
- func SetLevel(level Level)
- func SetLogger(level Level, lgr Logger) error
- func Warn(args ...interface{})
- func WarnWithFields(msg string, fields map[string]interface{})
- func Warnf(format string, v ...interface{})
- func Warnln(args ...interface{})
- type Config
- type Level
- type Logger
Constants ¶
const ( DebugLevel = Level(logger.DebugLevel) InfoLevel = Level(logger.InfoLevel) WarnLevel = Level(logger.WarnLevel) ErrorLevel = Level(logger.ErrorLevel) FatalLevel = Level(logger.FatalLevel) )
Level option
Variables ¶
This section is empty.
Functions ¶
func DebugWithFields ¶
DebugWithFields prints debug level log with additional fields. useful when output is in json format
func Debugf ¶
func Debugf(format string, v ...interface{})
Debugf prints debug level log like log.Printf
func ErrorWithFields ¶
ErrorWithFields prints error level log with additional fields. useful when output is in json format
func Errorf ¶
func Errorf(format string, v ...interface{})
Errorf prints error level log like log.Printf
func FatalWithFields ¶
FatalWithFields prints fatal level log with additional fields. useful when output is in json format
func Fatalf ¶
func Fatalf(format string, v ...interface{})
Fatalf prints fatal level log like log.Printf
func InfoWithFields ¶
InfoWithFields prints info level log with additional fields. useful when output is in json format
func Infof ¶
func Infof(format string, v ...interface{})
Infof prints info level log like log.Printf
func SetLevel ¶
func SetLevel(level Level)
SetLevel adjusts log level threshold. Only log with level higher or equal with this level will be printed
func WarnWithFields ¶
WarnWithFields prints warn level log with additional fields. useful when output is in json format
Types ¶
type Config ¶
type Config struct { // Level log level, default: debug Level Level // Format of the log's time field // default RFC3339="2006-01-02T15:04:05Z07:00" TimeFormat string // AppName is the application name this log belong to AppName string // Caller, option to print caller line numbers. // make sure you understand the overhead when use this Caller bool // LogFile is output file for log other than debug log // this is not needed by default, // application is expected to run in containerized environment LogFile string // DebugFile is output file for debug log // this is not needed by default, // application is expected to run in containerized environment DebugFile string // UseColor, option to colorize log in console. UseColor bool // UseJSON, option to print in json format. UseJSON bool }
Config of log
type Logger ¶
type Logger interface { SetLevel(level logger.Level) Debug(args ...interface{}) Debugln(args ...interface{}) Debugf(format string, args ...interface{}) DebugWithFields(msg string, kv map[string]interface{}) Info(args ...interface{}) Infoln(args ...interface{}) Infof(format string, args ...interface{}) InfoWithFields(msg string, kv map[string]interface{}) Warn(args ...interface{}) Warnln(args ...interface{}) Warnf(format string, args ...interface{}) WarnWithFields(msg string, kv map[string]interface{}) Error(args ...interface{}) Errorln(args ...interface{}) Errorf(format string, args ...interface{}) ErrorWithFields(msg string, kv map[string]interface{}) Errors(err error) Fatal(args ...interface{}) Fatalln(args ...interface{}) Fatalf(format string, args ...interface{}) FatalWithFields(msg string, kv map[string]interface{}) IsValid() bool // IsValid check if Logger is created using constructor }
Logger interface