Class: PrettyFormatter::Formatter

Inherits:
Logger::Formatter
  • Object
show all
Defined in:
lib/pretty_formatter.rb

Constant Summary collapse

@@severity_cache =
{}
@@pid =
$$
@@color =
ActiveSupport::LogSubscriber.colorize_logging
@@hostname =
get_hostname

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.get_hostnameObject



33
34
35
# File 'lib/pretty_formatter.rb', line 33

def self.get_hostname
  `hostname -s`.strip
end

Instance Method Details

#call(severity, timestamp, progname, msg) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/pretty_formatter.rb', line 20

def call(severity, timestamp, progname, msg)
  message = String === msg ? msg : msg.inspect
  full_message = ''

  unless (message.start_with?('Started GET "/assets') || !message.present?) && ::PrettyFormatter.suppress_noise
    prefix, time = ::PrettyFormatter.verbose ? [prefix_string, "#{Time.now.iso8601(5)} "] : ['', '']

    full_message = "#{prefix}#{time}#{severity_color(severity)} #{message}\n"
  end

  full_message
end