Documentation ¶
Index ¶
- func Is(e error, kargs ...string) bool
- type Config
- type Error
- type Log
- type Logger
- func (l Logger) ErrorF(format string, args ...any) *Error
- func (l Logger) Fatal(format string, args ...any)
- func (l Logger) Info(format string, args ...any) *Log
- func (l Logger) LogF(statusCode int, format string, args ...any) *Log
- func (l *Logger) RunWithInfRetries(f func() error, exception ...string) error
- func (l *Logger) RunWithRetries(f func() error, exception ...string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Format string // json, text, csv Level int // 100: DEBUG, 200: INFO, 300: NOTICE, 400: WARNING, 500: ERROR, 502: CRITICAL, 509: ALERT Output string // stdout, <filepath> Retries int // number of retries Wait time.Duration // wait time between retries StatusMap map[int][]string // status code to message map }
Config represents the configuration for the logger.
type Error ¶
type Error struct { UUID string `json:"uuid"` Status int `json:"status"` Message string `json:"message"` }
Error represents an error with a UUID, status, and message.
type Log ¶
type Log struct { Timestamp string `json:"timestamp"` Severity string `json:"severity"` Path string `json:"path"` Line int `json:"line"` Error }
Log represents a log entry.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger represents a logger instance.
func NewLogger ¶ added in v1.0.3
NewLogger creates a new logger instance with the given configuration.
func (Logger) ErrorF ¶
ErrorF logs an error message with the given status code and arguments. It returns an error object.
func (Logger) LogF ¶
LogF logs a formatted message with the given status code and arguments. It returns the log entry.
func (*Logger) RunWithInfRetries ¶ added in v1.1.3
RunWithInfRetries executes a function and retries infinitely if any error.
Click to show internal directories.
Click to hide internal directories.