class Guard::Dsl

def logger(options)

Options Hash: (**options)
  • except (Regexp) -- does not show messages from the matching
  • only (Regexp) -- show only messages from the matching Guard
  • time_format (String, Symbol) -- the time format
  • template (String) -- the logger template
  • level (String, Symbol) -- the log level

Parameters:
  • options (Hash) -- the log options

Other tags:
    Example: Log all but not the messages from a specific Guard plugin -
    Example: Limit logging to a Guard plugin -
    Example: Set a custom time format -
    Example: Set a custom log template -
    Example: Set the log level -
def logger(options)
  if options[:level]
    options[:level] = options[:level].to_sym
    unless [:debug, :info, :warn, :error].include? options[:level]
      UI.warning(format(WARN_INVALID_LOG_LEVEL, options[:level]))
      options.delete :level
    end
  end
  if options[:only] && options[:except]
    UI.warning WARN_INVALID_LOG_OPTIONS
    options.delete :only
    options.delete :except
  end
  # Convert the :only and :except options to a regular expression
  [:only, :except].each do |name|
    next unless options[name]
    list = [].push(options[name]).flatten.map do |plugin|
      Regexp.escape(plugin.to_s)
    end
    options[name] = Regexp.new(list.join("|"), Regexp::IGNORECASE)
  end
  UI.options = UI.options.merge(options)
end