Class: HTML::Proofer::Log
- Inherits:
-
Object
- Object
- HTML::Proofer::Log
- Includes:
- Yell::Loggable
- Defined in:
- lib/html/proofer/log.rb
Instance Method Summary collapse
- #colorize(color, message) ⇒ Object
-
#debug(message = nil) ⇒ Object
dumb override to play nice with Typhoeus/Ethon.
-
#initialize(verbose) ⇒ Log
constructor
A new instance of Log.
- #log(level, color, message) ⇒ Object
Constructor Details
#initialize(verbose) ⇒ Log
Returns a new instance of Log.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/html/proofer/log.rb', line 9 def initialize(verbose) log_level = verbose ? :debug : :info @logger = Yell.new(:format => false, \ :name => 'HTML::Proofer', \ :level => "gte.#{log_level}") do |l| l.adapter :stdout, :level => [:debug, :info, :warn] l.adapter :stderr, :level => [:error, :fatal] end end |
Instance Method Details
#colorize(color, message) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/html/proofer/log.rb', line 24 def colorize(color, ) if $stdout.isatty && $stderr.isatty Colored.colorize(, foreground: color) else end end |
#debug(message = nil) ⇒ Object
dumb override to play nice with Typhoeus/Ethon
33 34 35 |
# File 'lib/html/proofer/log.rb', line 33 def debug( = nil) log(:debug, :yellow, ) unless .nil? end |
#log(level, color, message) ⇒ Object
20 21 22 |
# File 'lib/html/proofer/log.rb', line 20 def log(level, color, ) @logger.send level, colorize(color, ) end |