Class: DLogReader::RotatingLog

Inherits:
Selector
  • Object
show all
Defined in:
lib/distributed_logreader/selector/rotating_log.rb

Overview

This class chooses the oldest log file in the directory that matches the input filename. This should work with a variety of log rotating schemes: including copytruncate and date suffix.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRotatingLog

Returns a new instance of RotatingLog.



9
10
11
12
13
# File 'lib/distributed_logreader/selector/rotating_log.rb', line 9

def initialize
  self.ignore_conditions = []
  self.ignore_conditions << lambda{|x| symlink_file_in_dir?(x)}
  # self.ignore_conditions << lambda{|x| true}
end

Instance Attribute Details

#ignore_conditionsObject

Returns the value of attribute ignore_conditions.



7
8
9
# File 'lib/distributed_logreader/selector/rotating_log.rb', line 7

def ignore_conditions
  @ignore_conditions
end

Instance Method Details

#file_to_process(file_or_dir) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/distributed_logreader/selector/rotating_log.rb', line 15

def file_to_process(file_or_dir)
  if File.directory?(file_or_dir)
    directory = file_or_dir
    basename = '/'
  else
    directory = File.dirname(file_or_dir)
    basename = File.basename(file_or_dir)
  end    
  oldest_logfile(directory, basename)
end