Sha256: 334f516a92187324ba969bd28b9054d67f01bcfc6d0a50746b686bdc1400a7f5
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
module Loggable module ClassMethods @@logger = nil # Use this method on any of your classes to trigger the logging facility: # # MyClass.logger = Logger.new('/path/to/logfile') # # Now you can call the 'logger' method inside a class or instance method to log at # the specified level. See the README for details. # def logger=(logger) @@logger = logger end # If ::Rails.logger is defined, that will be returned. # If no logger has been defined, a new STDOUT Logger will be created. def logger if defined?(::Rails) && Rails.respond_to?(:version) if Rails.version >= "3.0" && defined?(::Rails::Application) && !::Rails.logger.nil? @@logger = ::Rails.logger elsif defined?(RAILS_DEFAULT_LOGGER) @@logger = RAILS_DEFAULT_LOGGER end end # If none of the above was able to set @@logger, create a new default logger @@logger ||= ::Logger.new(STDOUT) return @@logger end end module InstanceMethods def logger self.class.logger end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mediashelf-loggable-0.4.5 | lib/loggable/log_methods.rb |