module Snapcrawl::LogHelpers
Constants
- SEVERITY_COLORS
Public Instance Methods
log_formatter()
click to toggle source
# File lib/snapcrawl/log_helpers.rb, line 15 def log_formatter proc do |severity, _time, _prog, message| severity_color = SEVERITY_COLORS[severity] line = "!#{severity_color}!#{severity.rjust 5}!txtrst! : #{message}\n" use_colors? ? colorize(line) : strip_color_markers(line) end end
strip_color_markers(text)
click to toggle source
# File lib/snapcrawl/log_helpers.rb, line 31 def strip_color_markers(text) text.gsub(/\!([a-z]{6})\!/, '') end
tty?()
click to toggle source
# File lib/snapcrawl/log_helpers.rb, line 27 def tty? ENV['TTY'] == 'on' ? true : ENV['TTY'] == 'off' ? false : $stdout.tty? end
use_colors?()
click to toggle source
# File lib/snapcrawl/log_helpers.rb, line 23 def use_colors? @use_colors ||= (Config.log_color == 'auto' ? tty? : Config.log_color) end