class LogLineParser::CommandLineInterface::Filter
Constants
- OptionValues
Public Instance Methods
execute(options)
click to toggle source
# File lib/log_line_parser/command_line_interface.rb, line 51 def execute(options) opt = option_values(options) Utils.open_multiple_output_files(opt.output_log_names, opt.output_dir) do |logs| queries = setup_queries_from_configs(opt.configs, logs, opt.bots_re) LogLineParser.each_record(error_output: opt.error_log || STDERR, parser: opt.log_format) do |line, record| queries.each {|query| query.call(line, record) } end end ensure opt.error_log.close if opt.error_log end
Private Instance Methods
collect_output_log_names(configs)
click to toggle source
# File lib/log_line_parser/command_line_interface.rb, line 79 def collect_output_log_names(configs) configs.map do |config| config[Query::ConfigFields::OUTPUT_LOG_NAME] end end
open_error_log(log_file)
click to toggle source
# File lib/log_line_parser/command_line_interface.rb, line 91 def open_error_log(log_file) open(File.expand_path(log_file), "wb") if log_file end
option_values(options)
click to toggle source
# File lib/log_line_parser/command_line_interface.rb, line 67 def option_values(options) configs = Utils.load_config_file(options[:config_file]) bots_re = Utils.compile_bots_re_from_config_file(options[:bots_config_file]) error_log = open_error_log(options[:error_log_file]) OptionValues.new(configs, bots_re, collect_output_log_names(configs), options[:output_dir], options[:log_format], error_log) end
setup_queries_from_configs(configs, logs, bots_re)
click to toggle source
# File lib/log_line_parser/command_line_interface.rb, line 85 def setup_queries_from_configs(configs, logs, bots_re) configs.map do |config| Query.register_query_to_log(config, logs, bots_re) end end