Skip to content

Latest commit

 

History

History
38 lines (29 loc) · 706 Bytes

README.md

File metadata and controls

38 lines (29 loc) · 706 Bytes

fatal

fatal by LitFill. Library for fatal assignment or logging (error management). Using log/slog package.

Example

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,
)

Usage notes

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.