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

Commit

Permalink
[Fixes #10886497] Add ability to configure safe inserts independent o…
Browse files Browse the repository at this point in the history
…f replica set support
  • Loading branch information
astupka committed Mar 8, 2011
1 parent 4d46989 commit c4bc929
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/central_logger/mongo_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions test/config/samples/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ test:
mongo:
database: system_log
application_name: central_foo
safe_insert: true
4 changes: 4 additions & 0 deletions test/unit/central_logger_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c4bc929

Please sign in to comment.