Module: DTK::Utils::Log

Defined in:
lib/utils/log.rb

Class Method Summary collapse

Class Method Details

.instanceObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/utils/log.rb', line 5

def self.instance
  @instance ||= Logger.new('/proc/1/fd/1', formatter: proc { |severity, datetime, progname, msg| 
    orange_color = "\x1b[33m"
    white_color = "\x1b[37m"
    red_color = "\x1b[31m"

    date_format = datetime.strftime("%Y-%m-%d %H:%M:%S:%L")
    if severity == "INFO"
      "#{orange_color}[#{date_format}] - #{white_color}#{msg}\n"
    elsif severity == "WARN"
      "#{orange_color}[#{date_format}] [WARNING] - #{msg}\n"
    elsif severity == "ERROR"       
        "#{red_color}[#{date_format}] [ERROR] - #{msg}\n"
    end
  })
end