Documentation
¶
Index ¶
- func InstanceConfigUpdated(logDir string, maxFileSizeMB int, logFileCount int, logLevel string) error
- func LogDebug(moduleName, msg string)
- func LogError(moduleName, msg string, err error)
- func LogInfo(moduleName, msg string)
- func LogWarn(moduleName, msg string)
- func SetupLogger(logDir string, maxFileSizeMB int, logFileCount int, logLevel string) error
- func SetupMicroserviceLogger(microserviceUUID string, logDir string, maxFileSizeMB int, logFileCount int) error
- func UpdateLoggerConfig(_ string, _ int, _ int, logLevel string) error
- type LogFormatter
- type Logger
- type LogrusLogger
- func (l *LogrusLogger) Debug(moduleName, msg string)
- func (l *LogrusLogger) Error(moduleName, msg string, err error)
- func (l *LogrusLogger) GetLevel() logrus.Level
- func (l *LogrusLogger) Info(moduleName, msg string)
- func (l *LogrusLogger) LogWithFields(level, moduleName, msg string, fields map[string]any, err error)
- func (l *LogrusLogger) SetLevel(level string)
- func (l *LogrusLogger) Warn(moduleName, msg string)
- type MicroserviceLogFormatter
- type MicroserviceLogger
- type ModuleLogger
- func (ml *ModuleLogger) Debug(msg string)
- func (ml *ModuleLogger) Debugf(format string, args ...any)
- func (ml *ModuleLogger) Error(msg string)
- func (ml *ModuleLogger) Errorf(format string, args ...any)
- func (ml *ModuleLogger) Info(msg string)
- func (ml *ModuleLogger) Infof(format string, args ...any)
- func (ml *ModuleLogger) Warn(msg string)
- func (ml *ModuleLogger) Warnf(format string, args ...any)
- type RotatingWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InstanceConfigUpdated ¶
func InstanceConfigUpdated(logDir string, maxFileSizeMB int, logFileCount int, logLevel string) error
InstanceConfigUpdated updates the logger with updated configuration which reuses existing FileHandler
func LogDebug ¶
func LogDebug(moduleName, msg string)
LogDebug is a convenience function for debug logging
func LogInfo ¶
func LogInfo(moduleName, msg string)
LogInfo is a convenience function for info logging
func LogWarn ¶
func LogWarn(moduleName, msg string)
LogWarn is a convenience function for warning logging
func SetupLogger ¶
SetupLogger sets up the logger with file rotation and console output
Types ¶
type Logger ¶
type Logger interface {
Debug(moduleName, msg string)
Info(moduleName, msg string)
Warn(moduleName, msg string)
Error(moduleName, msg string, err error)
SetLevel(level string)
GetLevel() logrus.Level
}
Logger is the main logger interface
type LogrusLogger ¶
type LogrusLogger struct {
// contains filtered or unexported fields
}
LogrusLogger wraps logrus.Logger with module support
func GetInstance ¶
func GetInstance() *LogrusLogger
GetInstance returns the singleton logger instance
func (*LogrusLogger) Debug ¶
func (l *LogrusLogger) Debug(moduleName, msg string)
Debug logs a debug message
func (*LogrusLogger) Error ¶
func (l *LogrusLogger) Error(moduleName, msg string, err error)
Error logs an error message
func (*LogrusLogger) GetLevel ¶
func (l *LogrusLogger) GetLevel() logrus.Level
GetLevel returns the current log level
func (*LogrusLogger) Info ¶
func (l *LogrusLogger) Info(moduleName, msg string)
Info logs an info message
func (*LogrusLogger) LogWithFields ¶
func (l *LogrusLogger) LogWithFields(level, moduleName, msg string, fields map[string]any, err error)
LogWithFields logs a message with structured fields as top-level JSON keys (enterprise SIEM). level is one of: debug, info, warn, error.
func (*LogrusLogger) SetLevel ¶
func (l *LogrusLogger) SetLevel(level string)
SetLevel sets the log level logrus expects lowercase level names (e.g., "debug", "info"), but config stores uppercase
func (*LogrusLogger) Warn ¶
func (l *LogrusLogger) Warn(moduleName, msg string)
Warn logs a warning message
type MicroserviceLogFormatter ¶
type MicroserviceLogFormatter struct{}
MicroserviceLogFormatter formats log entries for microservices
type MicroserviceLogger ¶
type MicroserviceLogger struct {
// contains filtered or unexported fields
}
MicroserviceLogger manages loggers for individual microservices
func GetMicroserviceLoggerInstance ¶
func GetMicroserviceLoggerInstance() *MicroserviceLogger
GetMicroserviceLoggerInstance returns the singleton microservice logger instance
func (*MicroserviceLogger) LogError ¶
func (ml *MicroserviceLogger) LogError(microserviceUUID, msg string, err error) bool
LogError logs an error message for a microservice
func (*MicroserviceLogger) LogInfo ¶
func (ml *MicroserviceLogger) LogInfo(microserviceUUID, msg string) bool
LogInfo logs an info message for a microservice
func (*MicroserviceLogger) LogWarn ¶
func (ml *MicroserviceLogger) LogWarn(microserviceUUID, msg string) bool
LogWarn logs a warning message for a microservice
type ModuleLogger ¶
type ModuleLogger struct {
// contains filtered or unexported fields
}
ModuleLogger is a simple wrapper for module-specific logging
func NewModuleLogger ¶
func NewModuleLogger(moduleName string) *ModuleLogger
NewModuleLogger creates a new ModuleLogger for a specific module
func (*ModuleLogger) Debugf ¶
func (ml *ModuleLogger) Debugf(format string, args ...any)
Debugf logs a formatted debug message
func (*ModuleLogger) Errorf ¶
func (ml *ModuleLogger) Errorf(format string, args ...any)
Errorf logs a formatted error message
func (*ModuleLogger) Infof ¶
func (ml *ModuleLogger) Infof(format string, args ...any)
Infof logs a formatted info message
func (*ModuleLogger) Warnf ¶
func (ml *ModuleLogger) Warnf(format string, args ...any)
Warnf logs a formatted warning message
type RotatingWriter ¶
type RotatingWriter struct {
// contains filtered or unexported fields
}
RotatingWriter implements io.WriteCloser with file rotation It maintains edgelet.0.log as the active file and rotates to .1.log, .2.log, etc.
func NewRotatingWriter ¶
func NewRotatingWriter(dir, filename string, maxSize int64, maxBackups int, rotateOnExisting bool) (*RotatingWriter, error)
NewRotatingWriter creates a new RotatingWriter rotateOnExisting: if true, rotate the log file if it already exists and has content (agent restart)
if false, append to existing file without rotation (config reload)