Documentation
¶
Overview ¶
fatal, LitFill <marrazzy54 at gmail dot com> library for fatal assignment or logging (error management)
Index ¶
- func Assign[T any](val T, err error) func(*slog.Logger, string, ...any) T
- func CreateLogFile(filename string) *os.File
- func CreateLogger(w io.Writer, lev slog.Level) *slog.Logger
- func Debug(logger *slog.Logger, msg string, args ...any)
- func Error(logger *slog.Logger, msg string, args ...any)
- func Info(logger *slog.Logger, msg string, args ...any)
- func Log(err error, logger *slog.Logger, msg string, args ...any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Assign ¶
Assign handles the return values of functions that return (val T, err error) and returns a function that logs the error and message using slog.Logger and returns val T. example:
file := Assign(os.Create(fileName))( myLogger, "cannot create file", "filename", fileName, )
func CreateLogFile ¶ added in v0.1.8
CreateLogFile creates a new log file with the specified filename and returns a pointer to the opened file. It uses Assign with the default slog.Logger to handle the assignment.
func CreateLogger ¶ added in v0.1.8
CreateLogger creates a new logger object using the slog package and configures it to write logs to the provided writer `w` with the specified logging level `lev`.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.