Skip to content
This repository has been archived by the owner on Jan 31, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
[Fixes #7417527] Remove central_logger dependency.
  • Loading branch information
astupka committed Jan 26, 2011
1 parent b528a33 commit 6c2f0dc
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -22,3 +22,4 @@ pkg
## PROJECT::SPECIFIC
*.log
/tmp
config/database.yml
3 changes: 2 additions & 1 deletion Gemfile
Expand Up @@ -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'
Expand Down
8 changes: 2 additions & 6 deletions Gemfile.lock
Expand Up @@ -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)
Expand Down Expand Up @@ -91,7 +86,8 @@ PLATFORMS

DEPENDENCIES
bistro_car!
central_logger
bson_ext
haml
jquery-rails
mongo
rails
12 changes: 3 additions & 9 deletions app/controllers/log_controller.rb
Expand Up @@ -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(")
Expand All @@ -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
5 changes: 3 additions & 2 deletions 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".
Expand Down
21 changes: 21 additions & 0 deletions 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.