Sha256: e9a388bf94820dfba0256a39dc8dd65ae04da9a4845320f1f7322455682901d8

Contents?: true

Size: 986 Bytes

Versions: 18

Compression:

Stored size: 986 Bytes

Contents

module MongodbLogger
  module InitializerMixin
    
    def rails30?
      3 == Rails::VERSION::MAJOR && 0 == Rails::VERSION::MINOR
    end
    
    def create_logger(config)
      path = rails30? ? config.paths.log.to_a.first : config.paths['log'].first
      level = ActiveSupport::BufferedLogger.const_get(config.log_level.to_s.upcase)
      logger = MongodbLogger::Logger.new(:path => path, :level => level)
      logger.auto_flushing = false if Rails.env.production?
      logger
    rescue StandardError => e
      logger = ActiveSupport::BufferedLogger.new(STDERR)
      logger.level = ActiveSupport::BufferedLogger::WARN
      logger.warn(
        "MongodbLogger Initializer Error: Unable to access log file. Please ensure that #{path} exists and is chmod 0666. " +
        "The log level has been raised to WARN and the output directed to STDERR until the problem is fixed." + "\n" +
        e.message + "\n" + e.backtrace.join("\n")
      )
      logger
    end
    
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
mongodb_logger-0.2.6 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.2.6-jruby lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.2.5 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.2.4 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.2.3 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.2.2 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.2.1 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.2.0 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.1.9 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.1.8 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.1.7 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.1.6 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.1.5 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.1.4 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.1.3 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.1.2 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.1.1 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.1.0 lib/mongodb_logger/initializer_mixin.rb