Sha256: f6963850227c782db7fe4d1eac36e5a598c62813ec5a8f6961dd73ac14585568

Contents?: true

Size: 746 Bytes

Versions: 1

Compression:

Stored size: 746 Bytes

Contents

Logger::SimpleFormatter.class_eval do
  def call(severity, time, progname, msg)
    # generate the info part of the line
    lead_string = "[#{time.strftime('%Y-%m-%d %H:%M:%S.%L')}] [" + sprintf("%-5s","#{severity}") + "]"
    lead_string = lead_string + " [#{progname}]" unless progname.nil? or progname.empty?

    # figure out how far it needs to be indented
    # add +1 because we manually insert a space when outputting the message
    indent = "".rjust(lead_string.length+1)

    # use the logger default method to prepare the message for output
    msg = msg2str(msg)

    # indent all subsequent lines to help with readability
    msg.gsub!( /([\r\n]+)/, "\\1#{indent}") if msg.respond_to? :gsub

    "#{lead_string} #{msg}\n"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
erp_tech_svcs-4.2.0 config/initializers/logger.rb