Sha256: 60e6d2b401a4eb7094611c3432f18d5de7f4bb7d3c6493800b865ab4b4d8e3fb
Contents?: true
Size: 698 Bytes
Versions: 7
Compression:
Stored size: 698 Bytes
Contents
require 'logger' require 'time' module Pallets class Logger < ::Logger # Overwrite severity methods to add metadata capabilities %i[debug info warn error fatal unknown].each do |severity| define_method severity do |message, metadata = {}| return super(message) if metadata.empty? formatted_metadata = ' ' + metadata.map { |k, v| "#{k}=#{v}" }.join(' ') super(formatted_metadata) { message } end end module Formatters class Pretty < ::Logger::Formatter def call(severity, time, metadata, message) "#{time.utc.iso8601(4)} pid=#{Process.pid}#{metadata} #{severity}: #{message}\n" end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems