Class: GitlabBranchRename::LoggerConfigure

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab_branch_rename/logger_configure.rb

Class Method Summary collapse

Class Method Details

.configure(configuration) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/gitlab_branch_rename/logger_configure.rb', line 5

def self.configure(configuration)
  logger = Logger.new(STDOUT)
  logger.formatter = proc do |severity, datetime, progname, msg|
    date_format = datetime.to_datetime.strftime("%Q")
    output = nil
    color = :black
    case severity
    when "DEBUG"
      output = "D #{date_format} #{msg}\n"
      color = :light_black
    when "INFO"
      output = "I #{date_format} #{msg}\n"
      color = :black
    when "WARN"
      output = "W #{date_format} #{msg}\n"
      color = :yellow
    when "ERROR"
      output = "E #{date_format} #{msg}\n"
      color = :red
    else
      output = "? #{date_format} #{msg}\n"
    end
    if configuration.disable_color
      output
    else
      output.colorize(color)
    end
  end
  logger
end