Documentation
¶
Index ¶
- Constants
- func Close()
- func Debug(a ...any)
- func Debugf(format string, a ...any)
- func Error(a ...any)
- func Errorf(format string, a ...any)
- func Fatal(a ...any)
- func Fatalf(format string, a ...any)
- func Info(a ...any)
- func Infof(format string, a ...any)
- func NewLogger(opts ...Option) *defaultLogger
- func Panic(a ...any)
- func Panicf(format string, a ...any)
- func Print(level Level, a ...any)
- func Printf(level Level, format string, a ...any)
- func SetLogger(logger Logger)
- func Warn(a ...any)
- func Warnf(format string, a ...any)
- type Entity
- type Level
- type Logger
- type Option
- func WithCallFullPath(fullPath bool) Option
- func WithCallSkip(skip int) Option
- func WithLevel(level Level) Option
- func WithStackLevel(level Level) Option
- func WithSyncers(syncers ...Syncer) Option
- func WithTerminals[T Terminal | []Terminal | map[Terminal][]Level](terminals ...T) Option
- func WithTimeFormat(timeFormat string) Option
- type Syncer
- type Terminal
Constants ¶
View Source
const ( LevelNone = internal.LevelNone LevelDebug = internal.LevelDebug LevelInfo = internal.LevelInfo LevelWarn = internal.LevelWarn LevelError = internal.LevelError LevelFatal = internal.LevelFatal LevelPanic = internal.LevelPanic )
Variables ¶
This section is empty.
Functions ¶
func NewLogger ¶
func NewLogger(opts ...Option) *defaultLogger
NewLogger returns a new logger configured with the given options.
Types ¶
type Logger ¶
type Logger interface {
slog.Handler
// Print writes a log record without stack information.
Print(level Level, a ...any)
// Printf writes a formatted log record without stack information.
Printf(level Level, format string, a ...any)
// Debug writes a debug-level log record.
Debug(a ...any)
// Debugf writes a formatted debug-level log record.
Debugf(format string, a ...any)
// Info writes an info-level log record.
Info(a ...any)
// Infof writes a formatted info-level log record.
Infof(format string, a ...any)
// Warn writes a warn-level log record.
Warn(a ...any)
// Warnf writes a formatted warn-level log record.
Warnf(format string, a ...any)
// Error writes an error-level log record.
Error(a ...any)
// Errorf writes a formatted error-level log record.
Errorf(format string, a ...any)
// Fatal writes a fatal-level log record.
Fatal(a ...any)
// Fatalf writes a formatted fatal-level log record.
Fatalf(format string, a ...any)
// Panic writes a panic-level log record.
Panic(a ...any)
// Panicf writes a formatted panic-level log record.
Panicf(format string, a ...any)
// Close closes the logger.
Close() error
}
Logger is a logging interface that extends slog.Handler.
type Option ¶
type Option func(o *options)
Option configures a logger.
func WithCallFullPath ¶ added in v2.3.0
WithCallFullPath sets whether to emit the full path of the caller file for the stack.
func WithCallSkip ¶ added in v2.3.0
WithCallSkip sets the number of stack frames to skip when emitting the stack.
func WithStackLevel ¶
WithStackLevel sets the log level from which the stack is emitted.
func WithSyncers ¶ added in v2.3.0
WithSyncers sets the log syncers.
func WithTerminals ¶ added in v2.3.0
WithTerminals sets the output terminals of the logger.
func WithTimeFormat ¶
WithTimeFormat sets the time format of the log output.
Click to show internal directories.
Click to hide internal directories.