logging

package
v1.0.0-rc07 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package logging provides the global logging system for opencenter-cli.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActionLogWriter

func ActionLogWriter(ctx context.Context) io.Writer

ActionLogWriter retrieves the action log writer from the context, if set.

func Debug

func Debug(args ...interface{})

Debug logs a debug message.

func Debugf

func Debugf(format string, args ...interface{})

Debugf logs a formatted debug message.

func Error

func Error(args ...interface{})

Error logs an error message.

func Errorf

func Errorf(format string, args ...interface{})

Errorf logs a formatted error message.

func Fatal

func Fatal(args ...interface{})

Fatal logs a fatal message and exits.

func Fatalf

func Fatalf(format string, args ...interface{})

Fatalf logs a formatted fatal message and exits.

func GetGlobalLogger

func GetGlobalLogger() *logrus.Logger

GetGlobalLogger returns the global logger instance.

func Info

func Info(args ...interface{})

Info logs an info message.

func Infof

func Infof(format string, args ...interface{})

Infof logs a formatted info message.

func Initialize

func Initialize(config *LoggingConfig) error

Initialize initializes the global logging system with the given configuration.

func LogActionMessage

func LogActionMessage(ctx context.Context, format string, args ...interface{})

LogActionMessage writes a timestamped message to the action log writer in ctx, if present.

func SetGlobalLogger

func SetGlobalLogger(l *logrus.Logger)

SetGlobalLogger sets the global logger instance.

func SetLogFormat

func SetLogFormat(format string) error

SetLogFormat sets the log format for the global logger.

func SetLogLevel

func SetLogLevel(level string) error

SetLogLevel sets the log level for the global logger.

func ValidateLoggingConfig

func ValidateLoggingConfig(config *LoggingConfig) error

ValidateLoggingConfig validates the logging configuration.

func Warn

func Warn(args ...interface{})

Warn logs a warning message.

func Warnf

func Warnf(format string, args ...interface{})

Warnf logs a formatted warning message.

func WithActionLogWriter

func WithActionLogWriter(ctx context.Context, writer io.Writer) context.Context

WithActionLogWriter stores an io.Writer in the context for logging lifecycle command actions.

func WithField

func WithField(key string, value interface{}) *logrus.Entry

WithField creates a logger with a single field.

func WithFields

func WithFields(fields logrus.Fields) *logrus.Entry

WithFields creates a logger with multiple fields.

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.

func (*YAMLFormatter) Format

func (f *YAMLFormatter) Format(entry *logrus.Entry) ([]byte, error)

Format formats the log entry as YAML.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL