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.
10 11 12 13 14 15 16 17 |
# File 'lib/html-proofer/log.rb', line 10 def initialize(log_level) @logger = Yell.new(format: false, \ name: 'HTMLProofer', \ level: "gte.#{log_level}") do |l| l.adapter :stdout, level: %i[debug info warn] l.adapter :stderr, level: %i[error fatal] end end |
Instance Method Details
#colorize(color, message) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/html-proofer/log.rb', line 38 def colorize(color, ) if $stdout.isatty && $stderr.isatty Rainbow().send(color) else end end |
#debug(message = nil) ⇒ Object
dumb override to play nice with Typhoeus/Ethon
47 48 49 |
# File 'lib/html-proofer/log.rb', line 47 def debug( = nil) log(:debug, ) unless .nil? end |
#log(level, message) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/html-proofer/log.rb', line 19 def log(level, ) color = case level when :debug :cyan when :info :blue when :warn :yellow when :error, :fatal :red end log_with_color(level, color, ) end |
#log_with_color(level, color, message) ⇒ Object
34 35 36 |
# File 'lib/html-proofer/log.rb', line 34 def log_with_color(level, color, ) @logger.send level, colorize(color, ) end |