Add more format directives here.
# File lib/log2counter/vendor/log_parser.rb, line 54 def initialize(name, format) @name, @format = name, format parse_format(format) end
The symbols are used to map the log to the env variables. The regex is used when checking what format the log is and to extract data.
# File lib/log2counter/vendor/log_parser.rb, line 61 def parse_format(format) format_directive = /%(.*?)(\{.*?\})?([#{[DIRECTIVES.keys.join('|')]}])([\s\"]*)/ log_format_symbols = [] format_regex = '' format.scan(format_directive) { |condition, subdirective, directive_char, ignored| log_format, match_regex = process_directive(directive_char, subdirective, condition) ignored.gsub!(/\s/, '\s') if ignored log_format_symbols << log_format format_regex << "(#{match_regex})#{ignored}" } @format_symbols = log_format_symbols @format_regex = /\A#{format_regex}/ end
# File lib/log2counter/vendor/log_parser.rb, line 80 def process_directive(directive_char, subdirective, condition) directive = DIRECTIVES[directive_char] case directive_char when 'i' log_format = subdirective[1...-1].downcase.tr('-', '_').to_sym [log_format, directive[1].source] else [directive[0], directive[1].source] end end