Documentation
¶
Index ¶
- Constants
- Variables
- func Debug(msg string, args ...any)
- func DebugLn(msg string, args ...any)
- func Debugf(format string, args ...any)
- func Error(args ...any)
- func ErrorLn(msg string, args ...any)
- func Errorf(format string, args ...any)
- func Fatal(args ...any)
- func FatalLn(msg string, args ...any)
- func Fatalf(format string, args ...any)
- func Field(key string, value any) slog.Attr
- func Info(args ...any)
- func InfoLn(msg string, args ...any)
- func Infof(format string, args ...any)
- func LogIfError(err error, loggerFunc func(args ...any), args ...any)
- func LogIfErrorf(err error, loggerFuncf func(format string, args ...any), format string, ...)
- func New(cfg *Config) *eSlogLogger
- func ParseText(text string) (slog.Level, error)
- func Print(args ...any)
- func Printf(format string, args ...any)
- func Println(args ...any)
- func Warn(args ...any)
- func WarnLn(msg string, args ...any)
- func Warnf(format string, args ...any)
- type Config
- type Format
Constants ¶
const LevelFatal = slog.Level(12)
const LevelPrint = slog.Level(16)
LevelPrint is a sentinel level used by Print/Printf/Println to indicate that the level attribute should be omitted from output. It is higher than default thresholds so it won't be filtered.
Variables ¶
var Logger *eSlogLogger
Logger is the default logger which extends slog.
Functions ¶
func Debugf ¶
Debugf logs at [LevelDebug]. The function uses fmt.Sprintf with given format and args and log it.
func Errorf ¶
Errorf logs at [LevelError]. The function uses fmt.Sprintf with given format and args and log it.
func FatalLn ¶
FatalLn logs at LevelFatal and appends a newline, then exits.
func Fatalf ¶
Fatalf logs at LevelFatal. The function uses fmt.Sprintf with given format and args and log it. Also it calls os.Exit(1).
func Infof ¶
Infof logs at [LevelInfo]. The function uses fmt.Sprintf with given format and args and log it.
func LogIfError ¶
LogIfError check the given error. If error is nil nothing is logged. If error is not nil the loggerFunc is used to log the args. The error is not automatically added to args except args are empty.
func LogIfErrorf ¶
func LogIfErrorf(err error, loggerFuncf func(format string, args ...any), format string, args ...any)
LogIfErrorf checks the given error. If error is nil nothing is logged. If error is not nil the loggerFuncf is used with the given format to print the given args. The error is not automatically added to args except args are empty.
func Print ¶
func Print(args ...any)
Print logs a simple, unstructured message to the configured Logger. The message is produced by fmt.Sprint over args and sent via context.Background. No level, timestamp, or attributes are set on the record; the Handler may supply defaults. Prefer structured or leveled logging APIs for richer context or severity control.
func Printf ¶
Printf formats and logs a message using the package's default Logger.
It applies fmt.Sprintf to the provided format and arguments, then submits the resulting text to the Logger's Handler with a background context. This helper emits only the message and does not set a level or attach attributes; prefer structured, leveled logging APIs when additional context is required.
func Println ¶
func Println(args ...any)
Println logs a line by formatting args with fmt.Sprintln (space‑separated, with a trailing newline) and sending the resulting message to the configured Logger’s Handler using context.Background(). It is a convenience wrapper similar to fmt.Println and does not set an explicit log level or add attributes.
Types ¶
type Format ¶
type Format int
Format represents the log format type.
func ParseFormat ¶
ParseFormat converts a string to Format. It returns an error if the format string is invalid.