Class: HTMLProofer::Log
- Inherits:
-
Object
- Object
- HTMLProofer::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(log_level) ⇒ Log
constructor
A new instance of Log.
- #log(level, message) ⇒ Object
- #log_with_color(level, color, message) ⇒ Object
Constructor Details
#initialize(log_level) ⇒ Log
Returns a new instance of Log.
8 9 10 11 12 13 14 15 |
# File 'lib/html-proofer/log.rb', line 8 def initialize(log_level) @logger = Yell.new(:format => false, \ :name => 'HTMLProofer', \ :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
36 37 38 39 40 41 42 |
# File 'lib/html-proofer/log.rb', line 36 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
45 46 47 |
# File 'lib/html-proofer/log.rb', line 45 def debug( = nil) log(:debug, ) unless .nil? end |
#log(level, message) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/html-proofer/log.rb', line 17 def log(level, ) color = case level when :debug :light_blue when :info :blue when :warn :yellow when :error, :fatal :red end log_with_color(level, color, ) end |
#log_with_color(level, color, message) ⇒ Object
32 33 34 |
# File 'lib/html-proofer/log.rb', line 32 def log_with_color(level, color, ) @logger.send level, colorize(color, ) end |