Documentation
¶
Index ¶
- Constants
- Variables
- func AddPluginSearchPath(path string)
- func ClearRegisteredPlugins()
- func DiscoverAndLoadPlugins() error
- func LoadPlugin(path string) error
- func RegisterBackendPlugin(plugin plugins.BackendPlugin) error
- func RegisterFilterPlugin(plugin plugins.FilterPlugin) error
- func RegisterFormatterPlugin(plugin plugins.FormatterPlugin) error
- func RegisterPluginMetadata(metadata PluginMetadata)
- func SetPluginSearchPaths(paths []string)
- func UnloadPlugin(name string) error
- type Backend
- type BackendStats
- type DestinationInfo
- type DestinationInterface
- type FileBackend
- type FileBackendImpl
- func (fb *FileBackendImpl) Close() error
- func (fb *FileBackendImpl) Flush() error
- func (fb *FileBackendImpl) GetFile() *os.File
- func (fb *FileBackendImpl) GetLock() *flock.Flock
- func (fb *FileBackendImpl) GetSize() int64
- func (fb *FileBackendImpl) GetStats() BackendStats
- func (fb *FileBackendImpl) GetWriter() *bufio.Writer
- func (fb *FileBackendImpl) Path() string
- func (fb *FileBackendImpl) Rotate() error
- func (fb *FileBackendImpl) Size() int64
- func (fb *FileBackendImpl) SupportsAtomic() bool
- func (fb *FileBackendImpl) Sync() error
- func (fb *FileBackendImpl) Write(entry []byte) (int, error)
- type FileBackendWithRotation
- func (fb *FileBackendWithRotation) Close() error
- func (fb *FileBackendWithRotation) Flush() error
- func (fb *FileBackendWithRotation) GetFile() *os.File
- func (fb *FileBackendWithRotation) GetLock() *flock.Flock
- func (fb *FileBackendWithRotation) GetSize() int64
- func (fb *FileBackendWithRotation) GetStats() BackendStats
- func (fb *FileBackendWithRotation) GetWriter() *bufio.Writer
- func (fb *FileBackendWithRotation) Path() string
- func (fb *FileBackendWithRotation) Rotate() error
- func (fb *FileBackendWithRotation) SetErrorHandler(handler func(source, dest, msg string, err error))
- func (fb *FileBackendWithRotation) SetMaxRetries(retries int)
- func (fb *FileBackendWithRotation) Size() int64
- func (fb *FileBackendWithRotation) SupportsAtomic() bool
- func (fb *FileBackendWithRotation) Sync() error
- func (fb *FileBackendWithRotation) Write(entry []byte) (int, error)
- type PluginBackend
- type PluginBackendImpl
- func (pb *PluginBackendImpl) Close() error
- func (pb *PluginBackendImpl) Flush() error
- func (pb *PluginBackendImpl) GetConfig() map[string]interface{}
- func (pb *PluginBackendImpl) GetPlugin() plugins.BackendPlugin
- func (pb *PluginBackendImpl) GetStats() BackendStats
- func (pb *PluginBackendImpl) GetURI() string
- func (pb *PluginBackendImpl) Reset() error
- func (pb *PluginBackendImpl) SupportsAtomic() bool
- func (pb *PluginBackendImpl) Sync() error
- func (pb *PluginBackendImpl) Write(data []byte) (int, error)
- type PluginDiscovery
- func (pd *PluginDiscovery) AddSearchPath(path string)
- func (pd *PluginDiscovery) DiscoverPlugins() ([]string, error)
- func (pd *PluginDiscovery) LoadDiscoveredPlugins() error
- func (pd *PluginDiscovery) LoadPluginSpecs(specs []PluginSpec) error
- func (pd *PluginDiscovery) ScanForPluginConfigs() ([]string, error)
- func (pd *PluginDiscovery) SetPattern(pattern string)
- func (pd *PluginDiscovery) SetSearchPaths(paths []string)
- type PluginInfo
- type PluginManager
- func (pm *PluginManager) GetBackendPlugin(scheme string) (plugins.BackendPlugin, bool)
- func (pm *PluginManager) GetFilterPlugin(filterType string) (plugins.FilterPlugin, bool)
- func (pm *PluginManager) GetFormatterPlugin(format string) (plugins.FormatterPlugin, bool)
- func (pm *PluginManager) GetPluginInfo() []PluginInfo
- func (pm *PluginManager) InitializePlugin(name string, config map[string]interface{}) error
- func (pm *PluginManager) ListPlugins() []plugins.Plugin
- func (pm *PluginManager) LoadPlugin(path string) error
- func (pm *PluginManager) UnloadPlugin(name string) error
- type PluginMetadata
- type PluginRegistry
- type PluginSpec
- type SyslogBackend
- type SyslogBackendImpl
- func (sb *SyslogBackendImpl) Close() error
- func (sb *SyslogBackendImpl) Flush() error
- func (sb *SyslogBackendImpl) GetStats() BackendStats
- func (sb *SyslogBackendImpl) SetPriority(priority int)
- func (sb *SyslogBackendImpl) SetTag(tag string)
- func (sb *SyslogBackendImpl) SupportsAtomic() bool
- func (sb *SyslogBackendImpl) Sync() error
- func (sb *SyslogBackendImpl) Write(entry []byte) (int, error)
Constants ¶
const ( ErrCodeFileOpen = "file_open" ErrCodeFileLock = "file_lock" )
Error codes for backend operations
const DefaultBufferSize = 32 * 1024 // 32 KB - matching omni package default
DefaultBufferSize for file operations
Variables ¶
var (
ErrDestinationNotFound = fmt.Errorf("destination not found")
)
Variable aliases for easier access
Functions ¶
func AddPluginSearchPath ¶
func AddPluginSearchPath(path string)
AddPluginSearchPath adds a search path for the default discovery
func ClearRegisteredPlugins ¶
func ClearRegisteredPlugins()
ClearRegisteredPlugins clears all registered plugins (for testing only)
func DiscoverAndLoadPlugins ¶
func DiscoverAndLoadPlugins() error
DiscoverAndLoadPlugins discovers and loads plugins using the default discovery
func LoadPlugin ¶
LoadPlugin loads a plugin using the default plugin manager
func RegisterBackendPlugin ¶
func RegisterBackendPlugin(plugin plugins.BackendPlugin) error
RegisterBackendPlugin registers a backend plugin directly (for built-in plugins)
func RegisterFilterPlugin ¶
func RegisterFilterPlugin(plugin plugins.FilterPlugin) error
RegisterFilterPlugin registers a filter plugin directly
func RegisterFormatterPlugin ¶
func RegisterFormatterPlugin(plugin plugins.FormatterPlugin) error
RegisterFormatterPlugin registers a formatter plugin directly
func RegisterPluginMetadata ¶
func RegisterPluginMetadata(metadata PluginMetadata)
RegisterPluginMetadata registers plugin metadata in the default registry
func SetPluginSearchPaths ¶
func SetPluginSearchPaths(paths []string)
SetPluginSearchPaths sets search paths for the default discovery
func UnloadPlugin ¶
UnloadPlugin unloads a plugin using the default plugin manager
Types ¶
type Backend ¶
type Backend interface {
// Write writes a log entry to the backend
Write(entry []byte) (int, error)
// Flush ensures all buffered data is written
Flush() error
// Close closes the backend
Close() error
// SupportsAtomic returns whether the backend supports atomic writes
SupportsAtomic() bool
// Sync syncs the backend to persistent storage
Sync() error
// GetStats returns backend statistics
GetStats() BackendStats
}
Backend interface for pluggable log backends
type BackendStats ¶
type BackendStats struct {
Path string
Size int64
WriteCount uint64
BytesWritten uint64
ErrorCount uint64
LastError time.Time
TotalWriteTime time.Duration
MaxWriteTime time.Duration
}
BackendStats represents statistics for a backend
type DestinationInfo ¶
type DestinationInfo struct {
Name string
Type string
URI string
Enabled bool
BytesWritten uint64
Errors uint64
LastWrite time.Time
}
DestinationInfo provides information about a destination
type DestinationInterface ¶
type DestinationInterface interface {
// Write writes a log entry to the destination
Write(entry []byte) (int, error)
// Flush ensures all buffered data is written
Flush() error
// Close closes the destination
Close() error
// Info returns information about the destination
Info() DestinationInfo
}
DestinationInterface represents a log output destination
type FileBackend ¶
type FileBackend interface {
Backend
// Rotate rotates the log file
Rotate() error
// Size returns the current file size
Size() int64
// Path returns the file path
Path() string
// GetWriter returns the buffered writer
GetWriter() *bufio.Writer
}
FileBackend represents a file-based logging backend
type FileBackendImpl ¶
type FileBackendImpl struct {
// contains filtered or unexported fields
}
FileBackendImpl implements the Backend interface for file-based logging
func NewFileBackend ¶
func NewFileBackend(path string) (*FileBackendImpl, error)
NewFileBackend creates a new file backend
func (*FileBackendImpl) Close ¶
func (fb *FileBackendImpl) Close() error
Close closes the file backend
func (*FileBackendImpl) Flush ¶
func (fb *FileBackendImpl) Flush() error
Flush flushes buffered data to disk
func (*FileBackendImpl) GetFile ¶
func (fb *FileBackendImpl) GetFile() *os.File
GetFile returns the underlying file
func (*FileBackendImpl) GetLock ¶
func (fb *FileBackendImpl) GetLock() *flock.Flock
GetLock returns the file lock
func (*FileBackendImpl) GetSize ¶
func (fb *FileBackendImpl) GetSize() int64
GetSize returns the current file size
func (*FileBackendImpl) GetStats ¶
func (fb *FileBackendImpl) GetStats() BackendStats
GetStats returns backend statistics
func (*FileBackendImpl) GetWriter ¶
func (fb *FileBackendImpl) GetWriter() *bufio.Writer
GetWriter returns the buffered writer
func (*FileBackendImpl) Rotate ¶
func (fb *FileBackendImpl) Rotate() error
Rotate rotates the log file
func (*FileBackendImpl) Size ¶
func (fb *FileBackendImpl) Size() int64
Size returns the current file size
func (*FileBackendImpl) SupportsAtomic ¶
func (fb *FileBackendImpl) SupportsAtomic() bool
SupportsAtomic returns true as file backend supports atomic writes via locking
type FileBackendWithRotation ¶
type FileBackendWithRotation struct {
// contains filtered or unexported fields
}
FileBackendWithRotation extends FileBackendImpl with disk-full handling
func NewFileBackendWithRotation ¶
func NewFileBackendWithRotation(path string, rotMgr *features.RotationManager) (*FileBackendWithRotation, error)
NewFileBackendWithRotation creates a new file backend with rotation support
func (*FileBackendWithRotation) Close ¶
func (fb *FileBackendWithRotation) Close() error
Close closes the file backend
func (*FileBackendWithRotation) Flush ¶
func (fb *FileBackendWithRotation) Flush() error
Flush flushes buffered data to disk
func (*FileBackendWithRotation) GetFile ¶
func (fb *FileBackendWithRotation) GetFile() *os.File
GetFile returns the underlying file
func (*FileBackendWithRotation) GetLock ¶
func (fb *FileBackendWithRotation) GetLock() *flock.Flock
GetLock returns the file lock
func (*FileBackendWithRotation) GetSize ¶
func (fb *FileBackendWithRotation) GetSize() int64
GetSize returns the current file size
func (*FileBackendWithRotation) GetStats ¶
func (fb *FileBackendWithRotation) GetStats() BackendStats
GetStats returns backend statistics
func (*FileBackendWithRotation) GetWriter ¶
func (fb *FileBackendWithRotation) GetWriter() *bufio.Writer
GetWriter returns the buffered writer
func (*FileBackendWithRotation) Path ¶
func (fb *FileBackendWithRotation) Path() string
Path returns the file path
func (*FileBackendWithRotation) Rotate ¶
func (fb *FileBackendWithRotation) Rotate() error
Rotate manually rotates the log file
func (*FileBackendWithRotation) SetErrorHandler ¶
func (fb *FileBackendWithRotation) SetErrorHandler(handler func(source, dest, msg string, err error))
SetErrorHandler sets the error handler function
func (*FileBackendWithRotation) SetMaxRetries ¶
func (fb *FileBackendWithRotation) SetMaxRetries(retries int)
SetMaxRetries sets the maximum number of retries on disk full
func (*FileBackendWithRotation) Size ¶
func (fb *FileBackendWithRotation) Size() int64
Size returns the current file size
func (*FileBackendWithRotation) SupportsAtomic ¶
func (fb *FileBackendWithRotation) SupportsAtomic() bool
SupportsAtomic returns true as file backend supports atomic writes via locking
func (*FileBackendWithRotation) Sync ¶
func (fb *FileBackendWithRotation) Sync() error
Sync syncs the file to disk
type PluginBackend ¶
type PluginBackend interface {
Backend
// Name returns the plugin name
Name() string
// Version returns the plugin version
Version() string
// Configure configures the plugin with options
Configure(options map[string]interface{}) error
}
PluginBackend represents a plugin-based logging backend
type PluginBackendImpl ¶
type PluginBackendImpl struct {
// contains filtered or unexported fields
}
PluginBackendImpl implements the Backend interface using a plugin-provided backend
func NewPluginBackend ¶
func NewPluginBackend(plugin plugins.BackendPlugin, uri string, config map[string]interface{}) (*PluginBackendImpl, error)
NewPluginBackend creates a new plugin-based backend
func (*PluginBackendImpl) Close ¶
func (pb *PluginBackendImpl) Close() error
Close implements the Backend interface
func (*PluginBackendImpl) Flush ¶
func (pb *PluginBackendImpl) Flush() error
Flush implements the Backend interface
func (*PluginBackendImpl) GetConfig ¶
func (pb *PluginBackendImpl) GetConfig() map[string]interface{}
GetConfig returns the configuration used to create this backend
func (*PluginBackendImpl) GetPlugin ¶
func (pb *PluginBackendImpl) GetPlugin() plugins.BackendPlugin
GetPlugin returns the underlying plugin
func (*PluginBackendImpl) GetStats ¶
func (pb *PluginBackendImpl) GetStats() BackendStats
GetStats returns backend statistics
func (*PluginBackendImpl) GetURI ¶
func (pb *PluginBackendImpl) GetURI() string
GetURI returns the URI used to create this backend
func (*PluginBackendImpl) Reset ¶
func (pb *PluginBackendImpl) Reset() error
Reset implements the Backend interface
func (*PluginBackendImpl) SupportsAtomic ¶
func (pb *PluginBackendImpl) SupportsAtomic() bool
SupportsAtomic implements the Backend interface
func (*PluginBackendImpl) Sync ¶
func (pb *PluginBackendImpl) Sync() error
Sync syncs the backend (delegates to Flush for plugins)
type PluginDiscovery ¶
type PluginDiscovery struct {
// contains filtered or unexported fields
}
PluginDiscovery handles automatic plugin discovery and loading
func NewPluginDiscovery ¶
func NewPluginDiscovery(manager *PluginManager) *PluginDiscovery
NewPluginDiscovery creates a new plugin discovery instance
func (*PluginDiscovery) AddSearchPath ¶
func (pd *PluginDiscovery) AddSearchPath(path string)
AddSearchPath adds a search path
func (*PluginDiscovery) DiscoverPlugins ¶
func (pd *PluginDiscovery) DiscoverPlugins() ([]string, error)
DiscoverPlugins discovers plugins in search paths
func (*PluginDiscovery) LoadDiscoveredPlugins ¶
func (pd *PluginDiscovery) LoadDiscoveredPlugins() error
LoadDiscoveredPlugins discovers and loads all plugins
func (*PluginDiscovery) LoadPluginSpecs ¶
func (pd *PluginDiscovery) LoadPluginSpecs(specs []PluginSpec) error
LoadPluginSpecs loads plugins from specifications
func (*PluginDiscovery) ScanForPluginConfigs ¶
func (pd *PluginDiscovery) ScanForPluginConfigs() ([]string, error)
ScanForPluginConfigs scans for plugin configuration files
func (*PluginDiscovery) SetPattern ¶
func (pd *PluginDiscovery) SetPattern(pattern string)
SetPattern sets the file pattern for plugin files
func (*PluginDiscovery) SetSearchPaths ¶
func (pd *PluginDiscovery) SetSearchPaths(paths []string)
SetSearchPaths sets custom search paths
type PluginInfo ¶
type PluginInfo struct {
Name string `json:"name"`
Version string `json:"version"`
Type string `json:"type"`
Details map[string]interface{} `json:"details,omitempty"`
}
PluginInfo represents plugin information
type PluginManager ¶
type PluginManager struct {
// contains filtered or unexported fields
}
PluginManager manages loaded plugins
func GetPluginManager ¶
func GetPluginManager() *PluginManager
GetPluginManager returns the default plugin manager
func NewPluginManager ¶
func NewPluginManager() *PluginManager
NewPluginManager creates a new plugin manager
func (*PluginManager) GetBackendPlugin ¶
func (pm *PluginManager) GetBackendPlugin(scheme string) (plugins.BackendPlugin, bool)
GetBackendPlugin returns a backend plugin for the given scheme
func (*PluginManager) GetFilterPlugin ¶
func (pm *PluginManager) GetFilterPlugin(filterType string) (plugins.FilterPlugin, bool)
GetFilterPlugin returns a filter plugin for the given type
func (*PluginManager) GetFormatterPlugin ¶
func (pm *PluginManager) GetFormatterPlugin(format string) (plugins.FormatterPlugin, bool)
GetFormatterPlugin returns a formatter plugin for the given format
func (*PluginManager) GetPluginInfo ¶
func (pm *PluginManager) GetPluginInfo() []PluginInfo
GetPluginInfo returns information about loaded plugins
func (*PluginManager) InitializePlugin ¶
func (pm *PluginManager) InitializePlugin(name string, config map[string]interface{}) error
InitializePlugin initializes a plugin with configuration
func (*PluginManager) ListPlugins ¶
func (pm *PluginManager) ListPlugins() []plugins.Plugin
ListPlugins returns all loaded plugins
func (*PluginManager) LoadPlugin ¶
func (pm *PluginManager) LoadPlugin(path string) error
LoadPlugin loads a plugin from a shared library file
func (*PluginManager) UnloadPlugin ¶
func (pm *PluginManager) UnloadPlugin(name string) error
UnloadPlugin unloads a plugin by name
type PluginMetadata ¶
type PluginMetadata struct {
Name string `json:"name"`
Version string `json:"version"`
Description string `json:"description"`
Author string `json:"author"`
License string `json:"license"`
Dependencies []string `json:"dependencies,omitempty"`
Config map[string]interface{} `json:"config,omitempty"`
}
PluginMetadata represents plugin metadata
func GetPluginMetadata ¶
func GetPluginMetadata(name string) (PluginMetadata, bool)
GetPluginMetadata retrieves plugin metadata from the default registry
func ListPluginMetadata ¶
func ListPluginMetadata() []PluginMetadata
ListPluginMetadata returns all plugin metadata from the default registry
type PluginRegistry ¶
type PluginRegistry struct {
// contains filtered or unexported fields
}
PluginRegistry maintains a registry of available plugins
func NewPluginRegistry ¶
func NewPluginRegistry() *PluginRegistry
NewPluginRegistry creates a new plugin registry
func (*PluginRegistry) Get ¶
func (pr *PluginRegistry) Get(name string) (PluginMetadata, bool)
Get retrieves plugin metadata
func (*PluginRegistry) List ¶
func (pr *PluginRegistry) List() []PluginMetadata
List returns all registered plugin metadata
func (*PluginRegistry) Register ¶
func (pr *PluginRegistry) Register(metadata PluginMetadata)
Register registers plugin metadata
type PluginSpec ¶
type PluginSpec struct {
Name string `json:"name"`
Path string `json:"path,omitempty"`
URL string `json:"url,omitempty"`
Config map[string]interface{} `json:"config,omitempty"`
}
PluginSpec represents a plugin specification for automatic loading
type SyslogBackend ¶
type SyslogBackend interface {
Backend
// SetPriority sets the syslog priority
SetPriority(priority int)
// SetTag sets the syslog tag
SetTag(tag string)
}
SyslogBackend represents a syslog logging backend
type SyslogBackendImpl ¶
type SyslogBackendImpl struct {
// contains filtered or unexported fields
}
SyslogBackendImpl implements the Backend interface for syslog
func NewSyslogBackend ¶
func NewSyslogBackend(network, address string, priority int, tag string) (*SyslogBackendImpl, error)
NewSyslogBackend creates a new syslog backend
func (*SyslogBackendImpl) Close ¶
func (sb *SyslogBackendImpl) Close() error
Close closes the syslog connection
func (*SyslogBackendImpl) Flush ¶
func (sb *SyslogBackendImpl) Flush() error
Flush flushes buffered data
func (*SyslogBackendImpl) GetStats ¶
func (sb *SyslogBackendImpl) GetStats() BackendStats
GetStats returns backend statistics
func (*SyslogBackendImpl) SetPriority ¶
func (sb *SyslogBackendImpl) SetPriority(priority int)
SetPriority sets the syslog priority
func (*SyslogBackendImpl) SetTag ¶
func (sb *SyslogBackendImpl) SetTag(tag string)
SetTag sets the syslog tag
func (*SyslogBackendImpl) SupportsAtomic ¶
func (sb *SyslogBackendImpl) SupportsAtomic() bool
SupportsAtomic returns false as syslog doesn't support atomic writes
func (*SyslogBackendImpl) Sync ¶
func (sb *SyslogBackendImpl) Sync() error
Sync syncs the backend (flushes for syslog)