fatal by LitFill. Library for fatal assignment or logging (error management). Using log/slog package.
Log(http.ServeAndListen(port),
logger,
"Can not serve and listen",
"port", port,
)
file := Assign(os.Create(filename),
logger,
"Can not create file",
"file name", filename,
)
Note
I don't know how to optimize this any further.
how this typically used:
func main() {
logFile := fatal.CreateLogFile("log.json")
defer logFile.Close()
logger := fatal.CreateLogger(io.MultiWriter(logFile, os.Stderr), slog.LevelInfo)
}
and then use it like normal.