2019-03-11 18:56:48 +02:00
|
|
|
package log
|
2018-05-30 19:53:04 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Logger is an optional custom logger.
|
2021-05-14 17:51:05 +02:00
|
|
|
var Logger StdLogger = log.New(os.Stderr, "", log.LstdFlags)
|
2018-09-18 00:17:07 +02:00
|
|
|
|
|
|
|
// StdLogger interface for Standard Logger.
|
|
|
|
type StdLogger interface {
|
|
|
|
Fatal(args ...interface{})
|
|
|
|
Fatalln(args ...interface{})
|
|
|
|
Fatalf(format string, args ...interface{})
|
|
|
|
Print(args ...interface{})
|
|
|
|
Println(args ...interface{})
|
|
|
|
Printf(format string, args ...interface{})
|
|
|
|
}
|
2018-05-30 19:53:04 +02:00
|
|
|
|
|
|
|
// Fatal writes a log entry.
|
|
|
|
// It uses Logger if not nil, otherwise it uses the default log.Logger.
|
|
|
|
func Fatal(args ...interface{}) {
|
|
|
|
Logger.Fatal(args...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fatalf writes a log entry.
|
|
|
|
// It uses Logger if not nil, otherwise it uses the default log.Logger.
|
|
|
|
func Fatalf(format string, args ...interface{}) {
|
|
|
|
Logger.Fatalf(format, args...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Print writes a log entry.
|
|
|
|
// It uses Logger if not nil, otherwise it uses the default log.Logger.
|
|
|
|
func Print(args ...interface{}) {
|
|
|
|
Logger.Print(args...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Println writes a log entry.
|
|
|
|
// It uses Logger if not nil, otherwise it uses the default log.Logger.
|
|
|
|
func Println(args ...interface{}) {
|
|
|
|
Logger.Println(args...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Printf writes a log entry.
|
|
|
|
// It uses Logger if not nil, otherwise it uses the default log.Logger.
|
|
|
|
func Printf(format string, args ...interface{}) {
|
|
|
|
Logger.Printf(format, args...)
|
|
|
|
}
|
2018-06-21 19:06:16 +02:00
|
|
|
|
|
|
|
// Warnf writes a log entry.
|
|
|
|
func Warnf(format string, args ...interface{}) {
|
|
|
|
Printf("[WARN] "+format, args...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Infof writes a log entry.
|
|
|
|
func Infof(format string, args ...interface{}) {
|
|
|
|
Printf("[INFO] "+format, args...)
|
|
|
|
}
|