Class: Flamingo::Logging::EventLog

Inherits:
Object
  • Object
show all
Defined in:
lib/flamingo/logging/event_log.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir, size = 10000) ⇒ EventLog

Returns a new instance of EventLog.



7
8
9
10
11
12
13
14
15
# File 'lib/flamingo/logging/event_log.rb', line 7

def initialize(dir,size=10000)
  self.dir = dir
  self.max_size = size
  @rotations = 0
  rotate!
  unless open?
    raise "Failure opening log file"
  end
end

Instance Attribute Details

#dirObject

Returns the value of attribute dir.



5
6
7
# File 'lib/flamingo/logging/event_log.rb', line 5

def dir
  @dir
end

#max_sizeObject

Returns the value of attribute max_size.



5
6
7
# File 'lib/flamingo/logging/event_log.rb', line 5

def max_size
  @max_size
end

Instance Method Details

#append(event) ⇒ Object Also known as: <<



17
18
19
20
21
22
23
# File 'lib/flamingo/logging/event_log.rb', line 17

def append(event)
  if should_rotate?
    rotate!
  end
  @log << "#{event}\n"
  @event_count += 1
end

#open?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/flamingo/logging/event_log.rb', line 26

def open?
  !@log.nil?
end