class

Logarithm::LogSourceFactory

Inherits Reference < Object

Factory for creating and managing log sources based on configuration.

Centralizes log source creation logic, eliminating duplication between training and monitoring commands while providing a clean API for source selection and instantiation.

Available Source Types

  • JOURNALD: Reads from systemd journald
  • VARLOG: Reads from traditional syslog files

Usage

config = LogSourceFactory::Config.new(
  types: [LogSourceFactory::SourceType::JOURNALD, LogSourceFactory::SourceType::VARLOG],
  paths: ["/var/log/syslog"],
  since: "1 hour ago",
  read_existing: true,
  recursive: false
)

log_source = LogSourceFactory.create(config)
# Returns either a single source or MultiLogSource if multiple sources

Benefits

  • Eliminates code duplication between CLI commands
  • Provides type-safe source type enumeration
  • Centralizes path expansion and validation logic
  • Makes adding new log sources easier
  • Configuration-driven approach improves testability

Class methods

create(config : Config) : AbstractLogSource

Creates log sources based on configuration.

Returns a single AbstractLogSource if only one source type is specified, or a MultiLogSource if multiple source types are configured.

Parameters:

  • config: Configuration specifying which sources to create and how

Returns: Configured log source(s) ready for use

Raises: ValidationError if no sources are specified or configuration is invalid

Source

Nested types