Class: Stratagem::Logger
- Includes:
- Singleton
- Defined in:
- lib/stratagem/logger.rb
Defined Under Namespace
Classes: Message
Constant Summary collapse
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #debug(message) ⇒ Object
- #empty? ⇒ Boolean
- #error(exception) ⇒ Object
- #fatal(exception) ⇒ Object
-
#initialize ⇒ Logger
constructor
A new instance of Logger.
- #phase(phase) ⇒ Object
- #pop ⇒ Object
Constructor Details
#initialize ⇒ Logger
Returns a new instance of Logger.
15 16 17 |
# File 'lib/stratagem/logger.rb', line 15 def initialize @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (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() add(Message.new(@phase, Time.now, )) end |
#empty? ⇒ 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. 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. 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 |
#pop ⇒ Object
40 41 42 43 |
# File 'lib/stratagem/logger.rb', line 40 def pop @@blocker.wait if empty? MESSAGE_QUEUE.shift end |