Class: LogMagic::LogListener

Inherits:
Object
  • Object
show all
Defined in:
lib/log_magic/log_listener.rb

Instance Method Summary collapse

Constructor Details

#initialize(log_file_name) ⇒ LogListener

Returns a new instance of LogListener.



2
3
4
# File 'lib/log_magic/log_listener.rb', line 2

def initialize(log_file_name)
  @log_file_name = log_file_name
end

Instance Method Details

#listenObject



6
7
8
9
10
11
12
13
# File 'lib/log_magic/log_listener.rb', line 6

def listen
  File.open(@log_file_name) do |log|
    log.extend(File::Tail)
    log.interval = 1
    log.backward(1)
    log.tail { |line| yield line }
  end
end