class ContextLogger

Public Class Methods

format_block() click to toggle source
# File lib/tarpaulin/logger.rb, line 8
def self.format_block # implicit
  the_proc = Proc.new # capture it
  context = eval("Context::determine{}", the_proc) # eval can take a Proc obj or a Binding
  result = the_proc.call # invoke it
  klass = 'nil' # can it be??
  # puts context[:self].inspect
  if context[:self]
    klass = context[:self].class.to_s.split('::').last
    if klass == "Object"; klass = 'main' end
  end
  if context[:function]
    if klass
      context = "#{context[:location]} #{klass}.#{context[:function]}()"
    else
      context = "#{context[:location]} #{context[:function]}()"
    end
  else
    context = "#{context[:location]} #{klass}@#{context[:line_number]}"
  end
  case result
  when String # maybe respond_to? is better but meh ...
    return "[#{context}]: #{result}" # time stamp
  else
    return "[#{context}]: #{result.inspect}"
  end
end
new(stream=STDOUT) click to toggle source
Calls superclass method
# File lib/tarpaulin/logger.rb, line 51
def initialize(stream=STDOUT)
  # DEBUG < INFO < WARN < ERROR < FATAL < UNKNOWN
  level=Logger::DEBUG
  super(stream)
end