multi_log_reader
Version, currently 0.1.03 versions
- 0.1.2latestAug 28, 2017
- 0.1.1not indexedAug 28, 2017
- 0.1.0not indexedAug 28, 2017
github.com/arcage/multi_log_reader
Concurrently reading multiple text files which are growing and may be rotated.
Nothing has been indexed for 0.1.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
multi_log_reader:
github: arcage/multi_log_reader
version: ~> 0.1.0Then run:
shards installshard.yml
No shard.yml has been indexed for 0.1.0. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
MultiLogReader for Crystal
Concurrently reading multiple text files which are growing and may be rotated, such as unix system log files.
This provides almost same functions as LogReader, but can read multiple files concurrently.
Of course, it works even with only one input file.
Installation
Add this to your application's shard.yml:
dependencies:
multi_log_reader:
github: arcage/multi_log_reader
Usage
require "multi_log_reader"
# puts lines from 2 input files.
MultiLogReader.new("a.log", "b.log").each do |line|
puts line
end
# expands file names from the patterns for `Dir.glob`
MultiLogReader.new("*.log", "*_log").each do |line|
puts line
end
For each input file:
- When the current file reaches EOF, this will wait new line added to the file. (like tail -f command)
- Even when the current file is rotated, this will trace new file and continue reading lines.
MultiLogReader#each will stop when all input files are missed. Here, "file is missed" means no readable file exists with given filename.
Except from avobe, it will continue to read new input.
If you want to stop it, you have to do that forcibly by using Ctrl+C, kill command etc.
Callbacks
You can set a Proc(String, Void) type callback by MultiLogReader.on_missing_file=.
Whenever one of the input files is missed, the proc will be called with file path string of that file.
Similarly, you can set a Proc(Void) type callback by MultiLogReader.on_missing_all=.
This proc will be called when all input files are missed(before exiting MultiLogReader#each).
require "multi_log_reader"
MultiLogReader.on_missing_file = ->(path : String) {
STDERR.puts "[MultiLogReader] Input file #{path} is gone."
}
MultiLogReader.on_missing_all = ->() {
STDERR.puts "[MultiLogReader] All input files are gone."
}
MultiLogReader.new("*_log").each do |line|
puts line
end
Contributors
- arcage ʕ·ᴥ·ʔAKJ - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.0- Tagged
- Aug 28, 2017
- Commit
66a6c46b0331- Indexed
- not yet
Dependents
No indexed shard depends on this one yet.
Repository
github.com/arcage/multi_log_reader
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 15, 2026
- Synced
- Aug 15, 2026
- Versions
- 3