Sha256: 6c1878ebf7609aa3178383074e8892b2aaa2fc730e5f00e317ff97c553ae8524

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require 'gom/logger'

module Gom
  # GOM default Logger instance
  Log = Gom::Logger.new

  # TODO: runtime configuration might move to config/initializers/...
  Log.level = ::Logger::DEBUG
end

__END__

  Log = ::Logger.new case RAILS_ENV
    when "test" 
      STDOUT
    else 
      "#{RAILS_ROOT}/log/gom-#{RAILS_ENV}.log"
  end

  class << Log
    # this is to de-patch the rails formatting patch..
    def format_message(severity, timestamp, progname, msg)
      "#{timestamp.to_formatted_s(:db)} #{severity.first} #{msg}\n" 
    end 

    # experimental convenience function:
    #
    #   Log.ex e
    #
    # does actually do: 
    #   Log.error e
    #   Log.debug "#{e.backtrace.join "\n\t"}"
    #
    # and:
    #   Log.ex e, "some message here"
    #
    # stands for:
    #   Log.error "some message here"
    #   Log.debug "#{e.backtrace.join "\n\t"}"
    #
    def ex e, msg = nil, level = :error
      send level, (msg || e)
      debug "#{e} -- error was: #{msg}\n\t#{e.backtrace.join "\n\t"}"
    end
  end

  # TODO: runtime configuration might move to config/initializers/...
  Log.level = ::Logger::DEBUG
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gom-core-0.1.1 lib/gom/log.rb