Sha256: 81ad0455c1158856500462ac1bcbe0ebb35eb56e7d72e0e21c0fb00209d5ca65
Contents?: true
Size: 1.77 KB
Versions: 6
Compression:
Stored size: 1.77 KB
Contents
require 'mongo_request_logger/ext/buffered_logger' require 'mongo_request_logger/ext/logger' require 'mongo_request_logger/logger' require 'mongo_request_logger/version' require 'mongo_request_logger/rack' if defined?(Rails) require 'mongo_request_logger/railtie' end require 'mongo_request_logger/adapters/moped' require 'mongo_request_logger/adapters/mongo' module MongoRequestLogger def self.configure(config_path, options={}) require 'mongo_request_logger/config' require 'mongo_request_logger/rack' require 'mongo_request_logger/viewer' begin # We prefer moped ... require 'moped' rescue LoadError # ... but fallback to mongo require 'mongo' end environment = ENV['RACK_ENV'] || ENV['RAILS_ENV'] global_config = MongoRequestLogger::Config.new global_config.load_file(config_path) log_config = global_config.namespaced(environment) fallback_log = options[:fallback_log] || log_config['fallback_log'] || "log/#{environment}.log" if log_config && log_config['database'] if defined? Moped adapter = MongoRequestLogger::Adapters::Moped.new(log_config) else adapter = MongoRequestLogger::Adapters::Mongo.new(log_config) end MongoRequestLogger::Viewer.adapter = adapter if defined?(PhusionPassenger) PhusionPassenger.on_event(:starting_worker_process) do |forked| if forked adapter.reconnect end end end logger = MongoRequestLogger::Logger.new adapter, fallback_log else logger = ::Logger.new(fallback_log) end MongoRequestLogger::Rack.logger = logger MongoRequestLogger::Rack.ignore_prefixes << '/assets' MongoRequestLogger::Rack.ignore_prefixes << '/favicon.ico' logger end end
Version data entries
6 entries across 6 versions & 1 rubygems