Skip to content
Browse files

[Fixes #7417527] Remove central_logger dependency.

  • Loading branch information...
1 parent b528a33 commit 6c2f0dc1013c3a27690d597809885ccd5c931e50 @astupka astupka committed Jan 26, 2011
Showing with 32 additions and 18 deletions.
  1. +1 −0 .gitignore
  2. +2 −1 Gemfile
  3. +2 −6 Gemfile.lock
  4. +3 −9 app/controllers/log_controller.rb
  5. +3 −2 config/database.yml.sample
  6. +21 −0 config/initializers/mongo.rb
View
1 .gitignore
@@ -22,3 +22,4 @@ pkg
## PROJECT::SPECIFIC
*.log
/tmp
+config/database.yml
View
3 Gemfile
@@ -6,11 +6,12 @@ gem 'rails'
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# gem 'sqlite3-ruby', :require => 'sqlite3'
-gem "central_logger"
gem "haml"
# fork that removes double response in Rails 3
gem "bistro_car", :git => "git://github.com/astupka/bistro_car.git"
gem "jquery-rails"
+gem "mongo"
+gem "bson_ext"
# Use unicorn as the web server
# gem 'unicorn'
View
8 Gemfile.lock
@@ -40,11 +40,6 @@ GEM
bson (1.2.0)
bson_ext (1.2.0)
builder (2.1.2)
- central_logger (0.3.0)
- bson_ext
- bundler (~> 1.0.0)
- mongo
- rake
erubis (2.6.6)
abstract (>= 1.0.0)
haml (3.0.24)
@@ -91,7 +86,8 @@ PLATFORMS
DEPENDENCIES
bistro_car!
- central_logger
+ bson_ext
haml
jquery-rails
+ mongo
rails
View
12 app/controllers/log_controller.rb
@@ -2,8 +2,8 @@ class LogController < ApplicationController
respond_to :html, :json
def index
- setup
- query = "@collection.#{params[:query] || 'find_one()'}"
+ collection = Mongo.db[Mongo.collection]
+ query = "collection.#{params[:query] || 'find_one()'}"
tail_lines = params[:tail].to_i
if 0 != tail_lines && query.include?(".find(")
@@ -19,12 +19,6 @@ def index
end
def apps
- setup
- respond_with(@db.command({:distinct => logger.mongo_collection_name, :key => "application_name"}) )
- end
-
- def setup
- @db = logger.mongo_connection
- @collection = @db[logger.mongo_collection_name]
+ respond_with(Mongo.db.command({:distinct => Mongo.collection, :key => "application_name"}) )
end
end
View
5 config/database.yml.sample
@@ -1,7 +1,8 @@
# template
development: &config
- mongo:
- database: localhost
+ host: production_log.somesite.com
+ database: database
+ collection: production_log
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
View
21 config/initializers/mongo.rb
@@ -0,0 +1,21 @@
+module Mongo
+ class << self
+ def db
+ @db ||= configure
+ end
+
+ def collection
+ @collection
+ end
+
+ def configure
+ config_file = Rails.root.join("config", "database.yml")
+ config = YAML.load(ERB.new(config_file.read).result)[Rails.env]
+ config = { 'host' => 'localhost',
+ 'port' => '27017' }.merge(config)
+ @collection = config["collection"]
+ Mongo::Connection.new(config['host'], config['port'], :auto_reconnect => true).db(config['database'])
+ end
+ end
+end
+

0 comments on commit 6c2f0dc

Please sign in to comment.
Something went wrong with that request. Please try again.