Documentation
¶
Overview ¶
Package logging provides the global logging system for opencenter-cli.
Index ¶
- func ActionLogWriter(ctx context.Context) io.Writer
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func GetGlobalLogger() *logrus.Logger
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func Initialize(config *LoggingConfig) error
- func LogActionMessage(ctx context.Context, format string, args ...interface{})
- func SetGlobalLogger(l *logrus.Logger)
- func SetLogFormat(format string) error
- func SetLogLevel(level string) error
- func ValidateLoggingConfig(config *LoggingConfig) error
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- func WithActionLogWriter(ctx context.Context, writer io.Writer) context.Context
- func WithField(key string, value interface{}) *logrus.Entry
- func WithFields(fields logrus.Fields) *logrus.Entry
- type FileConfig
- type LoggerManager
- type LoggingConfig
- type YAMLFormatter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActionLogWriter ¶
ActionLogWriter retrieves the action log writer from the context, if set.
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf logs a formatted debug message.
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf logs a formatted error message.
func Fatalf ¶
func Fatalf(format string, args ...interface{})
Fatalf logs a formatted fatal message and exits.
func GetGlobalLogger ¶
GetGlobalLogger returns the global logger instance.
func Initialize ¶
func Initialize(config *LoggingConfig) error
Initialize initializes the global logging system with the given configuration.
func LogActionMessage ¶
LogActionMessage writes a timestamped message to the action log writer in ctx, if present.
func SetGlobalLogger ¶
SetGlobalLogger sets the global logger instance.
func SetLogFormat ¶
SetLogFormat sets the log format for the global logger.
func SetLogLevel ¶
SetLogLevel sets the log level for the global logger.
func ValidateLoggingConfig ¶
func ValidateLoggingConfig(config *LoggingConfig) error
ValidateLoggingConfig validates the logging configuration.
func WithActionLogWriter ¶
WithActionLogWriter stores an io.Writer in the context for logging lifecycle command actions.
Types ¶
type FileConfig ¶
type FileConfig struct {
MaxSize int `yaml:"maxSize"`
MaxBackups int `yaml:"maxBackups"`
MaxAge int `yaml:"maxAge"`
Compress bool `yaml:"compress"`
}
FileConfig controls file logging rotation settings.
type LoggerManager ¶
type LoggerManager struct {
// contains filtered or unexported fields
}
LoggerManager manages the logging configuration and setup.
func NewLoggerManager ¶
func NewLoggerManager(config *LoggingConfig) (*LoggerManager, error)
NewLoggerManager creates a new logger manager with the given configuration.
func (*LoggerManager) Configure ¶
func (lm *LoggerManager) Configure() error
Configure configures the logger based on the logging configuration.
func (*LoggerManager) GetLogger ¶
func (lm *LoggerManager) GetLogger() *logrus.Logger
GetLogger returns the configured logger instance.
func (*LoggerManager) Reconfigure ¶
func (lm *LoggerManager) Reconfigure(config *LoggingConfig) error
Reconfigure reconfigures the logger with new settings.
type LoggingConfig ¶
type LoggingConfig struct {
Level string `yaml:"level"`
Format string `yaml:"format"`
Output string `yaml:"output"`
File FileConfig `yaml:"file"`
}
LoggingConfig controls logging behavior including level, format, output, and file rotation.
type YAMLFormatter ¶
type YAMLFormatter struct{}
YAMLFormatter is a custom formatter that outputs logs in YAML format.