Documentation
¶
Overview ¶
fatal, LitFill <marrazzy54 at email 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 takes the return values of functions that return (val T, err error) and returns a function that takes msg and logs in style of slog.logger and return the val T.
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. CreateLogFile uses Assign with default slog.Logger to do a proper 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. The logger's logging level is also set based on the lev parameter.
func Debug ¶ added in v0.0.3
Debug is a function that wraps slog. The log record contains the source position of the caller of Debug.
func Error ¶ added in v0.0.3
Error is a function that wraps slog. The log record contains the source position of the caller of Error.
Types ¶
This section is empty.