Compare commits

..

2 Commits
v0.1.0 ... main

Author SHA1 Message Date
2283c0f9b8 add interface to readme 2025-03-11 12:16:58 +01:00
1d0e63d91c add Fatal 2024-12-11 11:11:51 +01:00
3 changed files with 37 additions and 1 deletions

View File

@ -1,3 +1,5 @@
## dates and their corresponding seconds been here :) ## dates and their corresponding seconds been here :)
[24-11-15] [24-11-15]
u80864958_at_u80864958 = 979 u80864958_at_u80864958 = 979
[25-03-11]
schreifuchs_at_archibald = 195

View File

@ -1,3 +1,24 @@
# logger # logger
Just a simple logger Just a simple logger
## Logger interfaces
Full:
```go
type Logger interface {
Debug(a ...any)
Debugf(format string, a ...any)
Info(a ...any)
Infof(format string, a ...any)
Warn(str ...any)
Warnf(format string, a ...any)
Error(a ...any)
Errorf(format string, a ...any)
Fatal(code int, a ...any)
Fatalf(code int, format string, a ...any)
}
```

13
log.go
View File

@ -2,6 +2,7 @@ package logger
import ( import (
"fmt" "fmt"
"os"
"git.schreifuchs.ch/schreifuchs/logger/lvl" "git.schreifuchs.ch/schreifuchs/logger/lvl"
) )
@ -59,3 +60,15 @@ func (l *Logger) Error(a ...any) {
func (l *Logger) Errorf(format string, a ...any) { func (l *Logger) Errorf(format string, a ...any) {
l.Logf(lvl.Error, format, a...) 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)
}