Documentation
¶
Index ¶
- type LogLevel
- type Logger
- type Mode
- type Slogger
- func (l *Slogger) AnyAttr(attribute string, value any) any
- func (l *Slogger) Debug(description string, attributes ...any)
- func (l *Slogger) Error(description string, err error, attributes ...any)
- func (l *Slogger) Info(description string, attributes ...any)
- func (l *Slogger) LogAndReturnError(message string, err error, attributes ...any) error
- func (l *Slogger) StringAttr(attribute string, value string) any
- func (l *Slogger) Warn(description string, attributes ...any)
- func (l *Slogger) With(attributes ...any) Logger
- func (l *Slogger) WithOperation(operation string) Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LogLevel ¶
type LogLevel int
LogLevel represents the severity of the log message.
func ConvertLoggerMode ¶
type Logger ¶
type Logger interface { Info(description string, attributes ...any) Debug(description string, attributes ...any) Error(description string, err error, attributes ...any) Warn(description string, attributes ...any) WithOperation(operation string) Logger StringAttr(attribute string, value string) any AnyAttr(attribute string, value any) any With(attributes ...any) Logger LogAndReturnError(message string, err error, attributes ...any) error }
Logger interface defines methods for structured logging.
type Slogger ¶
type Slogger struct {
// contains filtered or unexported fields
}
Slogger is an implementation of Logger interface using slog.
func InitLogger ¶
InitLogger initializes a new logger instance based on the provided mode and output strings. It returns a pointer to the initialized Slogger.
If output is "stdout" or "stderr", it configures the logger for the specified log level to the respective standard output.
If output is a file path, it configures the logger to log to that file.
func (*Slogger) LogAndReturnError ¶
func (*Slogger) StringAttr ¶
StringAttr returns a string attribute for logging.
func (*Slogger) WithOperation ¶
WithOperation returns a new logger with the given operation name.
Click to show internal directories.
Click to hide internal directories.