Documentation
¶
Overview ¶
Package gologger provides a small tagged logger with package-level helpers and support for child loggers.
Index ¶
- Variables
- func Disable()
- func Enabled()
- func Error(raw string, values ...any)
- func Log(raw string, values ...any)
- func Warn(raw string, values ...any)
- type Logger
- func (logger *Logger) Disable()
- func (logger *Logger) Enabled()
- func (logger Logger) Error(raw string, values ...any)
- func (logger *Logger) Get(prefix string) *Logger
- func (logger Logger) IsEnabled() bool
- func (logger Logger) Log(raw string, values ...any)
- func (logger *Logger) Parent() *Logger
- func (logger Logger) Warn(raw string, values ...any)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrWriterNil is returned when a logger has no writer. ErrWriterNil error = errors.New("Writerr is nil") )
Functions ¶
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger writes formatted log messages with a tag and severity level.
Loggers can form a hierarchy through Get, which creates or returns a child logger that inherits the parent writer and enabled state.
func (*Logger) Get ¶
Get returns a child logger with the given prefix.
If a child logger with prefix already exists, Get returns the existing logger. Otherwise, it creates a new child logger that uses the same writer and enabled state as logger.
func (Logger) IsEnabled ¶
IsEnabled reports whether logger can currently write log messages.
It returns false when logging is disabled globally, regardless of the logger's own enabled state.