Class: Djb::Daemontools::Multilog::Collector
- Inherits:
-
Object
- Object
- Djb::Daemontools::Multilog::Collector
- Defined in:
- lib/djb/daemontools/multilog/collector.rb
Instance Attribute Summary collapse
-
#lines ⇒ Object
Returns the value of attribute lines.
-
#service_dir ⇒ Object
Returns the value of attribute service_dir.
Instance Method Summary collapse
- #collect ⇒ Object
-
#initialize(dir = "/service") ⇒ Collector
constructor
A new instance of Collector.
Constructor Details
#initialize(dir = "/service") ⇒ Collector
Returns a new instance of Collector.
11 12 13 14 |
# File 'lib/djb/daemontools/multilog/collector.rb', line 11 def initialize(dir = "/service") @lines = 100 @service_dir = dir end |
Instance Attribute Details
#lines ⇒ Object
Returns the value of attribute lines.
8 9 10 |
# File 'lib/djb/daemontools/multilog/collector.rb', line 8 def lines @lines end |
#service_dir ⇒ Object
Returns the value of attribute service_dir.
8 9 10 |
# File 'lib/djb/daemontools/multilog/collector.rb', line 8 def service_dir @service_dir end |
Instance Method Details
#collect ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/djb/daemontools/multilog/collector.rb', line 16 def collect all = Logs.new glob_pattern = @service_dir + "/*/log/main/current" Dir.glob(glob_pattern).each do |file| all += Logs.new.load(file,@lines) end all.sort! do |a,b| a.time <=> b.time end all[-@lines..-1] end |