lib/shog/formatter.rb
# Re-format any log messages that match the given `pattern`.
#
# @overload match( pattern, proc)
#   @param [Regexp] pattern to match against the log message.
#   @param [#call(message,last_match)] proc a callable object that receives
#     the message and the last match and re-formats the message.
#
# @overload match( pattern )
#   @param [Regexp] pattern to match against the log message.
#   @yieldparam message [String] the matched log message.
#   @yieldparam last_match [MatchData] the regex matches.
#   @yieldreturn [String] the re-formatted message.
#
# @example
#   configure do
#     match /GET (?<address>.*)/ do |message,last_match|
#       "GETTING -> #{last_match['address'].green}"
#     end
#   end
# @return [Formatter] self.
Re-format any log messages that match the given `pattern`.
Re - format any log messages that match the given ` pattern ` .
def match( pattern, proc = nil, &block )
      proc ||= block
      configuration[:matchers][pattern] = proc
      self
    end
def match ( pattern , proc = nil , & block ) proc ||= block configuration [ :matchers ] [ pattern ] = proc self end
Re-format any log messages that match the given `pattern`.
Re - format any log messages that match the given ` pattern ` .
None
Formatter
pattern
<not_specific>
proc
<not_specific>
block
<not_specific>
overload
match( pattern, proc) @param [Regexp] pattern to match against the log message. @param [#call(message,last_match)] proc a callable object that receives the message and the last match and re-formats the message.
match ( pattern proc ) @param [ Regexp ] pattern to match against the log message . @param [ #call ( message last_match ) ] proc a callable object that receives the message and the last match and re - formats the message .
overload
match( pattern ) @param [Regexp] pattern to match against the log message. @yieldparam message [String] the matched log message. @yieldparam last_match [MatchData] the regex matches. @yieldreturn [String] the re-formatted message.
match ( pattern ) @param [ Regexp ] pattern to match against the log message . @yieldparam message [ String ] the matched log message . @yieldparam last_match [ MatchData ] the regex matches . @yieldreturn [ String ] the re - formatted message .
example
configure do match /GET (?.*)/ do |message,last_match| "GETTING -> #{last_match['address'].green}" end end
configure do match / GET ( ? . * ) / do |message last_match| " GETTING - > # { last_match [ ' address ' ] . green } " end end