Module: Helpers::Log
- Included in:
- AnsibleSpecPlus
- Defined in:
- lib/helpers/log.rb
Class Method Summary collapse
- .debug? ⇒ Boolean
- .included(base) ⇒ Object
- .last_messages ⇒ Object
- .log ⇒ Object
- .log=(logger) ⇒ Object
- .set_debug(debug, level = ::Logger::INFO) ⇒ Object
Instance Method Summary collapse
- #debug? ⇒ Boolean
- #last_messages ⇒ Object
- #log ⇒ Object
- #log=(logger) ⇒ Object
- #set_debug(debug, level = ::Logger::INFO) ⇒ Object
Class Method Details
.debug? ⇒ Boolean
21 22 23 |
# File 'lib/helpers/log.rb', line 21 def debug? !@no_debug end |
.included(base) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/helpers/log.rb', line 36 def self.included(base) class << base def log Log.log end def log=(logger) Log.log=(logger) end def debug? Log.debug? end def set_debug(debug, level = Logger::INFO) Log.set_debug(debug, level) end def Log. end end end |
.last_messages ⇒ Object
30 31 32 33 |
# File 'lib/helpers/log.rb', line 30 def return [] unless @logger @logger. end |
.log ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/helpers/log.rb', line 8 def log unless @logger @logger = BufferedLogger.new($stdout) @logger.formatter = ColorFormatter.new if $stdout.tty? end @logger end |
.log=(logger) ⇒ Object
16 17 18 19 |
# File 'lib/helpers/log.rb', line 16 def log=(logger) @logger = logger log.info('changed logger') end |
.set_debug(debug, level = ::Logger::INFO) ⇒ Object
25 26 27 28 |
# File 'lib/helpers/log.rb', line 25 def set_debug(debug, level = ::Logger::INFO) @no_debug = !debug log.level = level end |