From de9a2e43d68a3557b5e0d2f0a8d39896fdebb68e Mon Sep 17 00:00:00 2001 From: Reed Law Date: Tue, 12 Apr 2011 14:21:17 -0400 Subject: [PATCH 1/4] make MongoLogger output to STDOUT for Heroku compatibility --- lib/central_logger/mongo_logger.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/central_logger/mongo_logger.rb b/lib/central_logger/mongo_logger.rb index 90b55c9..2656e4b 100644 --- a/lib/central_logger/mongo_logger.rb +++ b/lib/central_logger/mongo_logger.rb @@ -37,6 +37,7 @@ def add_metadata(options={}) end def add(severity, message = nil, progname = nil, &block) + $stdout.puts message if @level <= severity && message.present? && @mongo_record.present? # do not modify the original message used by the buffered logger msg = logging_colorized? ? message.gsub(/(\e(\[([\d;]*[mz]?))?)?/, '').strip : message From 808e05f349da2a3889703b827569ab06893d8711 Mon Sep 17 00:00:00 2001 From: Reed Law Date: Tue, 12 Apr 2011 14:50:27 -0400 Subject: [PATCH 2/4] add Heroku instructions to README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 58bbcce..ed60e5e 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,11 @@ Log to a central MongoDB from Rails apps. include CentralLogger::Filter +1. For use with Heroku you need to prevent the rails_log_stdout plugin from being added by Heroku: + + mkdir vendor/plugins/rails_log_stdout + touch vendor/plugins/rails_log_stdout/.gitkeep + 1. If using Rails 3, SKIP this step. Otherwise, add the following to config/environment.rb: require 'central_logger' From 39e5b56284663769a045ef71af646a2ef1e4b0ec Mon Sep 17 00:00:00 2001 From: Reed Law Date: Tue, 3 May 2011 13:40:14 -0400 Subject: [PATCH 3/4] make connection timeout after 5 seconds to prevent app from timing out --- lib/central_logger/mongo_logger.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/central_logger/mongo_logger.rb b/lib/central_logger/mongo_logger.rb index 2656e4b..f415286 100644 --- a/lib/central_logger/mongo_logger.rb +++ b/lib/central_logger/mongo_logger.rb @@ -134,7 +134,8 @@ def resolve_config def connect @mongo_connection ||= Mongo::Connection.new(@db_configuration['host'], @db_configuration['port'], - :auto_reconnect => true).db(@db_configuration['database']) + :auto_reconnect => true, + :timeout => 5).db(@db_configuration['database']) if @db_configuration['username'] && @db_configuration['password'] # the driver stores credentials in case reconnection is required From e572260edc53a40f94d2ca0028805fd056cd540e Mon Sep 17 00:00:00 2001 From: Reed Law Date: Tue, 31 May 2011 07:31:18 -0400 Subject: [PATCH 4/4] fix indentation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ed60e5e..0a77e6e 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Log to a central MongoDB from Rails apps. 1. For use with Heroku you need to prevent the rails_log_stdout plugin from being added by Heroku: mkdir vendor/plugins/rails_log_stdout - touch vendor/plugins/rails_log_stdout/.gitkeep + touch vendor/plugins/rails_log_stdout/.gitkeep 1. If using Rails 3, SKIP this step. Otherwise, add the following to config/environment.rb: