Documentation
¶
Index ¶
- func Debug(v ...interface{})
- func Debugf(format string, v ...interface{})
- func Debugw(msg string, keysAndValues ...interface{})
- func Error(v ...interface{})
- func Errorf(format string, v ...interface{})
- func Errorw(msg string, keysAndValues ...interface{})
- func Fatal(v ...interface{})
- func Fatalf(format string, v ...interface{})
- func Fatalw(msg string, keysAndValues ...interface{})
- func Info(v ...interface{})
- func Infof(format string, v ...interface{})
- func Infow(msg string, keysAndValues ...interface{})
- func Panic(v ...interface{})
- func Panicf(format string, v ...interface{})
- func Panicw(msg string, keysAndValues ...interface{})
- func SetLevel(lv Level)
- func SetLogger(v AllLogger)
- func SetOutput(w io.Writer)
- func Trace(v ...interface{})
- func Tracef(format string, v ...interface{})
- func Tracew(msg string, keysAndValues ...interface{})
- func Warn(v ...interface{})
- func Warnf(format string, v ...interface{})
- func Warnw(msg string, keysAndValues ...interface{})
- type AllLogger
- type CommonLogger
- type ControlLogger
- type FormatLogger
- type Level
- type Logger
- type WithLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debug ¶
func Debug(v ...interface{})
Debug logs a debug message using the default logger's Debug method.
Parameters:
- v (...interface{}): Variadic arguments that are passed to the logger.
Returns:
- None.
func Debugf ¶
func Debugf(format string, v ...interface{})
Debugf logs a formatted debug message using the default logger's Debugf method.
Parameters:
- format (string): The format string.
- v (...interface{}): Values to format.
Returns:
- None.
func Debugw ¶
func Debugw(msg string, keysAndValues ...interface{})
Debugw logs a debug message with context key-value pairs using the default logger's Debugw method.
Parameters:
- msg (string): The message to log.
- keysAndValues (...interface{}): Key-value pairs providing additional context.
Returns:
- None.
func Error ¶
func Error(v ...interface{})
Error logs an error message using the default logger's Error method.
Parameters:
- v (...interface{}): Variadic arguments that are passed to the logger.
Returns:
- None.
func Errorf ¶
func Errorf(format string, v ...interface{})
Errorf logs a formatted error message using the default logger's Errorf method.
Parameters:
- format (string): The format string.
- v (...interface{}): Values to format.
Returns:
- None.
func Errorw ¶
func Errorw(msg string, keysAndValues ...interface{})
Errorw logs an error message with context key-value pairs using the default logger's Errorw method.
Parameters:
- msg (string): The message to log.
- keysAndValues (...interface{}): Key-value pairs providing additional context.
Returns:
- None.
func Fatal ¶
func Fatal(v ...interface{})
Fatal calls the default logger's Fatal method and then exits the program.
Parameters:
- v (...interface{}): Variadic arguments that are passed to the logger.
Returns:
- None (the program terminates with os.Exit(1)).
func Fatalf ¶
func Fatalf(format string, v ...interface{})
Fatalf logs a formatted fatal message and then exits the program.
Parameters:
- format (string): The format string.
- v (...interface{}): Values to format.
Returns:
- None (the program terminates with os.Exit(1)).
func Fatalw ¶
func Fatalw(msg string, keysAndValues ...interface{})
Fatalw logs a fatal message with context key-value pairs and then exits the program.
Parameters:
- msg (string): The message to log.
- keysAndValues (...interface{}): Key-value pairs providing additional context.
Returns:
- None (the program terminates with os.Exit(1)).
func Info ¶
func Info(v ...interface{})
Info logs an informational message using the default logger's Info method.
Parameters:
- v (...interface{}): Variadic arguments that are passed to the logger.
Returns:
- None.
func Infof ¶
func Infof(format string, v ...interface{})
Infof logs a formatted informational message using the default logger's Infof method.
Parameters:
- format (string): The format string.
- v (...interface{}): Values to format.
Returns:
- None.
func Infow ¶
func Infow(msg string, keysAndValues ...interface{})
Infow logs an informational message with context key-value pairs using the default logger's Infow method.
Parameters:
- msg (string): The message to log.
- keysAndValues (...interface{}): Key-value pairs providing additional context.
Returns:
- None.
func Panic ¶
func Panic(v ...interface{})
Panic logs a message at the Panic level using the default logger's Panic method. Note: Despite the name, this method does not actually panic.
Parameters:
- v (...interface{}): Variadic arguments that are passed to the logger.
Returns:
- None.
func Panicf ¶
func Panicf(format string, v ...interface{})
Panicf logs a formatted message at the Panic level using the default logger's Panicf method. Note: Despite the name, this method does not actually panic.
Parameters:
- format (string): The format string.
- v (...interface{}): Values to format.
Returns:
- None.
func Panicw ¶
func Panicw(msg string, keysAndValues ...interface{})
Panicw logs a message at the Panic level with context key-value pairs using the default logger's Panicw method. Note: Despite the name, this method does not actually panic.
Parameters:
- msg (string): The message to log.
- keysAndValues (...interface{}): Key-value pairs providing additional context.
Returns:
- None.
func SetLevel ¶
func SetLevel(lv Level)
SetLevel adjusts the logging level to filter messages below a certain severity.
Parameters:
- lv (Level): The logging level to set.
Returns:
- None.
func SetLogger ¶
func SetLogger(v AllLogger)
SetLogger sets the default logger to a new instance.
Parameters:
- v (AllLogger): The new logger to be set.
Returns:
- None.
func SetOutput ¶
SetOutput changes the output destination of the logger.
Parameters:
- w (io.Writer): The new output destination.
Returns:
- None.
func Trace ¶
func Trace(v ...interface{})
Trace logs a trace message using the default logger's Trace method.
Parameters:
- v (...interface{}): Variadic arguments that are passed to the logger.
Returns:
- None.
func Tracef ¶
func Tracef(format string, v ...interface{})
Tracef logs a formatted trace message using the default logger's Tracef method.
Parameters:
- format (string): The format string.
- v (...interface{}): Values to format.
Returns:
- None.
func Tracew ¶
func Tracew(msg string, keysAndValues ...interface{})
Tracew logs a trace message with context key-value pairs using the default logger's Tracew method.
Parameters:
- msg (string): The message to log.
- keysAndValues (...interface{}): Key-value pairs providing additional context.
Returns:
- None.
func Warn ¶
func Warn(v ...interface{})
Warn logs a warning message using the default logger's Warn method.
Parameters:
- v (...interface{}): Variadic arguments that are passed to the logger.
Returns:
- None.
func Warnf ¶
func Warnf(format string, v ...interface{})
Warnf logs a formatted warning message using the default logger's Warnf method.
Parameters:
- format (string): The format string.
- v (...interface{}): Values to format.
Returns:
- None.
func Warnw ¶
func Warnw(msg string, keysAndValues ...interface{})
Warnw logs a warning message with context key-value pairs using the default logger's Warnw method.
Parameters:
- msg (string): The message to log.
- keysAndValues (...interface{}): Key-value pairs providing additional context.
Returns:
- None.
Types ¶
type AllLogger ¶
type AllLogger interface {
CommonLogger
ControlLogger
// WithContext returns a logger that is associated with a given context.
// Parameters:
// - ctx: The context to associate with the logger.
WithContext(ctx context.Context) CommonLogger
}
AllLogger is the combination of Logger, FormatLogger, CtxLogger, and ControlLogger. Custom extensions can be made through AllLogger.
func DefaultLogger ¶
func DefaultLogger() AllLogger
DefaultLogger returns the default logger instance. Parameters: None Returns: (AllLogger) The default logger instance.
type CommonLogger ¶
type CommonLogger interface {
Logger
FormatLogger
WithLogger
}
func WithContext ¶
func WithContext(ctx context.Context) CommonLogger
WithContext creates a new logger with the provided context.
Parameters:
- ctx (context.Context): The context to associate with the logger.
Returns:
- CommonLogger: A logger instance associated with the given context.
type ControlLogger ¶
type ControlLogger interface {
// SetLevel sets the logging level for the logger.
// Parameters:
// - level: The logging level to set.
SetLevel(Level)
// SetOutput sets the output destination for the logger.
// Parameters:
// - writer: The io.Writer to write logs to.
SetOutput(io.Writer)
}
ControlLogger provides methods to configure a logger.
type FormatLogger ¶
type FormatLogger interface {
// Tracef logs a formatted message at the Trace level.
// Parameters:
// - format: The format string.
// - v: The variables or objects to format and log.
Tracef(format string, v ...interface{})
// Debugf logs a formatted message at the Debug level.
// Parameters:
// - format: The format string.
// - v: The variables or objects to format and log.
Debugf(format string, v ...interface{})
// Infof logs a formatted message at the Info level.
// Parameters:
// - format: The format string.
// - v: The variables or objects to format and log.
Infof(format string, v ...interface{})
// Warnf logs a formatted message at the Warning level.
// Parameters:
// - format: The format string.
// - v: The variables or objects to format and log.
Warnf(format string, v ...interface{})
// Errorf logs a formatted message at the Error level.
// Parameters:
// - format: The format string.
// - v: The variables or objects to format and log.
Errorf(format string, v ...interface{})
// Fatalf logs a formatted message at the Fatal level and exits the application.
// Parameters:
// - format: The format string.
// - v: The variables or objects to format and log.
Fatalf(format string, v ...interface{})
// Panicf logs a formatted message at the Panic level.
// Note: Despite the name, this method does not actually panic.
// Parameters:
// - format: The format string.
// - v: The variables or objects to format and log.
Panicf(format string, v ...interface{})
}
FormatLogger is a logger interface that outputs logs with a format.
type Level ¶
type Level int
Level defines the priority of a log message. When a logger is configured with a level, any log message with a lower log level (smaller by integer comparison) will not be output.
const ( LevelTrace Level = iota // Trace represents very detailed debug information. LevelDebug // Debug represents general debugging information. LevelInfo // Info represents informational messages. LevelWarn // Warn represents warning messages. LevelError // Error represents error messages. LevelFatal // Fatal represents critical error messages and causes the program to exit. LevelPanic // Panic represents critical error messages (but does not actually cause a panic). )
The levels of logs.
type Logger ¶
type Logger interface {
// Trace logs a message at the Trace level.
// Parameters:
// - v: The variables or objects to log.
Trace(v ...interface{})
// Debug logs a message at the Debug level.
// Parameters:
// - v: The variables or objects to log.
Debug(v ...interface{})
// Info logs a message at the Info level.
// Parameters:
// - v: The variables or objects to log.
Info(v ...interface{})
// Warn logs a message at the Warning level.
// Parameters:
// - v: The variables or objects to log.
Warn(v ...interface{})
// Error logs a message at the Error level.
// Parameters:
// - v: The variables or objects to log.
Error(v ...interface{})
// Fatal logs a message at the Fatal level and exits the application.
// Parameters:
// - v: The variables or objects to log.
Fatal(v ...interface{})
// Panic logs a message at the Panic level.
// Note: Despite the name, this method does not actually panic.
// Parameters:
// - v: The variables or objects to log.
Panic(v ...interface{})
}
Logger is a logger interface that provides logging function with levels.
type WithLogger ¶
type WithLogger interface {
// Tracew logs a message at the Trace level with key-value pairs.
// Parameters:
// - msg: The message string.
// - keysAndValues: The key-value pairs to log.
Tracew(msg string, keysAndValues ...interface{})
// Debugw logs a message at the Debug level with key-value pairs.
// Parameters:
// - msg: The message string.
// - keysAndValues: The key-value pairs to log.
Debugw(msg string, keysAndValues ...interface{})
// Infow logs a message at the Info level with key-value pairs.
// Parameters:
// - msg: The message string.
// - keysAndValues: The key-value pairs to log.
Infow(msg string, keysAndValues ...interface{})
// Warnw logs a message at the Warning level with key-value pairs.
// Parameters:
// - msg: The message string.
// - keysAndValues: The key-value pairs to log.
Warnw(msg string, keysAndValues ...interface{})
// Errorw logs a message at the Error level with key-value pairs.
// Parameters:
// - msg: The message string.
// - keysAndValues: The key-value pairs to log.
Errorw(msg string, keysAndValues ...interface{})
// Fatalw logs a message at the Fatal level with key-value pairs and exits the application.
// Parameters:
// - msg: The message string.
// - keysAndValues: The key-value pairs to log.
Fatalw(msg string, keysAndValues ...interface{})
// Panicw logs a message at the Panic level with key-value pairs.
// Note: Despite the name, this method does not actually panic.
// Parameters:
// - msg: The message string.
// - keysAndValues: The key-value pairs to log.
Panicw(msg string, keysAndValues ...interface{})
}
WithLogger is a logger interface that outputs logs with a message and key-value pairs.