Class: Huebot::Logging::CollectingLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/huebot/logging/collecting_logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCollectingLogger

Returns a new instance of CollectingLogger.



6
7
8
9
# File 'lib/huebot/logging/collecting_logger.rb', line 6

def initialize
  @events = []
  @mut = Mutex.new
end

Instance Attribute Details

#eventsObject (readonly)

Returns the value of attribute events.



4
5
6
# File 'lib/huebot/logging/collecting_logger.rb', line 4

def events
  @events
end

Instance Method Details

#log(event_type, data = {}) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/huebot/logging/collecting_logger.rb', line 11

def log(event_type, data = {})
  now = Time.now
  @mut.synchronize {
    @events << [now, event_type, data]
  }
  self
end