Browse files

[Fixes #10886497] Add ability to configure safe inserts independent o…

…f replica set support
  • Loading branch information...
1 parent 4d46989 commit c4bc929cb48b01f432c5bc1e62bace9566d0a707 @astupka astupka committed Mar 8, 2011
Showing with 7 additions and 1 deletion.
  1. +2 −1 lib/central_logger/mongo_logger.rb
  2. +1 −0 test/config/samples/database.yml
  3. +4 −0 test/unit/central_logger_test.rb
View
3 lib/central_logger/mongo_logger.rb
@@ -96,9 +96,10 @@ def configure
'port' => 27017,
'capsize' => default_capsize}.merge(resolve_config)
@application_name = resolve_application_name
+ @safe_insert = @db_configuration['safe_insert'] || false
@insert_block = @db_configuration.has_key?('replica_set') && @db_configuration['replica_set'] ?
- lambda { rescue_connection_failure{ insert_log_record(true) } } :
+ lambda { rescue_connection_failure{ insert_log_record(@safe_insert) } } :
lambda { insert_log_record }
end
View
1 test/config/samples/database.yml
@@ -5,3 +5,4 @@ test:
mongo:
database: system_log
application_name: central_foo
+ safe_insert: true
View
4 test/unit/central_logger_test.rb
@@ -81,6 +81,10 @@ class CentralLogger::MongoLoggerTest < Test::Unit::TestCase
assert_equal "central_foo", @central_logger.instance_variable_get(:@application_name)
end
+ should "set safe insert when specified in the config file" do
+ assert @central_logger.instance_variable_get(:@safe_insert)
+ end
+
should "use the database name in the config file" do
assert_equal "system_log", @central_logger.db_configuration['database']
end

0 comments on commit c4bc929

Please sign in to comment.