Documentation
¶
Overview ¶
Package logging provides tools for easy logging errors with traceback. Logging package is written over slog.Logger.
Index ¶
- Variables
- func GetInstance(logLevel slog.Level, logFilePath string) *slog.Logger
- func GetLogTraceback(skipLevel int) string
- func LogError(logger *slog.Logger, msg string, err error)
- func LogErrorContext(ctx context.Context, logger *slog.Logger, msg string, err error)
- func LogRequest(ctx context.Context, logger *slog.Logger, request any)
- type Config
Constants ¶
This section is empty.
Variables ¶
View Source
var Levels = struct { INFO, DEBUG, WARN, ERROR slog.Level }{ INFO: slog.LevelInfo, DEBUG: slog.LevelDebug, WARN: slog.LevelWarn, ERROR: slog.LevelError, }
Levels are a simple abstractions on slog.Level.
Functions ¶
func GetInstance ¶
GetInstance implemented as singleton pattern to get Logger instance, created once for whole app:.
func GetLogTraceback ¶
GetLogTraceback return a string with info about filename, function name and line https://stackoverflow.com/questions/25927660/how-to-get-the-current-function-name
func LogErrorContext ¶ added in v1.0.5
Types ¶
Click to show internal directories.
Click to hide internal directories.