Documentation
¶
Index ¶
- type ContextKey
- type CreateOptions
- type Level
- type Logger
- func (logger *Logger) Debug(msg ...any)
- func (logger *Logger) DebugData(data map[string]any, msg ...any)
- func (logger *Logger) Debugf(format string, args ...any)
- func (logger *Logger) Error(msg ...any)
- func (logger *Logger) ErrorData(data map[string]any, msg ...any)
- func (logger *Logger) Errorf(format string, args ...any)
- func (logger *Logger) Fatal(msg ...any)
- func (logger *Logger) FatalData(data map[string]any, msg ...any)
- func (logger *Logger) Fatalf(format string, args ...any)
- func (logger *Logger) Info(msg ...any)
- func (logger *Logger) InfoData(data map[string]any, msg ...any)
- func (logger *Logger) Infof(format string, args ...any)
- func (logger *Logger) SetLevel(level Level)
- func (logger *Logger) Stacktrace(level Level, allGoroutines bool)
- func (logger *Logger) Warn(msg ...any)
- func (logger *Logger) WarnData(data map[string]any, msg ...any)
- func (logger *Logger) Warnf(format string, args ...any)
- func (logger *Logger) WithContext(ctx context.Context) context.Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextKey ¶
type ContextKey struct{}
type CreateOptions ¶
type CreateOptions func(c *createOpts)
functional options for creating a logger.
func OptExit ¶
func OptExit(exit func(code int)) CreateOptions
option to set the exit function for the logger. useful for testing.
func OptLevel ¶
func OptLevel(level Level) CreateOptions
option to set the log level for the logger.
type Level ¶
type Level uint8
Setting a level prevents messages with a lower level from being logged. The default level is LInfo, suppressing debug messages.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
logger wraps log.Logger.
func Create ¶
func Create(options ...CreateOptions) *Logger
creates a new logger with the given options.
func FromContext ¶
retrieves a logger from a context, see Logger.WithContext.
func (*Logger) DebugData ¶
sends a message with level debug and data. Note data ordering is not stable.
func (*Logger) ErrorData ¶
sends a message with level error and data. Note data ordering is not stable.
func (*Logger) FatalData ¶
sends a message with level fatal, data, and calls the logger exit function.
func (*Logger) Fatalf ¶
sends a formatted message with level fatal and calls the logger exit function.
func (*Logger) InfoData ¶
sends a message with level info and data. Note data ordering is not stable.
func (*Logger) Stacktrace ¶
prints a stacktrace as a log message with customizable level.
func (*Logger) WarnData ¶
sends a message with level warn and data. Note data ordering is not stable.