Class: Gitlab::QA::SystemLogs::SystemLogsFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/qa/system_logs/system_logs_formatter.rb

Constant Summary collapse

NUM_OF_LOG_SECTIONS =
4

Instance Method Summary collapse

Constructor Details

#initialize(base_paths, correlation_id) ⇒ SystemLogsFormatter

Returns a new instance of SystemLogsFormatter.



9
10
11
12
# File 'lib/gitlab/qa/system_logs/system_logs_formatter.rb', line 9

def initialize(base_paths, correlation_id)
  @base_paths = base_paths
  @correlation_id = correlation_id
end

Instance Method Details

#system_logs_summary_markdownObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gitlab/qa/system_logs/system_logs_formatter.rb', line 14

def system_logs_summary_markdown
  log_sections = Array.new(NUM_OF_LOG_SECTIONS) { [] }

  @base_paths.each do |base_path|
    all_logs = [
      Finders::Rails::ApiLogFinder.new(base_path).find(@correlation_id),
      Finders::Rails::ExceptionLogFinder.new(base_path).find(@correlation_id),
      Finders::Rails::ApplicationLogFinder.new(base_path).find(@correlation_id),
      Finders::Rails::GraphqlLogFinder.new(base_path).find(@correlation_id)
    ]

    create_log_summary_sections!(all_logs, log_sections)
  end

  log_sections.prepend('### System Logs') unless log_sections.all?(&:empty?)
  log_sections.join("\n").rstrip
end