Class: Plextail::Tracker
- Inherits:
-
Object
- Object
- Plextail::Tracker
- Defined in:
- lib/plextail/tracker.rb
Constant Summary collapse
- URL =
ENV['LOGPLEX_URI'] || 'https://east.logplex.io'
Instance Method Summary collapse
-
#initialize(*glob) ⇒ Tracker
constructor
A new instance of Tracker.
- #pipe(&block) ⇒ Object
Constructor Details
#initialize(*glob) ⇒ Tracker
Returns a new instance of Tracker.
7 8 9 |
# File 'lib/plextail/tracker.rb', line 7 def initialize(*glob) @glob = File.join *glob end |
Instance Method Details
#pipe(&block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/plextail/tracker.rb', line 11 def pipe(&block) file = Dir[glob].first PTY.spawn("tail -f #{glob}") do |stdin, stdout, pid| stdin.each do |string| string.strip! if string[/^==> (.+) <==$/] file = $1 elsif string.length > 0 line = Plextail::Line.new file, string block.call line to_plex line end end end rescue PTY::ChildExited puts "The child process exited!" end |