Class: Groonga::QueryLog::Analyzer
- Inherits:
-
Object
- Object
- Groonga::QueryLog::Analyzer
- Includes:
- CommandLineUtils
- Defined in:
- lib/groonga/query-log/analyzer.rb,
lib/groonga/query-log/analyzer/reporter.rb,
lib/groonga/query-log/analyzer/streamer.rb,
lib/groonga/query-log/analyzer/statistic.rb,
lib/groonga/query-log/analyzer/reporter/html.rb,
lib/groonga/query-log/analyzer/reporter/json.rb,
lib/groonga/query-log/analyzer/reporter/console.rb,
lib/groonga/query-log/analyzer/sized-statistics.rb,
lib/groonga/query-log/analyzer/reporter/json-stream.rb,
lib/groonga/query-log/analyzer/sized-grouped-operations.rb
Defined Under Namespace
Classes: ConsoleReporter, Error, HTMLReporter, JSONReporter, JSONStreamReporter, NoInputError, Reporter, SizedGroupedOperations, SizedStatistics, Statistic, Streamer, UnsupportedReporter
Instance Method Summary collapse
-
#initialize ⇒ Analyzer
constructor
A new instance of Analyzer.
-
#run(arguments) ⇒ Object
Executes analyzer for groonga’s query logs.
Methods included from CommandLineUtils
#log_via_stdin?, #stdin_with_pipe?, #stdin_with_redirect?
Constructor Details
#initialize ⇒ Analyzer
Returns a new instance of Analyzer.
45 46 47 |
# File 'lib/groonga/query-log/analyzer.rb', line 45 def initialize end |
Instance Method Details
#run(arguments) ⇒ Object
Executes analyzer for groonga’s query logs. “groonga-query-log-analyze” command run this method.
If only paths of query log files are specified, this method prints a result of them to console with coloring.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/groonga/query-log/analyzer.rb', line 64 def run(arguments) log_paths = @option_parser.parse!(arguments) stream = @options[:stream] dynamic_sort = @options[:dynamic_sort] statistics = SizedStatistics.new statistics.(@options) if stream streamer = Streamer.new(create_reporter(statistics)) streamer.start process_statistic = lambda do |statistic| streamer << statistic end elsif dynamic_sort process_statistic = lambda do |statistic| statistics << statistic end else full_statistics = [] process_statistic = lambda do |statistic| full_statistics << statistic end end begin parse(log_paths, &process_statistic) rescue Interrupt raise unless stream end if stream streamer.finish else statistics.replace(full_statistics) unless dynamic_sort reporter = create_reporter(statistics) reporter.(@options) reporter.report end true end |