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
(also: #directory)
Returns the value of attribute service_dir.
Instance Method Summary collapse
- #collect ⇒ Object
- #glob_pattern ⇒ Object
-
#initialize(dir = "/service") ⇒ Collector
constructor
A new instance of Collector.
- #logs ⇒ Object
Constructor Details
#initialize(dir = "/service") ⇒ Collector
Returns a new instance of Collector.
12 13 14 15 |
# File 'lib/djb/daemontools/multilog/collector.rb', line 12 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 Also known as: directory
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
29 30 31 32 33 34 35 36 |
# File 'lib/djb/daemontools/multilog/collector.rb', line 29 def collect all = logs.sort! do |a,b| a.time <=> b.time end # all[all.length - @lines..-1] lines = [@lines,all.length].min all[-lines..-1] end |
#glob_pattern ⇒ Object
17 18 19 |
# File 'lib/djb/daemontools/multilog/collector.rb', line 17 def glob_pattern @service_dir + "/*/log/main/current" end |
#logs ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/djb/daemontools/multilog/collector.rb', line 21 def logs all = Logs.new Dir.glob(glob_pattern).each do |file| all += Logs.new.load(file,@lines) end all end |