Sha256: 6ba8ad14c13f2c7b01217a90d8c742489df76f1013a67739143412106b9b35d0

Contents?: true

Size: 627 Bytes

Versions: 33

Compression:

Stored size: 627 Bytes

Contents

module Dbox
  module Loggable
    def self.included receiver
      receiver.extend ClassMethods
    end

    module ClassMethods
      def log
        Dbox.log
      end
    end

    def log
      Dbox.log
    end
  end

  def self.log
    @logger ||= setup_logger
  end

  def self.setup_logger
    if defined?(LOGGER)
      LOGGER
    elsif defined?(Rails.logger)
      Rails.logger
    else
      l = Logger.new(STDOUT)
      l.level = (ENV["DEBUG"] && ENV["DEBUG"] != "false") ? Logger::DEBUG : Logger::INFO
      l.formatter = proc {|severity, datetime, progname, msg| "[#{severity}] #{msg}\n" }
      l
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
dbox-0.6.6 lib/dbox/loggable.rb
dbox-0.6.5 lib/dbox/loggable.rb
dbox-0.6.4 lib/dbox/loggable.rb
dbox-0.6.3 lib/dbox/loggable.rb
dbox-0.6.2 lib/dbox/loggable.rb
dbox-0.6.1 lib/dbox/loggable.rb
dbox-0.6.0 lib/dbox/loggable.rb
dbox-0.5.3 lib/dbox/loggable.rb
dbox-0.5.2 lib/dbox/loggable.rb
dbox-0.5.1 lib/dbox/loggable.rb
dbox-0.5.0 lib/dbox/loggable.rb
dbox-0.4.4 lib/dbox/loggable.rb
dbox-0.4.3 lib/dbox/loggable.rb