class Rory::Logger
Public Class Methods
new(io, options={})
click to toggle source
Calls superclass method
# File lib/rory/logger.rb, line 6 def initialize(io, options={}) super(io) @default_formatter = Formatter.new @tagged = options.fetch(:tagged, [:request_id]) end
Public Instance Methods
<<(msg)
click to toggle source
Calls superclass method
# File lib/rory/logger.rb, line 12 def <<(msg) super([tagged, msg].reject(&:empty?).join(" ")) end
Also aliased as: write
request_id()
click to toggle source
# File lib/rory/logger.rb, line 18 def request_id Thread.current.get_inheritable_attribute(:rory_request_id) end
tagged()
click to toggle source
# File lib/rory/logger.rb, line 22 def tagged @tagged.map do |key| "#{key}=#{quoted_string(public_send(key))}" end.join(" ").rstrip end
Private Instance Methods
format_message(severity, datetime, progname, msg)
click to toggle source
# File lib/rory/logger.rb, line 34 def format_message(severity, datetime, progname, msg) (@formatter || @default_formatter).call(severity, datetime, progname, msg, tagged) end
quoted_string(str)
click to toggle source
# File lib/rory/logger.rb, line 30 def quoted_string(str) str =~ /\s/ ? %["#{str}"] : str end