Module: Autoshell::Log
- Included in:
- Base
- Defined in:
- lib/autoshell/log.rb
Overview
Mixin for handling log stuff
Instance Attribute Summary collapse
-
#logger ⇒ Logger
Instance-specific logger.
Instance Method Summary collapse
-
#log_output(color: false) ⇒ String
Get the complete output of the log.
-
#log_reset ⇒ Object
Reset the log contents.
Instance Attribute Details
#logger ⇒ Logger
16 17 18 19 20 21 22 23 24 |
# File 'lib/autoshell/log.rb', line 16 def logger return @logger if defined? @logger @log_device = StringIO.new @logger = Logger.new(@log_device) @logger.level = LOG_LEVEL @logger.formatter = LOG_FORMATTER @logger end |
Instance Method Details
#log_output(color: false) ⇒ String
Get the complete output of the log
29 30 31 32 33 34 35 36 |
# File 'lib/autoshell/log.rb', line 29 def log_output(color: false) return unless defined? @log_device if color @log_device.string else ANSI.unansi(@log_device.string) end end |
#log_reset ⇒ Object
Reset the log contents
40 41 42 43 |
# File 'lib/autoshell/log.rb', line 40 def log_reset @log_device.truncate(0) if defined? @log_device self end |