Module: GreenHat::SuperLog

Defined in:
lib/greenhat/thing/super_log.rb

Overview

Log Identifier

Class Method Summary collapse

Class Method Details

.api_json_format?(path) ⇒ Boolean

File Pattern Matching

Returns:

  • (Boolean)


33
34
35
# File 'lib/greenhat/thing/super_log.rb', line 33

def self.api_json_format?(path)
  ['rails_api_json_log'].any? { |x| path.include? x }
end

.dmesg_format?(path) ⇒ Boolean

Returns:

  • (Boolean)


82
83
84
85
86
# File 'lib/greenhat/thing/super_log.rb', line 82

def self.dmesg_format?(path)
  %w[
    dmesg
  ].any? { |x| path.include? x }
end

.json_format?(path) ⇒ Boolean

Returns:

  • (Boolean)


69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/greenhat/thing/super_log.rb', line 69

def self.json_format?(path)
  %w[
    production_json_log
    gitaly_current
    geo_log
    sidekiq_current
    sidekiq_log
    gitlab_shell_gitlab_shell_log
    gitlab_rails_audit_json_log
    gitlab_rails_application_json_log
  ].any? { |x| path.include? x }
end

.log?(kind) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/greenhat/thing/super_log.rb', line 6

def self.log?(kind)
  [
    'gitaly/current',
    'gitaly/gitaly_ruby_json.log',
    'gitlab-rails/api_json.log',
    'gitlab-rails/application_json.log',
    'gitlab-rails/audit_json.log',
    'gitlab-rails/graphql_json.log',
    'gitlab-rails/integrations_json.log',
    'gitlab-rails/production_json.log',
    'gitlab-rails/sidekiq_client.log',
    'gitlab-shell/gitlab-shell.log',
    'gitlab-workhorse/current',
    'puma/puma_stdout.log',
    'sidekiq/current',
    'gitlab-rails/importer.log',
    'gitlabsos.log',
    'nginx/gitlab_access.log',
    'patroni/current'
  ].any? { |x| x.include? kind.to_s }

  true
end

.reconfigure_format?(path) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
46
47
# File 'lib/greenhat/thing/super_log.rb', line 43

def self.reconfigure_format?(path)
  %w[
    reconfigure
  ].any? { |x| path.include? x }
end

.shellwords?(path) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
52
53
54
55
56
57
# File 'lib/greenhat/thing/super_log.rb', line 49

def self.shellwords?(path)
  %w[
    gitlab_pages_current
    alertmanager_current
    registry_current
    prometheus_current

  ].any? { |x| path.include? x }
end

.time_space?(path) ⇒ Boolean

Returns:

  • (Boolean)


59
60
61
62
63
64
65
66
67
# File 'lib/greenhat/thing/super_log.rb', line 59

def self.time_space?(path)
  %w[
    postgresql_current
    redis_current
    unicorn_current
    gitlab_monitor_current
    sidekiq_exporter_log
  ].any? { |x| path.include? x }
end

.type?(path) ⇒ Boolean

Identify Formatter

Returns:

  • (Boolean)


90
91
92
93
94
95
96
97
98
99
100
# File 'lib/greenhat/thing/super_log.rb', line 90

def self.type?(path)
  return :api_json_format if api_json_format?(path)
  return :unicorn_stderr_format if unicorn_stderr_format?(path)
  return :reconfigure_format if reconfigure_format?(path)
  return :shellwords if shellwords?(path)
  return :time_space if time_space?(path)
  return :json_format if json_format?(path)
  return :dmesg_format if dmesg_format?(path)

  nil
end

.unicorn_stderr_format?(path) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
40
41
# File 'lib/greenhat/thing/super_log.rb', line 37

def self.unicorn_stderr_format?(path)
  %w[
    unicorn_stderr
  ].any? { |x| path.include? x }
end