class DopCommon::Cli::TraceFormatter

This adds code line context to the log output

Public Instance Methods

call(severity, datetime, progname, msg) click to toggle source
# File lib/dop_common/cli/log.rb, line 15
def call(severity, datetime, progname, msg)
  timestamp = datetime.strftime("%Y-%m-%d %H:%M:%S.%L")
  hostname = ::Socket.gethostname.split('.').first
  file, line, method = caller[11].sub(/.*\/([0-9a-zA-Z_\-.]+):(\d+):.+`(.+)'/, "\\1-\\2-\\3").gsub(":", " ").split("-")
  pid = "[#{::Process.pid}]".ljust(7)
  "#{timestamp} #{hostname} #{progname}#{pid} #{severity.ljust(5)} #{file}:#{line}:#{method}: #{msg2str(msg)}\n"
end