Parent

Class/Module Index [+]

Quicksearch

ViziLogFormat

ViziLogFormat

Author

Al Kivi <admin@viztrax.com>

License

MIT

Constants

DIRECTIVES

add more format directives here..

Attributes

format[R]
format_regex[R]
format_symbols[R]
name[R]

Public Class Methods

new(name, format) click to toggle source
# File lib/vizi/parser.rb, line 39
def initialize(name, format)

  @name, @format = name, format

  parse_format(format)

end

Public Instance Methods

parse_format(format) click to toggle source

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/vizi/parser.rb, line 46
def parse_format(format)

  format_directive = /%(.*?)(\{.*?\})?([#{[DIRECTIVES.keys.join('|')]}])([\s\\"]*)/

  log_format_symbols = []

  format_regex = ""

  format.scan(format_directive) do |condition, subdirective, directive_char, ignored|

    log_format, match_regex = process_directive(directive_char, subdirective, condition)

    ignored.gsub!(/\s/, '\s') unless ignored.nil?

    log_format_symbols << log_format

    format_regex << "(#{match_regex})#{ignored}"

  end

  @format_symbols = log_format_symbols

  @format_regex =  /^#{format_regex}/

end
process_directive(directive_char, subdirective, condition) click to toggle source
# File lib/vizi/parser.rb, line 60
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

[Validate]

Generated with the Darkfish Rdoc Generator 2.