logging

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package logging provides a simple logging infrastructure for the observability plugin It supports file-based logging with different levels and structured output

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(component, format string, args ...interface{})

Debug logs a debug message using the global logger

func Error

func Error(component, format string, args ...interface{})

Error logs an error message using the global logger

func Info

func Info(component, format string, args ...interface{})

Info logs an info message using the global logger

func SetGlobalLogger

func SetGlobalLogger(logger *Logger)

SetGlobalLogger sets the global logger instance

func Warn

func Warn(component, format string, args ...interface{})

Warn logs a warning message using the global logger

Types

type Config

type Config struct {
	LogFile      string `yaml:"logFile" json:"logFile"`
	Level        string `yaml:"level" json:"level"`
	Component    string `yaml:"component" json:"component"`
	LogToConsole bool   `yaml:"logToConsole" json:"logToConsole"`
}

Config contains logger configuration

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default logging configuration

type LogLevel

type LogLevel int

LogLevel represents the severity of a log message

const (
	// DEBUG is the debug log level.
	DEBUG LogLevel = iota
	// INFO is the info log level.
	INFO
	// WARN is the warning log level.
	WARN
	// ERROR is the error log level.
	ERROR
)

func (LogLevel) String

func (l LogLevel) String() string

String returns the string representation of a log level

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger provides structured logging for the observability plugin

func GetGlobalLogger

func GetGlobalLogger() *Logger

GetGlobalLogger returns the global logger instance, creating it if necessary

func NewLogger

func NewLogger(config Config) (*Logger, error)

NewLogger creates a new logger instance

func (*Logger) Close

func (l *Logger) Close() error

Close closes the logger and its file handle

func (*Logger) Component

func (l *Logger) Component(component string) *Logger

Component creates a new logger with a specific component name

func (*Logger) Debug

func (l *Logger) Debug(component, format string, args ...interface{})

Debug logs a debug message

func (*Logger) Error

func (l *Logger) Error(component, format string, args ...interface{})

Error logs an error message

func (*Logger) Info

func (l *Logger) Info(component, format string, args ...interface{})

Info logs an info message

func (*Logger) SetLevel

func (l *Logger) SetLevel(level LogLevel)

SetLevel changes the log level

func (*Logger) Warn

func (l *Logger) Warn(component, format string, args ...interface{})

Warn logs a warning message

Jump to

Keyboard shortcuts

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