Class: Rreplay::Debugger
- Inherits:
-
Object
- Object
- Rreplay::Debugger
- Defined in:
- lib/rreplay/debugger.rb
Instance Method Summary collapse
-
#initialize(logger, debug = true) ⇒ Debugger
constructor
A new instance of Debugger.
- #out(&block) ⇒ Object
Constructor Details
#initialize(logger, debug = true) ⇒ Debugger
Returns a new instance of Debugger.
3 4 5 6 |
# File 'lib/rreplay/debugger.rb', line 3 def initialize(logger, debug = true) @logger = logger @debug = !logger.nil? && debug end |
Instance Method Details
#out(&block) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rreplay/debugger.rb', line 8 def out(&block) return unless @debug msg = block.call.then do |msg| case msg when Hash msg.merge({ time: Time.now.iso8601 }).to_json else "#{Time.now.iso8601} - #{block.call}" end end @logger.write("#{msg}\n") end |