fatal

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2024 License: MIT Imports: 3 Imported by: 1

README

fatal

fatal by LitFill. library for fatal assignment or logging (error management)

Example

Log(http.ServeAndListen(port),
    "Can not serve and listen",
    "port", port
)

file := Assign(os.Create("log.txt"),
    "Can not create file",
    "file", "log.txt"
)

Documentation

Overview

fatal, LitFill <marrazzy54 at email dot com> library for fatal assignment or logging (error management)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assign

func Assign[T any](val T, err error) func(string, ...any) T

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))(
    "cannot create file",
    "filename", fileName,
)

func Debug added in v0.0.3

func Debug(msg string, log ...any)

func Error added in v0.0.3

func Error(msg string, log ...any)

func Info added in v0.0.3

func Info(msg string, log ...any)

func Log

func Log(err error, msg string, log ...any)

Log wraps function call returning error to log it using `log/slog` so it has `msg` and `log`. example:

Log(http.ServeAndListen(port),
    "Can not serve and listen",
    "port", port
)

func NewWriter added in v0.1.0

func NewWriter(writers []io.Writer) io.Writer

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL