Documentation
¶
Overview ¶
Package logger provides a simple leveled logging implementation for CLI tools.
Index ¶
- Variables
- func Debug(args ...any)
- func Debugf(format string, args ...any)
- func Error(args ...any)
- func Errorf(format string, args ...any)
- func Fatal(args ...any)
- func Fatalf(format string, args ...any)
- func Info(args ...any)
- func Infof(format string, args ...any)
- func SetMaxLevel(level Level)
- func SetOutput(w io.Writer)
- func Verbose(args ...any)
- func Verbosef(format string, args ...any)
- func Warn(args ...any)
- func Warnf(format string, args ...any)
- type Level
- type Logger
- func (l *Logger) Debug(args ...any)
- func (l *Logger) Debugf(format string, args ...any)
- func (l *Logger) Error(args ...any)
- func (l *Logger) Errorf(format string, args ...any)
- func (l *Logger) Fatal(args ...any)
- func (l *Logger) Fatalf(format string, args ...any)
- func (l *Logger) GetMaxLevel() Level
- func (l *Logger) Info(args ...any)
- func (l *Logger) Infof(format string, args ...any)
- func (l *Logger) SetMaxLevel(level Level)
- func (l *Logger) SetOutput(w io.Writer)
- func (l *Logger) Verbose(args ...any)
- func (l *Logger) Verbosef(format string, args ...any)
- func (l *Logger) Warn(args ...any)
- func (l *Logger) Warnf(format string, args ...any)
Constants ¶
This section is empty.
Variables ¶
var DefaultLogger = New(LevelInfo, os.Stderr)
DefaultLogger is the global logger instance used by package-level functions.
Functions ¶
func Fatal ¶
func Fatal(args ...any)
Fatal logs a message at Fatal level using the DefaultLogger and exits.
func SetMaxLevel ¶
func SetMaxLevel(level Level)
SetMaxLevel sets the maximum logging level on the DefaultLogger.
func Verbose ¶
func Verbose(args ...any)
Verbose logs a message at Verbose level using the DefaultLogger.
Types ¶
type Level ¶
type Level int
Level represents the severity of a log message.
func GetMaxLevel ¶
func GetMaxLevel() Level
GetMaxLevel returns the current maximum logging level from the DefaultLogger.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a leveled logger that outputs messages with level prefixes.
func (*Logger) GetMaxLevel ¶
GetMaxLevel returns the current maximum logging level.
func (*Logger) SetMaxLevel ¶
SetMaxLevel sets the maximum logging level. Messages with a level higher than maxLevel will not be logged.