Skip to content
/ fatal Public

library for fatal assignment or logging using `log/slog` (error management)

License

Notifications You must be signed in to change notification settings

LitFill/fatal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

library for fatal assignment or logging using `log/slog` (error management)

Resources

License

Stars

Watchers

Forks

Packages

No packages published