logging

package
v1.0.1-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: EPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BasenameControlPlane is the log file series for edgelet.service.
	BasenameControlPlane = "edgelet"
	// BasenameDataPlane is the log file series for edgelet-containerd.service.
	BasenameDataPlane = "edgelet-containerd"
)

Variables

This section is empty.

Functions

func DaemonLogBudgetMB

func DaemonLogBudgetMB(totalGiB float64, role SeriesRole, runtimeSplit bool) int

DaemonLogBudgetMB returns the MiB budget for one daemon log series. totalGiB is config logLimit; runtimeSplit applies the 60/40 split for embedded split mode.

func GetRotatingWriterLimits

func GetRotatingWriterLimits() (maxSize int64, maxBackups int, ok bool)

GetRotatingWriterLimits returns rotation caps for the daemon log writer, if present.

func InstanceConfigUpdated

func InstanceConfigUpdated(logDir string, maxFileSizeMB int, logFileCount int, logLevel string, basename ...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 LogError

func LogError(moduleName, msg string, err error)

LogError is a convenience function for error 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 RuntimeSplitFromEnv

func RuntimeSplitFromEnv() bool

RuntimeSplitFromEnv reports whether the control plane runs attach-only (EDGELET_RUNTIME_SPLIT=1).

func SetupLogger

func SetupLogger(logDir string, maxFileSizeMB int, logFileCount int, logLevel string, basename ...string) error

SetupLogger sets up the logger with file rotation and console output. Optional basename selects the log file series (default BasenameControlPlane).

func SetupMicroserviceLogger

func SetupMicroserviceLogger(microserviceUUID string, logDir string, maxFileSizeMB int, logFileCount int) error

SetupMicroserviceLogger sets up a logger for a specific microservice

func UpdateLoggerConfig

func UpdateLoggerConfig(_ string, maxFileSizeMB int, logFileCount int, logLevel string, _ ...string) error

UpdateLoggerConfig updates logger configuration without recreating the writer. This prevents log rotation on config reloads. Optional basename is ignored.

Types

type LogFormatter

type LogFormatter struct{}

LogFormatter formats log entries

func (*LogFormatter) Format

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

Format formats a log entry

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

func (*MicroserviceLogFormatter) Format

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

Format formats a microservice log entry

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) Debug

func (ml *ModuleLogger) Debug(msg string)

Debug logs a debug message

func (*ModuleLogger) Debugf

func (ml *ModuleLogger) Debugf(format string, args ...any)

Debugf logs a formatted debug message

func (*ModuleLogger) Error

func (ml *ModuleLogger) Error(msg string)

Error logs an error message

func (*ModuleLogger) Errorf

func (ml *ModuleLogger) Errorf(format string, args ...any)

Errorf logs a formatted error message

func (*ModuleLogger) Info

func (ml *ModuleLogger) Info(msg string)

Info logs an info message

func (*ModuleLogger) Infof

func (ml *ModuleLogger) Infof(format string, args ...any)

Infof logs a formatted info message

func (*ModuleLogger) Warn

func (ml *ModuleLogger) Warn(msg string)

Warn logs a warning 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)

func (*RotatingWriter) Close

func (w *RotatingWriter) Close() error

Close closes the file

func (*RotatingWriter) Limits

func (w *RotatingWriter) Limits() (maxSize int64, maxBackups int)

Limits returns the current rotation caps.

func (*RotatingWriter) SetLimits

func (w *RotatingWriter) SetLimits(maxSize int64, maxBackups int)

SetLimits updates rotation caps without rotating or reopening the active file.

func (*RotatingWriter) Write

func (w *RotatingWriter) Write(p []byte) (n int, err error)

Write writes p to the file

type SeriesRole

type SeriesRole int

SeriesRole identifies which daemon log series receives a budget share.

const (
	// SeriesControlPlane is edgelet.service (basename edgelet).
	SeriesControlPlane SeriesRole = iota
	// SeriesDataPlane is edgelet-containerd.service (basename edgelet-containerd).
	SeriesDataPlane
)

Jump to

Keyboard shortcuts

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