logreader
Version, currently 0.1.11 version
- 0.1.1latestJun 19, 2018
github.com/arcage/crystal-logreader
Reading lines in the text file which is growing and may be rotated, such as unix system log file.
Installation
# Add this to your shard.yml
dependencies:
logreader:
github: arcage/crystal-logreader
version: ~> 0.1.1Then run:
shards installshard.yml
- Crystal
0.25.0- License
- MIT
- Author
- ʕ·ᴥ·ʔAKJ
Dependencies
This version declares no dependencies.
README
LogReader
Reading lines in the text file which is growing and may be rotated, such as unix system log file.
- When the current file reaches EOF, this will wait new line added to the file. (like
tail -fcommand) - Even when the current file is rotated, this will trace new file and continue reading lines.
Installation
Add this to your application's shard.yml:
dependencies:
logreader:
github: arcage/crystal-logreader
Usage
require "logreader"
# create LogReader object
log = LogReader.new("/var/log/maillog")
# reads single line from the file
# waits new line, when the file reaches EOF
puts log.read_line
# iterates each line in the file
log.each do |line|
puts line
end
LogReader has only two public instance method #read_line and #each
#each will not finish in normal operation. if you want to stop it, you have to do it forcibly by using Ctrl+C, kill command etc.
Internal behaviour
When reading no data for reasons such as EOF, LogReader try to read more data every second.
For every consecutive 5 results that no data read, LogReader checks whether or not the inode number associated with the file name was changed.
If it had been changed, LogReader close current file and re-open the file.
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.1- Tagged
- Jun 19, 2018
- Commit
ec0d0d46d31c- Crystal
0.25.0- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/arcage/crystal-logreader
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 15, 2026
- Synced
- Aug 15, 2026
- Versions
- 1