Logarithm::MultiLogSource
Inherits Logarithm::AbstractLogSource < Reference < Object
Composite log source that combines multiple log sources.
This class allows aggregating logs from multiple sources (journald, files, network streams, etc.) into a single unified stream. All sources run concurrently and their outputs are multiplexed into one channel.
Use Cases
- Multi-system monitoring: Combine logs from multiple servers
- Hybrid sources: Mix systemd journal with traditional syslog files
- Comprehensive coverage: Ensure no log sources are missed
- Load distribution: Distribute log processing across sources
Example Usage
# Combine journald and syslog files
journal_source = JournaldLogSource.new
file_source = VarlogLogSource.new(["/var/log/syslog", "/var/log/messages"])
multi_source = MultiLogSource.new([journal_source, file_source])
# Use like any other log source
channel = Channel(String).new(1000)
multi_source.start(channel)
# Logs from both sources flow through the same channel
Threading Behavior
Each source runs in its own background fibers. The MultiLogSource coordinates starting and stopping all sources simultaneously. Sources are independent and can fail without affecting others.
Error Handling
If individual sources fail during operation, they will log errors but won't stop other sources. The composite source continues operating with remaining healthy sources.
Constructors
Instance methods
Returns combined descriptions from all sources.
Returns: Flat array of all source descriptions for logging/auditing
Example: ["systemd journal", "/var/log/syslog", "/var/log/messages"]
Starts all log sources concurrently.
Each source begins reading in its own background fibers. All sources send their logs to the same shared channel.
Parameters:
- channel: Shared channel for all sources to send log lines to
Stops all log sources.
Signals all sources to stop reading and clean up resources. Blocks until all sources have completed shutdown.