Class: Stratagem::Logger

Inherits:
Object show all
Includes:
Singleton
Defined in:
lib/stratagem/logger.rb

Defined Under Namespace

Classes: Message

Constant Summary collapse

MESSAGE_QUEUE =
[]
@@blocker =
Blocker.new()

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLogger

Returns a new instance of Logger.



15
16
17
# File 'lib/stratagem/logger.rb', line 15

def initialize
  @errors = []
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



13
14
15
# File 'lib/stratagem/logger.rb', line 13

def errors
  @errors
end

Instance Method Details

#debug(message) ⇒ Object



23
24
25
# File 'lib/stratagem/logger.rb', line 23

def debug(message)
  add(Message.new(@phase, Time.now, message))
end

#empty?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/stratagem/logger.rb', line 45

def empty?
  MESSAGE_QUEUE.size == 0
end

#error(exception) ⇒ Object



27
28
29
30
31
# File 'lib/stratagem/logger.rb', line 27

def error(exception)
  puts exception.message
  puts exception.backtrace
  @errors << create_error(exception)
end

#fatal(exception) ⇒ Object



33
34
35
36
37
38
# File 'lib/stratagem/logger.rb', line 33

def fatal(exception)
  puts exception.message
  puts exception.backtrace
  @errors << create_error(exception)
  # add(Message.new(@phase, Time.now, $!.message))
end

#phase(phase) ⇒ Object



19
20
21
# File 'lib/stratagem/logger.rb', line 19

def phase(phase)
  @phase = phase
end

#popObject



40
41
42
43
# File 'lib/stratagem/logger.rb', line 40

def pop
  @@blocker.wait if empty?
  MESSAGE_QUEUE.shift
end