2018-06-13 22:37:48 +03:00
|
|
|
package logutils
|
|
|
|
|
|
|
|
type Log interface {
|
2023-03-28 17:22:55 +03:00
|
|
|
Fatalf(format string, args ...any)
|
|
|
|
Panicf(format string, args ...any)
|
|
|
|
Errorf(format string, args ...any)
|
|
|
|
Warnf(format string, args ...any)
|
|
|
|
Infof(format string, args ...any)
|
2018-06-13 22:37:48 +03:00
|
|
|
|
|
|
|
Child(name string) Log
|
|
|
|
SetLevel(level LogLevel)
|
|
|
|
}
|
|
|
|
|
|
|
|
type LogLevel int
|
|
|
|
|
|
|
|
const (
|
2022-09-06 13:48:25 +02:00
|
|
|
// LogLevelDebug Debug messages, write to debug logs only by logutils.Debug.
|
2018-06-13 22:37:48 +03:00
|
|
|
LogLevelDebug LogLevel = 0
|
|
|
|
|
2022-09-06 13:48:25 +02:00
|
|
|
// LogLevelInfo Information messages, don't write too many messages,
|
2019-10-13 17:40:51 +03:00
|
|
|
// only useful ones: they are shown when running with -v.
|
2018-06-13 22:37:48 +03:00
|
|
|
LogLevelInfo LogLevel = 1
|
|
|
|
|
2022-09-06 13:48:25 +02:00
|
|
|
// LogLevelWarn Hidden errors: non-critical errors: work can be continued, no need to fail whole program;
|
2018-06-28 21:27:07 +03:00
|
|
|
// tests will crash if any warning occurred.
|
2018-06-13 22:37:48 +03:00
|
|
|
LogLevelWarn LogLevel = 2
|
|
|
|
|
2022-09-06 13:48:25 +02:00
|
|
|
// LogLevelError Only not hidden from user errors: whole program failing, usually
|
2018-06-13 22:37:48 +03:00
|
|
|
// error logging happens in 1-2 places: in the "main" function.
|
|
|
|
LogLevelError LogLevel = 3
|
|
|
|
)
|