add Fatal
This commit is contained in:
parent
1de9439225
commit
1d0e63d91c
13
log.go
13
log.go
@ -2,6 +2,7 @@ package logger
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"git.schreifuchs.ch/schreifuchs/logger/lvl"
|
||||
)
|
||||
@ -59,3 +60,15 @@ func (l *Logger) Error(a ...any) {
|
||||
func (l *Logger) Errorf(format string, a ...any) {
|
||||
l.Logf(lvl.Error, format, a...)
|
||||
}
|
||||
|
||||
// Fatal logs directly do stdout and exis the application with given code.
|
||||
func (l *Logger) Fatal(code int, a ...any) {
|
||||
fmt.Println("Fatal:", fmt.Sprint(a...))
|
||||
os.Exit(code)
|
||||
}
|
||||
|
||||
// Fatalf logs formated directly do stdout and exis the application with given code.
|
||||
func (l *Logger) Fatalf(code int, format string, a ...any) {
|
||||
fmt.Println("Fatal:", fmt.Sprintf(format, a...))
|
||||
os.Exit(code)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user