Sha256: d6b1001938f338248488d2ee2a59cd2a8b9bf70525951577ebea1dbaa5663a83

Contents?: true

Size: 998 Bytes

Versions: 13

Compression:

Stored size: 998 Bytes

Contents

module MongodbLogger
  module InitializerMixin
    
    def rails3(minor = 0)
      3 == Rails::VERSION::MAJOR && minor == Rails::VERSION::MINOR
    end
    
    def create_logger(config)
      path = config.paths['log'].first
      level = ActiveSupport::BufferedLogger.const_get(config.log_level.to_s.upcase)
      logger = MongodbLogger::Logger.new(:path => path, :level => level)
      logger.level = level
      logger.auto_flushing = false if Rails.env.production? && rails3(1)
      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

13 entries across 13 versions & 1 rubygems

Version Path
mongodb_logger-0.5.1 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.5.0 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.4.2 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.4.1 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.4.0 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.3.3-jruby lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.3.3 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.3.2-jruby lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.3.2 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.3.1-jruby lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.3.1 lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.3.0-jruby lib/mongodb_logger/initializer_mixin.rb
mongodb_logger-0.3.0 lib/mongodb_logger/initializer_mixin.rb