summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2014-08-05 14:32:45 -0400
committerBenety Goh <benety@mongodb.com>2014-08-12 18:56:41 -0400
commita3845092f26955e6cbfca868fd136b7d5eefed9b (patch)
treedfb566b50a00b8c64002e6107d9fcbdb1443c6cf /src/mongo
parent0ea8cf462b48a1aeefb10fd4bba0b1e93b0e661e (diff)
downloadmongo-a3845092f26955e6cbfca868fd136b7d5eefed9b.tar.gz
SERVER-14729 logging cleanup - removed mongo/util/log.h from headers, de-inlining functions that use logging where applicable.
de-inlined BSONElement::_asCode() de-inlined BSONObjBuilder::appendDate() de-inlined DBClientCursor::nextSafe() de-inlined IndexDescriptor::_checkOk() de-inlined LastErrorHolder::getSafe() de-inlined UpdateResult constructor de-inlined QueryPlannerCommon::reverseScans() de-inlined repl::ScopedConn::connect() de-inlined repl::_MultiCommand::run() de-inlined OplogReader::tailCheck() de-inlined repl::StateBox::change() de-inlined repl::SyncSourceFeedback::_resetConnection() de-inlined DiskLoc56Bit::operator=() de-inlined DurableInterface::~DurableInterface() de-inlined ListeningSockets::closeAll() de-inlined RelativePath::fromFullPath() and getPartition() de-inlined V8Scope::checkV8ErrorState and removed debug log message from ObjTracker destructor (v8-3.25) de-inlined V8Scope::checkV8ErrorState and removed debug log message from ObjTracker destructor removed log message from List1::orphan() - this should have no user-facing impact because List1::orphan() is used in tests only removed log message from RWLockRecursiveNongreedy::Lock() removed log message from RSBase destructor removed log.h dependency from DESTRUCTOR_GUARD macro removed mongo/util/log.h dependency from qlog.h removed mongo/util/log.h dependency from stacktrace.h removed mongo/util/log.h dependency from s2 logging header removed mongo/util/log.h dependency from chunk_diff-inl.cpp removed mongo/util/log.h from pch.h removed unused mongo/util/log.h include from inlined file sorter.cpp convert HashTable<K,V> to non-template NamespaceHashTable. De-inlined NamespaceHashTable::_find() and constructor convert isself getMyAddrs()and getallIPs() debug log to use LOG() macro assign default log component MONGO_LOG_DEFAULT_COMPONENT removed unused macros LOGATMOST and LOGSOME removed unused FLOG() macro from goodies.h
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/SConscript6
-rw-r--r--src/mongo/bson/bson_db.h14
-rw-r--r--src/mongo/bson/bson_validate_test.cpp1
-rw-r--r--src/mongo/bson/bsonelement.cpp15
-rw-r--r--src/mongo/bson/bsonobj.cpp1
-rw-r--r--src/mongo/bson/bsonobjbuilder.cpp15
-rw-r--r--src/mongo/bson/bsonobjbuilder.h19
-rw-r--r--src/mongo/client/clientAndShell.cpp1
-rw-r--r--src/mongo/client/dbclientcursor.cpp11
-rw-r--r--src/mongo/client/dbclientcursor.h13
-rw-r--r--src/mongo/client/scoped_db_conn_test.cpp1
-rw-r--r--src/mongo/db/auth/authz_manager_external_state_local.cpp1
-rw-r--r--src/mongo/db/auth/authz_manager_external_state_s.cpp1
-rw-r--r--src/mongo/db/auth/authz_session_external_state_server_common.cpp1
-rw-r--r--src/mongo/db/auth/security_key.cpp1
-rw-r--r--src/mongo/db/auth/user_document_parser.cpp1
-rw-r--r--src/mongo/db/catalog/collection.cpp1
-rw-r--r--src/mongo/db/catalog/collection_compact.cpp1
-rw-r--r--src/mongo/db/client.cpp1
-rw-r--r--src/mongo/db/commands.cpp1
-rw-r--r--src/mongo/db/commands/auth_schema_upgrade_d.cpp1
-rw-r--r--src/mongo/db/commands/authentication_commands.cpp1
-rw-r--r--src/mongo/db/commands/clone_collection.cpp1
-rw-r--r--src/mongo/db/commands/compact.cpp1
-rw-r--r--src/mongo/db/commands/count.cpp1
-rw-r--r--src/mongo/db/commands/dbhash.cpp1
-rw-r--r--src/mongo/db/commands/fsync.cpp1
-rw-r--r--src/mongo/db/commands/geo_near_cmd.cpp1
-rw-r--r--src/mongo/db/commands/isself.cpp2
-rw-r--r--src/mongo/db/commands/server_status.cpp1
-rw-r--r--src/mongo/db/commands/test_commands.cpp1
-rw-r--r--src/mongo/db/commands/user_management_commands.cpp1
-rw-r--r--src/mongo/db/d_concurrency.cpp1
-rw-r--r--src/mongo/db/dbcommands_generic.cpp1
-rw-r--r--src/mongo/db/dbeval.cpp1
-rw-r--r--src/mongo/db/exec/collection_scan.cpp1
-rw-r--r--src/mongo/db/exec/delete.cpp1
-rw-r--r--src/mongo/db/exec/geo_near.cpp1
-rw-r--r--src/mongo/db/exec/index_scan.cpp1
-rw-r--r--src/mongo/db/exec/projection.cpp1
-rw-r--r--src/mongo/db/fts/fts_command.cpp1
-rw-r--r--src/mongo/db/fts/fts_enabled.cpp2
-rw-r--r--src/mongo/db/fts/fts_index_format_test.cpp1
-rw-r--r--src/mongo/db/geo/geo_query.cpp1
-rw-r--r--src/mongo/db/geo/geoparser.cpp1
-rw-r--r--src/mongo/db/geo/r2_region_coverer_test.cpp1
-rw-r--r--src/mongo/db/global_environment_d.cpp1
-rw-r--r--src/mongo/db/index/SConscript9
-rw-r--r--src/mongo/db/index/btree_based_access_method.cpp1
-rw-r--r--src/mongo/db/index/expression_keys_private.cpp1
-rw-r--r--src/mongo/db/index/index_descriptor.cpp8
-rw-r--r--src/mongo/db/index/index_descriptor.h7
-rw-r--r--src/mongo/db/index/s2_access_method.cpp1
-rw-r--r--src/mongo/db/index_rebuilder.cpp2
-rw-r--r--src/mongo/db/instance.cpp1
-rw-r--r--src/mongo/db/introspect.cpp1
-rw-r--r--src/mongo/db/json.cpp1
-rw-r--r--src/mongo/db/lasterror.cpp12
-rw-r--r--src/mongo/db/lasterror.h11
-rw-r--r--src/mongo/db/lockstat.h1
-rw-r--r--src/mongo/db/lockstate.cpp1
-rw-r--r--src/mongo/db/log_process_details.cpp1
-rw-r--r--src/mongo/db/matcher/expression_parser_leaf_test.cpp1
-rw-r--r--src/mongo/db/matcher/path.cpp1
-rw-r--r--src/mongo/db/mongod_options.cpp1
-rw-r--r--src/mongo/db/operation_context_impl.cpp1
-rw-r--r--src/mongo/db/ops/delete_executor.cpp1
-rw-r--r--src/mongo/db/ops/update_result.cpp58
-rw-r--r--src/mongo/db/ops/update_result.h16
-rw-r--r--src/mongo/db/query/SConscript1
-rw-r--r--src/mongo/db/query/canonical_query.cpp1
-rw-r--r--src/mongo/db/query/index_bounds_builder.cpp1
-rw-r--r--src/mongo/db/query/plan_enumerator.cpp1
-rw-r--r--src/mongo/db/query/planner_access.cpp1
-rw-r--r--src/mongo/db/query/planner_ixselect.cpp1
-rw-r--r--src/mongo/db/query/qlog.h12
-rw-r--r--src/mongo/db/query/query_planner_common.cpp86
-rw-r--r--src/mongo/db/query/query_planner_common.h48
-rw-r--r--src/mongo/db/query/query_planner_test.cpp1
-rw-r--r--src/mongo/db/query/stage_builder.cpp1
-rw-r--r--src/mongo/db/range_deleter_db_env.cpp1
-rw-r--r--src/mongo/db/repl/SConscript1
-rw-r--r--src/mongo/db/repl/connections.cpp62
-rw-r--r--src/mongo/db/repl/connections.h21
-rw-r--r--src/mongo/db/repl/health.cpp1
-rw-r--r--src/mongo/db/repl/heartbeat.cpp1
-rw-r--r--src/mongo/db/repl/initial_sync.cpp1
-rw-r--r--src/mongo/db/repl/isself.cpp15
-rw-r--r--src/mongo/db/repl/multicmd.cpp54
-rw-r--r--src/mongo/db/repl/multicmd.h15
-rw-r--r--src/mongo/db/repl/oplogreader.cpp7
-rw-r--r--src/mongo/db/repl/oplogreader.h7
-rw-r--r--src/mongo/db/repl/repl_coordinator_hybrid.cpp1
-rw-r--r--src/mongo/db/repl/repl_coordinator_impl.cpp1
-rw-r--r--src/mongo/db/repl/replset_commands.cpp1
-rw-r--r--src/mongo/db/repl/rs.cpp1
-rw-r--r--src/mongo/db/repl/rs_base.h7
-rw-r--r--src/mongo/db/repl/rs_initiate.cpp1
-rw-r--r--src/mongo/db/repl/rs_sync.cpp1
-rw-r--r--src/mongo/db/repl/state_box.cpp57
-rw-r--r--src/mongo/db/repl/state_box.h15
-rw-r--r--src/mongo/db/repl/sync_source_feedback.cpp5
-rw-r--r--src/mongo/db/repl/sync_source_feedback.h8
-rw-r--r--src/mongo/db/repl/write_concern.cpp1
-rw-r--r--src/mongo/db/restapi.cpp1
-rw-r--r--src/mongo/db/server_options_helpers.cpp1
-rw-r--r--src/mongo/db/sorter/sorter.cpp1
-rw-r--r--src/mongo/db/stats/counters.cpp1
-rw-r--r--src/mongo/db/stats/snapshots.cpp1
-rw-r--r--src/mongo/db/stats/top.cpp1
-rw-r--r--src/mongo/db/storage/heap1/SConscript1
-rw-r--r--src/mongo/db/storage/heap1/heap1_database_catalog_entry_index_real.cpp1
-rw-r--r--src/mongo/db/storage/heap1/record_store_heap.cpp1
-rw-r--r--src/mongo/db/storage/mmap_v1/SConscript4
-rw-r--r--src/mongo/db/storage/mmap_v1/btree/btree_logic_test.cpp1
-rw-r--r--src/mongo/db/storage/mmap_v1/btree/btree_ondisk.cpp53
-rw-r--r--src/mongo/db/storage/mmap_v1/btree/btree_ondisk.h15
-rw-r--r--src/mongo/db/storage/mmap_v1/btree/key.cpp1
-rw-r--r--src/mongo/db/storage/mmap_v1/catalog/hashtab.cpp95
-rw-r--r--src/mongo/db/storage/mmap_v1/catalog/hashtab.h63
-rw-r--r--src/mongo/db/storage/mmap_v1/catalog/namespace-inl.h4
-rw-r--r--src/mongo/db/storage/mmap_v1/catalog/namespace_details.cpp1
-rw-r--r--src/mongo/db/storage/mmap_v1/catalog/namespace_details.h2
-rw-r--r--src/mongo/db/storage/mmap_v1/catalog/namespace_index.cpp2
-rw-r--r--src/mongo/db/storage/mmap_v1/catalog/namespace_index.h3
-rw-r--r--src/mongo/db/storage/mmap_v1/data_file.cpp1
-rw-r--r--src/mongo/db/storage/mmap_v1/dur.cpp6
-rw-r--r--src/mongo/db/storage/mmap_v1/dur.h2
-rw-r--r--src/mongo/db/storage/mmap_v1/dur_commitjob.cpp1
-rw-r--r--src/mongo/db/storage/mmap_v1/dur_journal.cpp2
-rw-r--r--src/mongo/db/storage/mmap_v1/dur_preplogbuffer.cpp1
-rw-r--r--src/mongo/db/storage/mmap_v1/dur_recover.cpp1
-rw-r--r--src/mongo/db/storage/mmap_v1/durable_mapped_file.cpp3
-rw-r--r--src/mongo/db/storage/mmap_v1/durop.cpp2
-rw-r--r--src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp1
-rw-r--r--src/mongo/db/storage/mmap_v1/mmap_v1_engine.cpp1
-rw-r--r--src/mongo/db/storage/mmap_v1/record_store_v1_base.cpp1
-rw-r--r--src/mongo/db/storage/mmap_v1/record_store_v1_capped.cpp1
-rw-r--r--src/mongo/db/storage/mmap_v1/record_store_v1_repair_iterator.cpp1
-rw-r--r--src/mongo/db/storage/mmap_v1/record_store_v1_test_help.cpp1
-rw-r--r--src/mongo/db/storage/rocks/rocks_database_catalog_entry.cpp1
-rw-r--r--src/mongo/db/storage/rocks/rocks_record_store.cpp2
-rw-r--r--src/mongo/dbtests/config_server_fixture.cpp1
-rw-r--r--src/mongo/dbtests/framework.cpp1
-rw-r--r--src/mongo/dbtests/framework_options.cpp1
-rw-r--r--src/mongo/dbtests/jsobjtests.cpp1
-rw-r--r--src/mongo/dbtests/jsontests.cpp1
-rw-r--r--src/mongo/dbtests/jstests.cpp1
-rw-r--r--src/mongo/dbtests/namespacetests.cpp1
-rw-r--r--src/mongo/dbtests/perftests.cpp1
-rw-r--r--src/mongo/dbtests/repltests.cpp1
-rw-r--r--src/mongo/dbtests/sharding.cpp1
-rw-r--r--src/mongo/pch.h1
-rw-r--r--src/mongo/s/balancer_policy_tests.cpp1
-rw-r--r--src/mongo/s/chunk_diff-inl.cpp42
-rw-r--r--src/mongo/s/chunk_manager_targeter.cpp1
-rw-r--r--src/mongo/s/chunk_manager_targeter_test.cpp1
-rw-r--r--src/mongo/s/cluster_write.cpp1
-rw-r--r--src/mongo/s/collection_metadata.cpp1
-rw-r--r--src/mongo/s/commands/auth_schema_upgrade_s.cpp1
-rw-r--r--src/mongo/s/config_upgrade.cpp1
-rw-r--r--src/mongo/s/config_upgrade_helpers.cpp1
-rw-r--r--src/mongo/s/config_upgrade_v0_to_v5.cpp1
-rw-r--r--src/mongo/s/d_merge.cpp1
-rw-r--r--src/mongo/s/distlock.h3
-rw-r--r--src/mongo/s/mongos_options.cpp1
-rw-r--r--src/mongo/s/s_only.cpp1
-rw-r--r--src/mongo/s/scc_fast_query_handler.cpp1
-rw-r--r--src/mongo/s/server.cpp1
-rw-r--r--src/mongo/s/shardconnection.cpp1
-rw-r--r--src/mongo/scripting/engine.cpp1
-rw-r--r--src/mongo/scripting/engine_v8-3.25.cpp45
-rw-r--r--src/mongo/scripting/engine_v8-3.25.h52
-rw-r--r--src/mongo/scripting/engine_v8.cpp45
-rw-r--r--src/mongo/scripting/engine_v8.h52
-rw-r--r--src/mongo/scripting/v8-3.25_utils.cpp1
-rw-r--r--src/mongo/scripting/v8_utils.cpp1
-rw-r--r--src/mongo/server.h6
-rw-r--r--src/mongo/shell/bench.cpp1
-rw-r--r--src/mongo/shell/dbshell.cpp1
-rw-r--r--src/mongo/shell/shell_utils_extended.cpp1
-rw-r--r--src/mongo/shell/shell_utils_launcher.cpp1
-rw-r--r--src/mongo/tools/bridge.cpp1
-rw-r--r--src/mongo/tools/dump.cpp1
-rw-r--r--src/mongo/tools/import.cpp1
-rw-r--r--src/mongo/tools/tool.cpp1
-rw-r--r--src/mongo/util/alignedbuilder.cpp1
-rw-r--r--src/mongo/util/alignedbuilder.h1
-rw-r--r--src/mongo/util/assert_util.cpp4
-rw-r--r--src/mongo/util/assert_util.h18
-rw-r--r--src/mongo/util/concurrency/list.h4
-rw-r--r--src/mongo/util/concurrency/rwlock.h2
-rw-r--r--src/mongo/util/concurrency/task.cpp1
-rw-r--r--src/mongo/util/concurrency/thread_pool.cpp1
-rw-r--r--src/mongo/util/fail_point.cpp1
-rw-r--r--src/mongo/util/fail_point_test.cpp1
-rw-r--r--src/mongo/util/goodies.h2
-rw-r--r--src/mongo/util/logfile.cpp1
-rw-r--r--src/mongo/util/mmap.cpp1
-rw-r--r--src/mongo/util/mmap_posix.cpp1
-rw-r--r--src/mongo/util/mmap_win.cpp1
-rw-r--r--src/mongo/util/net/listen.cpp26
-rw-r--r--src/mongo/util/net/listen.h26
-rw-r--r--src/mongo/util/net/message_server_port.cpp1
-rw-r--r--src/mongo/util/net/ssl_options.cpp1
-rw-r--r--src/mongo/util/ntservice.cpp1
-rw-r--r--src/mongo/util/password.cpp2
-rw-r--r--src/mongo/util/paths.cpp30
-rw-r--r--src/mongo/util/paths.h34
-rw-r--r--src/mongo/util/processinfo.cpp2
-rw-r--r--src/mongo/util/processinfo_freebsd.cpp1
-rw-r--r--src/mongo/util/processinfo_linux2.cpp1
-rw-r--r--src/mongo/util/processinfo_openbsd5.cpp1
-rw-r--r--src/mongo/util/processinfo_sunos5.cpp1
-rw-r--r--src/mongo/util/processinfo_win32.cpp1
-rw-r--r--src/mongo/util/signal_handlers_synchronous.cpp1
-rw-r--r--src/mongo/util/stacktrace.h18
-rw-r--r--src/mongo/util/version_reporting.cpp1
218 files changed, 987 insertions, 475 deletions
diff --git a/src/mongo/SConscript b/src/mongo/SConscript
index e14391b6798..036a96c7d08 100644
--- a/src/mongo/SConscript
+++ b/src/mongo/SConscript
@@ -575,6 +575,7 @@ serverOnlyFiles = [ "db/curop.cpp",
"db/range_deleter_db_env.cpp",
"db/range_deleter_service.cpp",
"db/repl/rs.cpp",
+ "db/repl/connections.cpp",
"db/repl/consensus.cpp",
"db/repl/rs_initiate.cpp",
"db/repl/repl_coordinator_external_state_impl.cpp",
@@ -596,12 +597,14 @@ serverOnlyFiles = [ "db/curop.cpp",
"db/repl/bgsync.cpp",
"db/repl/member.cpp",
"db/repl/master_slave.cpp",
+ "db/repl/multicmd.cpp",
"db/repl/sync.cpp",
"db/repl/sync_tail.cpp",
"db/repl/sync_source_feedback.cpp",
"db/repl/oplogreader.cpp",
"db/repl/resync.cpp",
"db/repl/oplog.cpp",
+ "db/repl/state_box.cpp",
"db/prefetch.cpp",
"db/repl/write_concern.cpp",
"db/index_legacy.cpp",
@@ -610,7 +613,6 @@ serverOnlyFiles = [ "db/curop.cpp",
"db/index/btree_based_access_method.cpp",
"db/index/btree_based_bulk_access_method.cpp",
"db/index/btree_index_cursor.cpp",
- "db/index/index_descriptor.cpp",
"db/index/fts_access_method.cpp",
"db/index/hash_access_method.cpp",
"db/index/haystack_access_method.cpp",
@@ -640,6 +642,7 @@ serverOnlyFiles = [ "db/curop.cpp",
"db/ops/insert.cpp",
"db/ops/update.cpp",
"db/ops/update_executor.cpp",
+ "db/ops/update_result.cpp",
"db/dbcommands.cpp",
"db/dbcommands_admin.cpp",
"db/write_concern.cpp",
@@ -914,6 +917,7 @@ serveronlyLibdeps = ["coreshard",
"db/catalog/collection_options",
"db/exec/working_set",
"db/exec/exec",
+ "db/index/index_descriptor",
"db/query/query",
"db/repl/repl_settings",
"db/repl/network_interface_impl",
diff --git a/src/mongo/bson/bson_db.h b/src/mongo/bson/bson_db.h
index bd1b7b53a33..0be07dfe15e 100644
--- a/src/mongo/bson/bson_db.h
+++ b/src/mongo/bson/bson_db.h
@@ -65,20 +65,6 @@ namespace mongo {
return OpTime();
}
- inline std::string BSONElement::_asCode() const {
- switch( type() ) {
- case mongo::String:
- case Code:
- return std::string(valuestr(), valuestrsize()-1);
- case CodeWScope:
- return std::string(codeWScopeCode(), *(int*)(valuestr())-1);
- default:
- log() << "can't convert type: " << (int)(type()) << " to code" << std::endl;
- }
- uassert( 10062 , "not code" , 0 );
- return "";
- }
-
inline BSONObjBuilder& BSONObjBuilderValueStream::operator<<(const DateNowLabeler& id) {
_builder->appendDate(_fieldName, jsTime());
_fieldName = StringData();
diff --git a/src/mongo/bson/bson_validate_test.cpp b/src/mongo/bson/bson_validate_test.cpp
index 47cf87b80db..3377e4fcbd6 100644
--- a/src/mongo/bson/bson_validate_test.cpp
+++ b/src/mongo/bson/bson_validate_test.cpp
@@ -29,6 +29,7 @@
#include "mongo/unittest/unittest.h"
#include "mongo/platform/random.h"
#include "mongo/bson/bson_validate.h"
+#include "mongo/util/log.h"
namespace {
diff --git a/src/mongo/bson/bsonelement.cpp b/src/mongo/bson/bsonelement.cpp
index 47e9e0a1544..c8e98e4cbf1 100644
--- a/src/mongo/bson/bsonelement.cpp
+++ b/src/mongo/bson/bsonelement.cpp
@@ -31,6 +31,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/util/base64.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
@@ -702,6 +703,20 @@ namespace mongo {
}
}
+ std::string BSONElement::_asCode() const {
+ switch( type() ) {
+ case mongo::String:
+ case Code:
+ return std::string(valuestr(), valuestrsize()-1);
+ case CodeWScope:
+ return std::string(codeWScopeCode(), *(int*)(valuestr())-1);
+ default:
+ log() << "can't convert type: " << (int)(type()) << " to code" << std::endl;
+ }
+ uassert( 10062 , "not code" , 0 );
+ return "";
+ }
+
std::ostream& operator<<( std::ostream &s, const BSONElement &e ) {
return s << e.toString();
}
diff --git a/src/mongo/bson/bsonobj.cpp b/src/mongo/bson/bsonobj.cpp
index 209142a9921..95f93485d5c 100644
--- a/src/mongo/bson/bsonobj.cpp
+++ b/src/mongo/bson/bsonobj.cpp
@@ -31,6 +31,7 @@
#include "mongo/bson/bson_validate.h"
#include "mongo/db/json.h"
+#include "mongo/util/log.h"
#include "mongo/util/md5.hpp"
#include "mongo/util/mongoutils/str.h"
diff --git a/src/mongo/bson/bsonobjbuilder.cpp b/src/mongo/bson/bsonobjbuilder.cpp
index c75644c198c..ab14168ed13 100644
--- a/src/mongo/bson/bsonobjbuilder.cpp
+++ b/src/mongo/bson/bsonobjbuilder.cpp
@@ -193,6 +193,21 @@ namespace mongo {
}
}
+ BSONObjBuilder& BSONObjBuilder::appendDate(const StringData& fieldName, Date_t dt) {
+ /* easy to pass a time_t to this and get a bad result. thus this warning. */
+#if defined(_DEBUG) && defined(MONGO_EXPOSE_MACROS)
+ if( dt > 0 && dt <= 0xffffffff ) {
+ static int n;
+ if( n++ == 0 )
+ log() << "DEV WARNING appendDate() called with a tiny (but nonzero) date" << std::endl;
+ }
+#endif
+ _b.appendNum((char) Date);
+ _b.appendStr(fieldName);
+ _b.appendNum(dt);
+ return *this;
+ }
+
/* add all the fields from the object specified to this object */
BSONObjBuilder& BSONObjBuilder::appendElements(BSONObj x) {
if (!x.isEmpty())
diff --git a/src/mongo/bson/bsonobjbuilder.h b/src/mongo/bson/bsonobjbuilder.h
index 3495ca9313d..c1f56c50512 100644
--- a/src/mongo/bson/bsonobjbuilder.h
+++ b/src/mongo/bson/bsonobjbuilder.h
@@ -46,10 +46,6 @@
#include "mongo/bson/bsonobj.h"
#include "mongo/client/export_macros.h"
-#if defined(_DEBUG) && defined(MONGO_EXPOSE_MACROS)
-#include "mongo/util/log.h"
-#endif
-
namespace mongo {
#if defined(_WIN32)
@@ -328,20 +324,7 @@ namespace mongo {
@param dt a Java-style 64 bit date value, that is
the number of milliseconds since January 1, 1970, 00:00:00 GMT
*/
- BSONObjBuilder& appendDate(const StringData& fieldName, Date_t dt) {
- /* easy to pass a time_t to this and get a bad result. thus this warning. */
-#if defined(_DEBUG) && defined(MONGO_EXPOSE_MACROS)
- if( dt > 0 && dt <= 0xffffffff ) {
- static int n;
- if( n++ == 0 )
- log() << "DEV WARNING appendDate() called with a tiny (but nonzero) date" << std::endl;
- }
-#endif
- _b.appendNum((char) Date);
- _b.appendStr(fieldName);
- _b.appendNum(dt);
- return *this;
- }
+ BSONObjBuilder& appendDate(const StringData& fieldName, Date_t dt);
BSONObjBuilder& append(const StringData& fieldName, Date_t dt) {
return appendDate(fieldName, dt);
}
diff --git a/src/mongo/client/clientAndShell.cpp b/src/mongo/client/clientAndShell.cpp
index dc838787915..c242193d3f8 100644
--- a/src/mongo/client/clientAndShell.cpp
+++ b/src/mongo/client/clientAndShell.cpp
@@ -34,6 +34,7 @@
#include "mongo/db/server_options.h"
#include "mongo/s/shard.h"
#include "mongo/util/assert_util.h"
+#include "mongo/util/log.h"
#include "mongo/util/timer.h"
namespace mongo {
diff --git a/src/mongo/client/dbclientcursor.cpp b/src/mongo/client/dbclientcursor.cpp
index 120c951e441..68652796e1a 100644
--- a/src/mongo/client/dbclientcursor.cpp
+++ b/src/mongo/client/dbclientcursor.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/namespace_string.h"
#include "mongo/s/shard.h"
#include "mongo/s/stale_exception.h" // for RecvStaleConfigException
+#include "mongo/util/log.h"
namespace mongo {
@@ -268,6 +269,16 @@ namespace mongo {
return o;
}
+ BSONObj DBClientCursor::nextSafe() {
+ BSONObj o = next();
+ if( strcmp(o.firstElementFieldName(), "$err") == 0 ) {
+ std::string s = "nextSafe(): " + o.toString();
+ LOG(5) << s;
+ uasserted(13106, s);
+ }
+ return o;
+ }
+
void DBClientCursor::peek(vector<BSONObj>& v, int atMost) {
int m = atMost;
diff --git a/src/mongo/client/dbclientcursor.h b/src/mongo/client/dbclientcursor.h
index a130b36cb42..3ce07e210c0 100644
--- a/src/mongo/client/dbclientcursor.h
+++ b/src/mongo/client/dbclientcursor.h
@@ -35,7 +35,6 @@
#include "mongo/client/export_macros.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/json.h"
-#include "mongo/util/log.h"
#include "mongo/util/net/message.h"
namespace mongo {
@@ -86,17 +85,7 @@ namespace mongo {
void putBack( const BSONObj &o ) { _putBack.push( o.getOwned() ); }
/** throws AssertionException if get back { $err : ... } */
- BSONObj nextSafe() {
- MONGO_LOG_DEFAULT_COMPONENT_LOCAL(::mongo::logger::LogComponent::kNetworking);
-
- BSONObj o = next();
- if( strcmp(o.firstElementFieldName(), "$err") == 0 ) {
- std::string s = "nextSafe(): " + o.toString();
- LOG(5) << s;
- uasserted(13106, s);
- }
- return o;
- }
+ BSONObj nextSafe();
/** peek ahead at items buffered for future next() calls.
never requests new data from the server. so peek only effective
diff --git a/src/mongo/client/scoped_db_conn_test.cpp b/src/mongo/client/scoped_db_conn_test.cpp
index 71125723c36..5b75263f6a0 100644
--- a/src/mongo/client/scoped_db_conn_test.cpp
+++ b/src/mongo/client/scoped_db_conn_test.cpp
@@ -32,6 +32,7 @@
#include "mongo/util/net/message_port.h"
#include "mongo/util/net/message_server.h"
#include "mongo/util/fail_point_service.h"
+#include "mongo/util/log.h"
#include "mongo/util/time_support.h"
#include "mongo/util/timer.h"
#include "mongo/unittest/unittest.h"
diff --git a/src/mongo/db/auth/authz_manager_external_state_local.cpp b/src/mongo/db/auth/authz_manager_external_state_local.cpp
index ed28d14da90..e23d2522354 100644
--- a/src/mongo/db/auth/authz_manager_external_state_local.cpp
+++ b/src/mongo/db/auth/authz_manager_external_state_local.cpp
@@ -34,6 +34,7 @@
#include "mongo/bson/util/bson_extract.h"
#include "mongo/db/auth/authorization_manager.h"
#include "mongo/db/auth/user_document_parser.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
diff --git a/src/mongo/db/auth/authz_manager_external_state_s.cpp b/src/mongo/db/auth/authz_manager_external_state_s.cpp
index 848cd18c330..b6cdf8ed6d3 100644
--- a/src/mongo/db/auth/authz_manager_external_state_s.cpp
+++ b/src/mongo/db/auth/authz_manager_external_state_s.cpp
@@ -43,6 +43,7 @@
#include "mongo/s/type_database.h"
#include "mongo/s/grid.h"
#include "mongo/util/assert_util.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
diff --git a/src/mongo/db/auth/authz_session_external_state_server_common.cpp b/src/mongo/db/auth/authz_session_external_state_server_common.cpp
index a62b472e5ab..d6c94dca62f 100644
--- a/src/mongo/db/auth/authz_session_external_state_server_common.cpp
+++ b/src/mongo/db/auth/authz_session_external_state_server_common.cpp
@@ -33,6 +33,7 @@
#include "mongo/db/client.h"
#include "mongo/db/server_parameters.h"
#include "mongo/util/debug_util.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/auth/security_key.cpp b/src/mongo/db/auth/security_key.cpp
index efbe3bdb201..125dccbac66 100644
--- a/src/mongo/db/auth/security_key.cpp
+++ b/src/mongo/db/auth/security_key.cpp
@@ -39,6 +39,7 @@
#include "mongo/db/auth/privilege.h"
#include "mongo/db/auth/user.h"
#include "mongo/db/server_options.h"
+#include "mongo/util/log.h"
#include "mongo/util/password_digest.h"
namespace mongo {
diff --git a/src/mongo/db/auth/user_document_parser.cpp b/src/mongo/db/auth/user_document_parser.cpp
index 39ee04be0d4..341f22c9a3c 100644
--- a/src/mongo/db/auth/user_document_parser.cpp
+++ b/src/mongo/db/auth/user_document_parser.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/auth/user.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/namespace_string.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
diff --git a/src/mongo/db/catalog/collection.cpp b/src/mongo/db/catalog/collection.cpp
index 1fc7d39a64e..fd4e54b8dfd 100644
--- a/src/mongo/db/catalog/collection.cpp
+++ b/src/mongo/db/catalog/collection.cpp
@@ -45,6 +45,7 @@
#include "mongo/db/repl/repl_coordinator_global.h"
#include "mongo/db/auth/user_document_parser.h" // XXX-ANDY
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/catalog/collection_compact.cpp b/src/mongo/db/catalog/collection_compact.cpp
index c4d91c17168..1e4d7d15d97 100644
--- a/src/mongo/db/catalog/collection_compact.cpp
+++ b/src/mongo/db/catalog/collection_compact.cpp
@@ -40,6 +40,7 @@
#include "mongo/db/catalog/index_key_validate.h"
#include "mongo/db/index/index_access_method.h"
#include "mongo/db/operation_context.h"
+#include "mongo/util/log.h"
#include "mongo/util/touch_pages.h"
namespace mongo {
diff --git a/src/mongo/db/client.cpp b/src/mongo/db/client.cpp
index bead7c20752..35e2bd30f04 100644
--- a/src/mongo/db/client.cpp
+++ b/src/mongo/db/client.cpp
@@ -66,6 +66,7 @@
#include "mongo/util/concurrency/thread_name.h"
#include "mongo/util/file_allocator.h"
#include "mongo/util/mongoutils/str.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/commands.cpp b/src/mongo/db/commands.cpp
index 67a1f730f3b..951a8ab8d27 100644
--- a/src/mongo/db/commands.cpp
+++ b/src/mongo/db/commands.cpp
@@ -47,6 +47,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/server_parameters.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/commands/auth_schema_upgrade_d.cpp b/src/mongo/db/commands/auth_schema_upgrade_d.cpp
index 962820d262c..0de0cb58e72 100644
--- a/src/mongo/db/commands/auth_schema_upgrade_d.cpp
+++ b/src/mongo/db/commands/auth_schema_upgrade_d.cpp
@@ -37,6 +37,7 @@
#include "mongo/db/repl/repl_coordinator_global.h"
#include "mongo/db/repl/rs.h"
#include "mongo/db/repl/rs_config.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/version.h"
diff --git a/src/mongo/db/commands/authentication_commands.cpp b/src/mongo/db/commands/authentication_commands.cpp
index de6229524af..9124abc46be 100644
--- a/src/mongo/db/commands/authentication_commands.cpp
+++ b/src/mongo/db/commands/authentication_commands.cpp
@@ -51,6 +51,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/platform/random.h"
#include "mongo/util/concurrency/mutex.h"
+#include "mongo/util/log.h"
#include "mongo/util/md5.hpp"
#include "mongo/util/net/ssl_manager.h"
#include "mongo/util/text.h"
diff --git a/src/mongo/db/commands/clone_collection.cpp b/src/mongo/db/commands/clone_collection.cpp
index c0e7ce576aa..5dc75a5dba4 100644
--- a/src/mongo/db/commands/clone_collection.cpp
+++ b/src/mongo/db/commands/clone_collection.cpp
@@ -51,6 +51,7 @@
#include "mongo/db/repl/oplogreader.h"
#include "mongo/db/operation_context_impl.h"
#include "mongo/db/storage_options.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/commands/compact.cpp b/src/mongo/db/commands/compact.cpp
index 4ff1e8d85fc..a31b84cf1b9 100644
--- a/src/mongo/db/commands/compact.cpp
+++ b/src/mongo/db/commands/compact.cpp
@@ -44,6 +44,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/operation_context_impl.h"
#include "mongo/db/repl/repl_coordinator_global.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/commands/count.cpp b/src/mongo/db/commands/count.cpp
index d49203cedfb..ea74c4e7c2b 100644
--- a/src/mongo/db/commands/count.cpp
+++ b/src/mongo/db/commands/count.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/query/get_executor.h"
#include "mongo/db/query/explain.h"
#include "mongo/db/query/type_explain.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/commands/dbhash.cpp b/src/mongo/db/commands/dbhash.cpp
index 945a9e8ebb2..2125dd85e8c 100644
--- a/src/mongo/db/commands/dbhash.cpp
+++ b/src/mongo/db/commands/dbhash.cpp
@@ -35,6 +35,7 @@
#include "mongo/db/catalog/database.h"
#include "mongo/db/catalog/database_catalog_entry.h"
#include "mongo/db/query/internal_plans.h"
+#include "mongo/util/log.h"
#include "mongo/util/md5.hpp"
#include "mongo/util/timer.h"
diff --git a/src/mongo/db/commands/fsync.cpp b/src/mongo/db/commands/fsync.cpp
index 4bf4a742cdb..8db840c2338 100644
--- a/src/mongo/db/commands/fsync.cpp
+++ b/src/mongo/db/commands/fsync.cpp
@@ -46,6 +46,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/operation_context_impl.h"
#include "mongo/util/background.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/commands/geo_near_cmd.cpp b/src/mongo/db/commands/geo_near_cmd.cpp
index 7b85946e9cf..7631e2f279b 100644
--- a/src/mongo/db/commands/geo_near_cmd.cpp
+++ b/src/mongo/db/commands/geo_near_cmd.cpp
@@ -44,6 +44,7 @@
#include "mongo/db/query/explain.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/platform/unordered_map.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/commands/isself.cpp b/src/mongo/db/commands/isself.cpp
index 1f9e154b07c..0339cfdb0e6 100644
--- a/src/mongo/db/commands/isself.cpp
+++ b/src/mongo/db/commands/isself.cpp
@@ -60,4 +60,4 @@ namespace mongo {
return Status::OK();
}
-}
+} // namespace mongo
diff --git a/src/mongo/db/commands/server_status.cpp b/src/mongo/db/commands/server_status.cpp
index 49a4cacb303..9ff11711e40 100644
--- a/src/mongo/db/commands/server_status.cpp
+++ b/src/mongo/db/commands/server_status.cpp
@@ -42,6 +42,7 @@
#include "mongo/db/commands/server_status_metric.h"
#include "mongo/db/stats/counters.h"
#include "mongo/platform/process_id.h"
+#include "mongo/util/log.h"
#include "mongo/util/net/listen.h"
#include "mongo/util/net/ssl_manager.h"
#include "mongo/util/processinfo.h"
diff --git a/src/mongo/db/commands/test_commands.cpp b/src/mongo/db/commands/test_commands.cpp
index 97a61695193..7583929a3eb 100644
--- a/src/mongo/db/commands/test_commands.cpp
+++ b/src/mongo/db/commands/test_commands.cpp
@@ -39,6 +39,7 @@
#include "mongo/db/catalog/collection.h"
#include "mongo/db/repl/oplog.h"
#include "mongo/db/operation_context_impl.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/commands/user_management_commands.cpp b/src/mongo/db/commands/user_management_commands.cpp
index e0fe630cf45..4139481645f 100644
--- a/src/mongo/db/commands/user_management_commands.cpp
+++ b/src/mongo/db/commands/user_management_commands.cpp
@@ -56,6 +56,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/platform/unordered_set.h"
#include "mongo/stdx/functional.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/net/ssl_manager.h"
#include "mongo/util/sequence_util.h"
diff --git a/src/mongo/db/d_concurrency.cpp b/src/mongo/db/d_concurrency.cpp
index 737118f2a2a..2c7fcffd4ea 100644
--- a/src/mongo/db/d_concurrency.cpp
+++ b/src/mongo/db/d_concurrency.cpp
@@ -47,6 +47,7 @@
#include "mongo/util/concurrency/qlock.h"
#include "mongo/util/concurrency/rwlock.h"
#include "mongo/util/concurrency/threadlocal.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/stacktrace.h"
diff --git a/src/mongo/db/dbcommands_generic.cpp b/src/mongo/db/dbcommands_generic.cpp
index 6b276d4c871..6a466cc0dd4 100644
--- a/src/mongo/db/dbcommands_generic.cpp
+++ b/src/mongo/db/dbcommands_generic.cpp
@@ -57,6 +57,7 @@
#include "mongo/util/exit.h"
#include "mongo/util/fail_point.h"
#include "mongo/util/fail_point_service.h"
+#include "mongo/util/log.h"
#include "mongo/util/md5.hpp"
#include "mongo/util/processinfo.h"
#include "mongo/util/ramlog.h"
diff --git a/src/mongo/db/dbeval.cpp b/src/mongo/db/dbeval.cpp
index 355f725026e..b34e07058f4 100644
--- a/src/mongo/db/dbeval.cpp
+++ b/src/mongo/db/dbeval.cpp
@@ -41,6 +41,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/json.h"
#include "mongo/scripting/engine.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/exec/collection_scan.cpp b/src/mongo/db/exec/collection_scan.cpp
index 963d2a3ef4e..ab03475676e 100644
--- a/src/mongo/db/exec/collection_scan.cpp
+++ b/src/mongo/db/exec/collection_scan.cpp
@@ -34,6 +34,7 @@
#include "mongo/db/exec/working_set.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/util/fail_point_service.h"
+#include "mongo/util/log.h"
#include "mongo/db/client.h" // XXX-ERH
diff --git a/src/mongo/db/exec/delete.cpp b/src/mongo/db/exec/delete.cpp
index f06fac15398..fda4b8ba779 100644
--- a/src/mongo/db/exec/delete.cpp
+++ b/src/mongo/db/exec/delete.cpp
@@ -34,6 +34,7 @@
#include "mongo/db/exec/working_set_common.h"
#include "mongo/db/repl/oplog.h"
#include "mongo/db/repl/repl_coordinator_global.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/exec/geo_near.cpp b/src/mongo/db/exec/geo_near.cpp
index 1c5a045a914..270a18152d2 100644
--- a/src/mongo/db/exec/geo_near.cpp
+++ b/src/mongo/db/exec/geo_near.cpp
@@ -40,6 +40,7 @@
#include "mongo/db/matcher/expression.h"
#include "mongo/db/query/expression_index.h"
#include "mongo/db/query/expression_index_knobs.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/exec/index_scan.cpp b/src/mongo/db/exec/index_scan.cpp
index 0d165623ee1..a16ed4ab33b 100644
--- a/src/mongo/db/exec/index_scan.cpp
+++ b/src/mongo/db/exec/index_scan.cpp
@@ -34,6 +34,7 @@
#include "mongo/db/index/index_cursor.h"
#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/query/explain.h"
+#include "mongo/util/log.h"
namespace {
diff --git a/src/mongo/db/exec/projection.cpp b/src/mongo/db/exec/projection.cpp
index 244b68540d6..de6f8885dd2 100644
--- a/src/mongo/db/exec/projection.cpp
+++ b/src/mongo/db/exec/projection.cpp
@@ -33,6 +33,7 @@
#include "mongo/db/exec/working_set_common.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/matcher/expression.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
diff --git a/src/mongo/db/fts/fts_command.cpp b/src/mongo/db/fts/fts_command.cpp
index 128b5a9f255..21a7e86fc6c 100644
--- a/src/mongo/db/fts/fts_command.cpp
+++ b/src/mongo/db/fts/fts_command.cpp
@@ -33,6 +33,7 @@
#include "mongo/db/fts/fts_command.h"
#include "mongo/db/fts/fts_util.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/timer.h"
diff --git a/src/mongo/db/fts/fts_enabled.cpp b/src/mongo/db/fts/fts_enabled.cpp
index 25a4619eae1..0d20f0eb039 100644
--- a/src/mongo/db/fts/fts_enabled.cpp
+++ b/src/mongo/db/fts/fts_enabled.cpp
@@ -30,6 +30,8 @@
#include "mongo/db/server_parameters.h"
+#include "mongo/util/log.h"
+
namespace mongo {
namespace fts {
namespace {
diff --git a/src/mongo/db/fts/fts_index_format_test.cpp b/src/mongo/db/fts/fts_index_format_test.cpp
index 09a3766f94e..ee7d8f7208d 100644
--- a/src/mongo/db/fts/fts_index_format_test.cpp
+++ b/src/mongo/db/fts/fts_index_format_test.cpp
@@ -34,6 +34,7 @@
#include <set>
#include "mongo/db/fts/fts_index_format.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/unittest/unittest.h"
diff --git a/src/mongo/db/geo/geo_query.cpp b/src/mongo/db/geo/geo_query.cpp
index 60cf9665bb7..22270a2732e 100644
--- a/src/mongo/db/geo/geo_query.cpp
+++ b/src/mongo/db/geo/geo_query.cpp
@@ -29,6 +29,7 @@
#include "mongo/db/geo/geo_query.h"
#include "mongo/db/geo/geoparser.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
diff --git a/src/mongo/db/geo/geoparser.cpp b/src/mongo/db/geo/geoparser.cpp
index 658e145efb1..e34be56007e 100644
--- a/src/mongo/db/geo/geoparser.cpp
+++ b/src/mongo/db/geo/geoparser.cpp
@@ -33,6 +33,7 @@
#include "mongo/db/geo/shapes.h"
#include "mongo/db/jsobj.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
#include "third_party/s2/s2polygonbuilder.h"
diff --git a/src/mongo/db/geo/r2_region_coverer_test.cpp b/src/mongo/db/geo/r2_region_coverer_test.cpp
index e3d1c980c71..34c91d13634 100644
--- a/src/mongo/db/geo/r2_region_coverer_test.cpp
+++ b/src/mongo/db/geo/r2_region_coverer_test.cpp
@@ -32,6 +32,7 @@
#include "mongo/platform/random.h"
#include "mongo/bson/bsonmisc.h"
#include "mongo/db/geo/geometry_container.h"
+#include "mongo/util/log.h"
namespace {
diff --git a/src/mongo/db/global_environment_d.cpp b/src/mongo/db/global_environment_d.cpp
index 27155f89c3d..76a658543f8 100644
--- a/src/mongo/db/global_environment_d.cpp
+++ b/src/mongo/db/global_environment_d.cpp
@@ -35,6 +35,7 @@
#include "mongo/db/operation_context_impl.h"
#include "mongo/db/storage/storage_engine.h"
#include "mongo/scripting/engine.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/index/SConscript b/src/mongo/db/index/SConscript
index 8d062d13878..5d28d1990ad 100644
--- a/src/mongo/db/index/SConscript
+++ b/src/mongo/db/index/SConscript
@@ -3,6 +3,15 @@
Import("env")
env.Library(
+ target='index_descriptor',
+ source=[
+ 'index_descriptor.cpp',
+ ],
+ LIBDEPS=[
+ ],
+)
+
+env.Library(
target='key_generator',
source=[
'btree_key_generator.cpp',
diff --git a/src/mongo/db/index/btree_based_access_method.cpp b/src/mongo/db/index/btree_based_access_method.cpp
index ac1ac47f39a..afed5a92661 100644
--- a/src/mongo/db/index/btree_based_access_method.cpp
+++ b/src/mongo/db/index/btree_based_access_method.cpp
@@ -40,6 +40,7 @@
#include "mongo/db/pdfile_private.h"
#include "mongo/db/server_parameters.h"
#include "mongo/db/operation_context.h"
+#include "mongo/util/log.h"
#include "mongo/util/progress_meter.h"
diff --git a/src/mongo/db/index/expression_keys_private.cpp b/src/mongo/db/index/expression_keys_private.cpp
index 44be3b10aa8..0cbdcf1f6e0 100644
--- a/src/mongo/db/index/expression_keys_private.cpp
+++ b/src/mongo/db/index/expression_keys_private.cpp
@@ -39,6 +39,7 @@
#include "mongo/db/index_names.h"
#include "mongo/db/index/2d_common.h"
#include "mongo/util/assert_util.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
#include "third_party/s2/s2cell.h"
#include "third_party/s2/s2regioncoverer.h"
diff --git a/src/mongo/db/index/index_descriptor.cpp b/src/mongo/db/index/index_descriptor.cpp
index e227be9e914..758d07bc927 100644
--- a/src/mongo/db/index/index_descriptor.cpp
+++ b/src/mongo/db/index/index_descriptor.cpp
@@ -29,6 +29,7 @@
*/
#include "mongo/db/index/index_descriptor.h"
+#include "mongo/util/log.h"
namespace mongo {
@@ -80,4 +81,11 @@ namespace mongo {
return existingOptionsMap == newOptionsMap;
}
+ void IndexDescriptor::_checkOk() const {
+ if ( _magic == 123987 )
+ return;
+ log() << "uh oh: " << (void*)(this) << " " << _magic;
+ invariant(0);
+ }
+
}
diff --git a/src/mongo/db/index/index_descriptor.h b/src/mongo/db/index/index_descriptor.h
index ce1bb344644..64b67d6c76a 100644
--- a/src/mongo/db/index/index_descriptor.h
+++ b/src/mongo/db/index/index_descriptor.h
@@ -178,12 +178,7 @@ namespace mongo {
private:
- void _checkOk() const {
- if ( _magic == 123987 )
- return;
- log() << "uh oh: " << (void*)(this) << " " << _magic;
- verify(0);
- }
+ void _checkOk() const;
int _magic;
diff --git a/src/mongo/db/index/s2_access_method.cpp b/src/mongo/db/index/s2_access_method.cpp
index 3f4b0f95deb..fe8d41d5f0f 100644
--- a/src/mongo/db/index/s2_access_method.cpp
+++ b/src/mongo/db/index/s2_access_method.cpp
@@ -38,6 +38,7 @@
#include "mongo/db/index/expression_keys_private.h"
#include "mongo/db/index/expression_params.h"
#include "mongo/db/jsobj.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/index_rebuilder.cpp b/src/mongo/db/index_rebuilder.cpp
index 83765f06728..f8854feae14 100644
--- a/src/mongo/db/index_rebuilder.cpp
+++ b/src/mongo/db/index_rebuilder.cpp
@@ -45,7 +45,7 @@
namespace mongo {
- MONGO_LOG_DEFAULT_COMPONENT_FILE(::mongo::logger::LogComponent::kStorage);
+ MONGO_LOG_DEFAULT_COMPONENT_FILE(::mongo::logger::LogComponent::kIndexing);
IndexRebuilder indexRebuilder;
diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp
index 3abd2c8ebf5..411ee1cf85a 100644
--- a/src/mongo/db/instance.cpp
+++ b/src/mongo/db/instance.cpp
@@ -337,6 +337,7 @@ namespace mongo {
Message& m,
DbResponse& dbresponse,
const HostAndPort& remote ) {
+ MONGO_LOG_DEFAULT_COMPONENT_LOCAL(::mongo::logger::LogComponent::kQuery);
// before we lock...
int op = m.operation();
diff --git a/src/mongo/db/introspect.cpp b/src/mongo/db/introspect.cpp
index c32d1f71efb..4e6cf821604 100644
--- a/src/mongo/db/introspect.cpp
+++ b/src/mongo/db/introspect.cpp
@@ -41,6 +41,7 @@
#include "mongo/db/storage_options.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/util/goodies.h"
+#include "mongo/util/log.h"
namespace {
const size_t MAX_PROFILE_DOC_SIZE_BYTES = 100*1024;
diff --git a/src/mongo/db/json.cpp b/src/mongo/db/json.cpp
index 130d453c7ac..a7ed1b5959d 100644
--- a/src/mongo/db/json.cpp
+++ b/src/mongo/db/json.cpp
@@ -33,6 +33,7 @@
#include "mongo/platform/strtoll.h"
#include "mongo/util/base64.h"
#include "mongo/util/hex.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/time_support.h"
diff --git a/src/mongo/db/lasterror.cpp b/src/mongo/db/lasterror.cpp
index 130254c4a8f..b3bc72f068d 100644
--- a/src/mongo/db/lasterror.cpp
+++ b/src/mongo/db/lasterror.cpp
@@ -27,11 +27,12 @@
* then also delete it in the license file.
*/
-#include "mongo/pch.h"
+#include "mongo/platform/basic.h"
#include "mongo/db/lasterror.h"
#include "mongo/db/jsobj.h"
+#include "mongo/util/log.h"
#include "mongo/util/net/message.h"
namespace mongo {
@@ -117,6 +118,15 @@ namespace mongo {
return 0;
}
+ LastError * LastErrorHolder::getSafe() {
+ LastError * le = get(false);
+ if ( ! le ) {
+ error() << " no LastError!" << std::endl;
+ verify( le );
+ }
+ return le;
+ }
+
LastError * LastErrorHolder::_get( bool create ) {
LastError * le = _tl.get();
if ( ! le && create ) {
diff --git a/src/mongo/db/lasterror.h b/src/mongo/db/lasterror.h
index 45788c08ab2..d1f953734f0 100644
--- a/src/mongo/db/lasterror.h
+++ b/src/mongo/db/lasterror.h
@@ -34,7 +34,6 @@
#include "mongo/db/jsobj.h"
#include "mongo/bson/oid.h"
-#include "mongo/util/log.h"
namespace mongo {
class BSONObjBuilder;
@@ -136,15 +135,7 @@ namespace mongo {
~LastErrorHolder();
LastError * get( bool create = false );
- LastError * getSafe() {
- LastError * le = get(false);
- if ( ! le ) {
- error() << " no LastError!" << std::endl;
- verify( le );
- }
- return le;
- }
-
+ LastError * getSafe();
LastError * _get( bool create = false ); // may return a disabled LastError
void reset( LastError * le );
diff --git a/src/mongo/db/lockstat.h b/src/mongo/db/lockstat.h
index cf0e43c50ad..82b24e3c004 100644
--- a/src/mongo/db/lockstat.h
+++ b/src/mongo/db/lockstat.h
@@ -31,6 +31,7 @@
#pragma once
+#include "mongo/bson/util/builder.h"
#include "mongo/platform/atomic_word.h"
#include "mongo/util/timer.h"
diff --git a/src/mongo/db/lockstate.cpp b/src/mongo/db/lockstate.cpp
index 372a34c5641..3e5744703f7 100644
--- a/src/mongo/db/lockstate.cpp
+++ b/src/mongo/db/lockstate.cpp
@@ -31,6 +31,7 @@
#include "mongo/db/lockstate.h"
#include "mongo/db/namespace_string.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
diff --git a/src/mongo/db/log_process_details.cpp b/src/mongo/db/log_process_details.cpp
index a851444f5cd..955ae0557b2 100644
--- a/src/mongo/db/log_process_details.cpp
+++ b/src/mongo/db/log_process_details.cpp
@@ -34,6 +34,7 @@
#include "mongo/db/server_options.h"
#include "mongo/db/server_options_helpers.h"
+#include "mongo/util/log.h"
#include "mongo/util/net/sock.h"
#include "mongo/util/net/ssl_manager.h"
#include "mongo/util/processinfo.h"
diff --git a/src/mongo/db/matcher/expression_parser_leaf_test.cpp b/src/mongo/db/matcher/expression_parser_leaf_test.cpp
index 594cd5d7309..42cf3a37887 100644
--- a/src/mongo/db/matcher/expression_parser_leaf_test.cpp
+++ b/src/mongo/db/matcher/expression_parser_leaf_test.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/json.h"
#include "mongo/db/matcher/expression.h"
#include "mongo/db/matcher/expression_leaf.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/matcher/path.cpp b/src/mongo/db/matcher/path.cpp
index cd4f1ee9c0a..ae8a884d3cc 100644
--- a/src/mongo/db/matcher/path.cpp
+++ b/src/mongo/db/matcher/path.cpp
@@ -32,6 +32,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/matcher/path_internal.h"
#include "mongo/db/matcher/path.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/mongod_options.cpp b/src/mongo/db/mongod_options.cpp
index eedead3865c..5d17679c6c5 100644
--- a/src/mongo/db/mongod_options.cpp
+++ b/src/mongo/db/mongod_options.cpp
@@ -41,6 +41,7 @@
#include "mongo/db/repl/repl_settings.h"
#include "mongo/db/server_options.h"
#include "mongo/db/server_options_helpers.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/net/ssl_options.h"
#include "mongo/util/options_parser/startup_options.h"
diff --git a/src/mongo/db/operation_context_impl.cpp b/src/mongo/db/operation_context_impl.cpp
index ea82457cc9b..fed76022dbb 100644
--- a/src/mongo/db/operation_context_impl.cpp
+++ b/src/mongo/db/operation_context_impl.cpp
@@ -35,6 +35,7 @@
#include "mongo/db/repl/repl_coordinator_global.h"
#include "mongo/db/storage/storage_engine.h"
#include "mongo/platform/random.h"
+#include "mongo/util/log.h"
#include "mongo/util/fail_point_service.h"
namespace mongo {
diff --git a/src/mongo/db/ops/delete_executor.cpp b/src/mongo/db/ops/delete_executor.cpp
index ba36650e634..607c13fc4e5 100644
--- a/src/mongo/db/ops/delete_executor.cpp
+++ b/src/mongo/db/ops/delete_executor.cpp
@@ -38,6 +38,7 @@
#include "mongo/db/query/get_executor.h"
#include "mongo/db/repl/repl_coordinator_global.h"
#include "mongo/util/assert_util.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
diff --git a/src/mongo/db/ops/update_result.cpp b/src/mongo/db/ops/update_result.cpp
new file mode 100644
index 00000000000..be3d39abe3f
--- /dev/null
+++ b/src/mongo/db/ops/update_result.cpp
@@ -0,0 +1,58 @@
+//@file update_result.cpp
+
+/**
+ * Copyright (C) 2008-2014 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#include "mongo/platform/basic.h"
+
+#include "mongo/db/ops/update_result.h"
+
+#include "mongo/util/log.h"
+
+namespace mongo {
+
+ MONGO_LOG_DEFAULT_COMPONENT_FILE(::mongo::logger::LogComponent::kQuery);
+
+ UpdateResult::UpdateResult(bool existing_,
+ bool modifiers_,
+ unsigned long long numDocsModified_,
+ unsigned long long numMatched_,
+ const BSONObj& upsertedObject_)
+ : existing(existing_),
+ modifiers(modifiers_),
+ numDocsModified(numDocsModified_),
+ numMatched(numMatched_) {
+
+ BSONElement id = upsertedObject_["_id"];
+ if ( ! existing && numMatched == 1 && !id.eoo() ) {
+ upserted = id.wrap(kUpsertedFieldName);
+ }
+ LOG(4) << "UpdateResult -- " << toString();
+ }
+
+} // namespace mongo
diff --git a/src/mongo/db/ops/update_result.h b/src/mongo/db/ops/update_result.h
index 46174da538e..276813ae150 100644
--- a/src/mongo/db/ops/update_result.h
+++ b/src/mongo/db/ops/update_result.h
@@ -31,7 +31,6 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/curop.h"
#include "mongo/db/namespace_string.h"
-#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
@@ -44,20 +43,7 @@ namespace mongo {
bool modifiers_,
unsigned long long numDocsModified_,
unsigned long long numMatched_,
- const BSONObj& upsertedObject_ )
- : existing(existing_)
- , modifiers(modifiers_)
- , numDocsModified(numDocsModified_)
- , numMatched(numMatched_) {
- MONGO_LOG_DEFAULT_COMPONENT_LOCAL(::mongo::logger::LogComponent::kQuery);
-
- BSONElement id = upsertedObject_["_id"];
- if ( ! existing && numMatched == 1 && !id.eoo() ) {
- upserted = id.wrap(kUpsertedFieldName);
- }
-
- LOG(4) << "UpdateResult -- " << toString();
- }
+ const BSONObj& upsertedObject_ );
// if existing objects were modified
diff --git a/src/mongo/db/query/SConscript b/src/mongo/db/query/SConscript
index 769d6f59aa1..91d3af5be9b 100644
--- a/src/mongo/db/query/SConscript
+++ b/src/mongo/db/query/SConscript
@@ -16,6 +16,7 @@ env.Library(
"planner_ixselect.cpp",
"query_knobs.cpp",
"query_planner.cpp",
+ "query_planner_common.cpp",
"query_solution.cpp",
],
LIBDEPS=[
diff --git a/src/mongo/db/query/canonical_query.cpp b/src/mongo/db/query/canonical_query.cpp
index 603c636a403..a8b501821ba 100644
--- a/src/mongo/db/query/canonical_query.cpp
+++ b/src/mongo/db/query/canonical_query.cpp
@@ -32,6 +32,7 @@
#include "mongo/db/matcher/expression_array.h"
#include "mongo/db/matcher/expression_geo.h"
#include "mongo/db/query/query_planner_common.h"
+#include "mongo/util/log.h"
namespace {
diff --git a/src/mongo/db/query/index_bounds_builder.cpp b/src/mongo/db/query/index_bounds_builder.cpp
index af8621090cd..87a2a8ea135 100644
--- a/src/mongo/db/query/index_bounds_builder.cpp
+++ b/src/mongo/db/query/index_bounds_builder.cpp
@@ -37,6 +37,7 @@
#include "mongo/db/query/indexability.h"
#include "mongo/db/query/qlog.h"
#include "mongo/db/query/query_knobs.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/db/geo/s2.h"
#include "third_party/s2/s2cell.h"
diff --git a/src/mongo/db/query/plan_enumerator.cpp b/src/mongo/db/query/plan_enumerator.cpp
index c958dc3d3a2..94a66d3d952 100644
--- a/src/mongo/db/query/plan_enumerator.cpp
+++ b/src/mongo/db/query/plan_enumerator.cpp
@@ -33,6 +33,7 @@
#include "mongo/db/query/indexability.h"
#include "mongo/db/query/index_tag.h"
#include "mongo/db/query/qlog.h"
+#include "mongo/util/log.h"
namespace {
diff --git a/src/mongo/db/query/planner_access.cpp b/src/mongo/db/query/planner_access.cpp
index 4c32b4c4277..cb43096e9ae 100644
--- a/src/mongo/db/query/planner_access.cpp
+++ b/src/mongo/db/query/planner_access.cpp
@@ -40,6 +40,7 @@
#include "mongo/db/query/qlog.h"
#include "mongo/db/query/query_planner.h"
#include "mongo/db/query/query_planner_common.h"
+#include "mongo/util/log.h"
namespace {
diff --git a/src/mongo/db/query/planner_ixselect.cpp b/src/mongo/db/query/planner_ixselect.cpp
index 864f05d39b3..f2067f651dc 100644
--- a/src/mongo/db/query/planner_ixselect.cpp
+++ b/src/mongo/db/query/planner_ixselect.cpp
@@ -39,6 +39,7 @@
#include "mongo/db/query/index_tag.h"
#include "mongo/db/query/qlog.h"
#include "mongo/db/query/query_planner_common.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/query/qlog.h b/src/mongo/db/query/qlog.h
index 1d0ada2fb99..3050877ba2b 100644
--- a/src/mongo/db/query/qlog.h
+++ b/src/mongo/db/query/qlog.h
@@ -28,9 +28,11 @@
#pragma once
-#include <ostream>
-
-#include "mongo/util/log.h"
+#include "mongo/logger/log_component.h"
+#include "mongo/logger/log_severity.h"
+#include "mongo/logger/logger.h"
+#include "mongo/logger/logstream_builder.h"
+#include "mongo/util/concurrency/thread_name.h"
namespace mongo {
@@ -57,7 +59,9 @@ namespace mongo {
const logger::LogSeverity verboseQueryLogSeverity = logger::LogSeverity::Debug(5);
// With a #define like this, we don't evaluate the costly toString()s that are QLOG'd
-#define QLOG() MONGO_LOG_COMPONENT(verboseQueryLogSeverity, verboseQueryLogComponent) << "[QLOG] "
+#define QLOG() \
+ if (!(::mongo::logger::globalLogDomain())->shouldLog(::mongo::verboseQueryLogComponent, ::mongo::verboseQueryLogSeverity)) {} \
+ else ::mongo::logger::LogstreamBuilder(::mongo::logger::globalLogDomain(), ::mongo::getThreadName(), ::mongo::verboseQueryLogSeverity, ::mongo::verboseQueryLogComponent) << "[QLOG] "
bool qlogOff();
bool qlogOn();
diff --git a/src/mongo/db/query/query_planner_common.cpp b/src/mongo/db/query/query_planner_common.cpp
new file mode 100644
index 00000000000..c31252e3c37
--- /dev/null
+++ b/src/mongo/db/query/query_planner_common.cpp
@@ -0,0 +1,86 @@
+/**
+ * Copyright (C) 2014 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#include "mongo/platform/basic.h"
+
+#include "mongo/db/query/query_planner_common.h"
+
+#include "mongo/db/query/qlog.h"
+#include "mongo/util/assert_util.h"
+
+namespace mongo {
+
+ void QueryPlannerCommon::reverseScans(QuerySolutionNode* node) {
+ StageType type = node->getType();
+
+ if (STAGE_IXSCAN == type) {
+ IndexScanNode* isn = static_cast<IndexScanNode*>(node);
+ isn->direction *= -1;
+
+ if (isn->bounds.isSimpleRange) {
+ std::swap(isn->bounds.startKey, isn->bounds.endKey);
+ // XXX: Not having a startKeyInclusive means that if we reverse a max/min query
+ // we have different results with and without the reverse...
+ isn->bounds.endKeyInclusive = true;
+ }
+ else {
+ for (size_t i = 0; i < isn->bounds.fields.size(); ++i) {
+ std::vector<Interval>& iv = isn->bounds.fields[i].intervals;
+ // Step 1: reverse the list.
+ std::reverse(iv.begin(), iv.end());
+ // Step 2: reverse each interval.
+ for (size_t j = 0; j < iv.size(); ++j) {
+ iv[j].reverse();
+ }
+ }
+ }
+
+ if (!isn->bounds.isValidFor(isn->indexKeyPattern, isn->direction)) {
+ QLOG() << "Invalid bounds: " << isn->bounds.toString() << std::endl;
+ invariant(0);
+ }
+
+ // TODO: we can just negate every value in the already computed properties.
+ isn->computeProperties();
+ }
+ else if (STAGE_SORT_MERGE == type) {
+ // reverse direction of comparison for merge
+ MergeSortNode* msn = static_cast<MergeSortNode*>(node);
+ msn->sort = reverseSortObj(msn->sort);
+ }
+ else {
+ invariant(STAGE_SORT != type);
+ // This shouldn't be here...
+ }
+
+ for (size_t i = 0; i < node->children.size(); ++i) {
+ reverseScans(node->children[i]);
+ }
+ }
+
+} // namespace mongo
diff --git a/src/mongo/db/query/query_planner_common.h b/src/mongo/db/query/query_planner_common.h
index 2caa2545be3..848e0f00ba1 100644
--- a/src/mongo/db/query/query_planner_common.h
+++ b/src/mongo/db/query/query_planner_common.h
@@ -31,7 +31,6 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/matcher/expression.h"
#include "mongo/db/query/query_solution.h"
-#include "mongo/db/query/qlog.h"
namespace mongo {
@@ -80,53 +79,8 @@ namespace mongo {
* Traverses the tree rooted at 'node'. For every STAGE_IXSCAN encountered, reverse
* the scan direction and index bounds.
*/
- static void reverseScans(QuerySolutionNode* node) {
- StageType type = node->getType();
+ static void reverseScans(QuerySolutionNode* node);
- if (STAGE_IXSCAN == type) {
- IndexScanNode* isn = static_cast<IndexScanNode*>(node);
- isn->direction *= -1;
-
- if (isn->bounds.isSimpleRange) {
- std::swap(isn->bounds.startKey, isn->bounds.endKey);
- // XXX: Not having a startKeyInclusive means that if we reverse a max/min query
- // we have different results with and without the reverse...
- isn->bounds.endKeyInclusive = true;
- }
- else {
- for (size_t i = 0; i < isn->bounds.fields.size(); ++i) {
- std::vector<Interval>& iv = isn->bounds.fields[i].intervals;
- // Step 1: reverse the list.
- std::reverse(iv.begin(), iv.end());
- // Step 2: reverse each interval.
- for (size_t j = 0; j < iv.size(); ++j) {
- iv[j].reverse();
- }
- }
- }
-
- if (!isn->bounds.isValidFor(isn->indexKeyPattern, isn->direction)) {
- QLOG() << "Invalid bounds: " << isn->bounds.toString() << std::endl;
- verify(0);
- }
-
- // TODO: we can just negate every value in the already computed properties.
- isn->computeProperties();
- }
- else if (STAGE_SORT_MERGE == type) {
- // reverse direction of comparison for merge
- MergeSortNode* msn = static_cast<MergeSortNode*>(node);
- msn->sort = reverseSortObj(msn->sort);
- }
- else {
- verify(STAGE_SORT != type);
- // This shouldn't be here...
- }
-
- for (size_t i = 0; i < node->children.size(); ++i) {
- reverseScans(node->children[i]);
- }
- }
};
} // namespace mongo
diff --git a/src/mongo/db/query/query_planner_test.cpp b/src/mongo/db/query/query_planner_test.cpp
index 93b87844da6..b10d874f400 100644
--- a/src/mongo/db/query/query_planner_test.cpp
+++ b/src/mongo/db/query/query_planner_test.cpp
@@ -42,6 +42,7 @@
#include "mongo/db/query/query_solution.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/assert_util.h"
+#include "mongo/util/log.h"
using namespace mongo;
diff --git a/src/mongo/db/query/stage_builder.cpp b/src/mongo/db/query/stage_builder.cpp
index 7621abbd9e1..d82ef8bb657 100644
--- a/src/mongo/db/query/stage_builder.cpp
+++ b/src/mongo/db/query/stage_builder.cpp
@@ -49,6 +49,7 @@
#include "mongo/db/index/fts_access_method.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/range_deleter_db_env.cpp b/src/mongo/db/range_deleter_db_env.cpp
index 29e96e4ead4..dcce2025b01 100644
--- a/src/mongo/db/range_deleter_db_env.cpp
+++ b/src/mongo/db/range_deleter_db_env.cpp
@@ -37,6 +37,7 @@
#include "mongo/db/repl/rs.h"
#include "mongo/db/write_concern_options.h"
#include "mongo/s/d_logic.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript
index 0d17be5942d..e9803d19eb9 100644
--- a/src/mongo/db/repl/SConscript
+++ b/src/mongo/db/repl/SConscript
@@ -47,6 +47,7 @@ env.Library('repl_coordinator_impl',
LIBDEPS=['$BUILD_DIR/mongo/db/common',
'$BUILD_DIR/mongo/fail_point',
'$BUILD_DIR/mongo/foundation',
+ '$BUILD_DIR/mongo/db/index/index_descriptor',
'$BUILD_DIR/mongo/server_options_core',
'repl_coordinator_interface',
'replica_set_messages',
diff --git a/src/mongo/db/repl/connections.cpp b/src/mongo/db/repl/connections.cpp
new file mode 100644
index 00000000000..b5811792a5c
--- /dev/null
+++ b/src/mongo/db/repl/connections.cpp
@@ -0,0 +1,62 @@
+// @connections.cpp
+
+/*
+ * Copyright (C) 2014 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#include "mongo/platform/basic.h"
+
+#include "mongo/db/repl/connections.h"
+
+#include "mongo/util/log.h"
+
+namespace mongo {
+namespace repl {
+
+ // we should already be locked...
+ bool ScopedConn::connect() {
+ std::string err;
+ if (!connInfo->cc->connect(HostAndPort(_hostport), err)) {
+ log() << "couldn't connect to " << _hostport << ": " << err << rsLog;
+ return false;
+ }
+ connInfo->connected = true;
+ connInfo->tagPort();
+
+ // if we cannot authenticate against a member, then either its key file
+ // or our key file has to change. if our key file has to change, we'll
+ // be rebooting. if their file has to change, they'll be rebooted so the
+ // connection created above will go dead, reconnect, and reauth.
+ if (getGlobalAuthorizationManager()->isAuthEnabled()) {
+ return authenticateInternalUser(connInfo->cc.get());
+ }
+
+ return true;
+ }
+
+} // namespace repl
+} // namespace mongo
diff --git a/src/mongo/db/repl/connections.h b/src/mongo/db/repl/connections.h
index eadf4e92d49..62eb727ed4a 100644
--- a/src/mongo/db/repl/connections.h
+++ b/src/mongo/db/repl/connections.h
@@ -130,25 +130,8 @@ namespace repl {
const std::string _hostport;
// we should already be locked...
- bool connect() {
- std::string err;
- if (!connInfo->cc->connect(HostAndPort(_hostport), err)) {
- log() << "couldn't connect to " << _hostport << ": " << err << rsLog;
- return false;
- }
- connInfo->connected = true;
- connInfo->tagPort();
-
- // if we cannot authenticate against a member, then either its key file
- // or our key file has to change. if our key file has to change, we'll
- // be rebooting. if their file has to change, they'll be rebooted so the
- // connection created above will go dead, reconnect, and reauth.
- if (getGlobalAuthorizationManager()->isAuthEnabled()) {
- return authenticateInternalUser(connInfo->cc.get());
- }
-
- return true;
- }
+ bool connect();
+
};
inline ScopedConn::ScopedConn(const std::string& hostport) : _hostport(hostport) {
diff --git a/src/mongo/db/repl/health.cpp b/src/mongo/db/repl/health.cpp
index 65422709641..665a2df2d56 100644
--- a/src/mongo/db/repl/health.cpp
+++ b/src/mongo/db/repl/health.cpp
@@ -43,6 +43,7 @@
#include "mongo/util/background.h"
#include "mongo/util/concurrency/task.h"
#include "mongo/util/goodies.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/html.h"
#include "mongo/util/ramlog.h"
diff --git a/src/mongo/db/repl/heartbeat.cpp b/src/mongo/db/repl/heartbeat.cpp
index fa1b0fde090..f9ae91d7ef2 100644
--- a/src/mongo/db/repl/heartbeat.cpp
+++ b/src/mongo/db/repl/heartbeat.cpp
@@ -48,6 +48,7 @@
#include "mongo/util/concurrency/task.h"
#include "mongo/util/fail_point_service.h"
#include "mongo/util/goodies.h"
+#include "mongo/util/log.h"
#include "mongo/util/ramlog.h"
namespace mongo {
diff --git a/src/mongo/db/repl/initial_sync.cpp b/src/mongo/db/repl/initial_sync.cpp
index 19822bbc75b..63a0d0937d2 100644
--- a/src/mongo/db/repl/initial_sync.cpp
+++ b/src/mongo/db/repl/initial_sync.cpp
@@ -34,6 +34,7 @@
#include "mongo/db/repl/oplog.h"
#include "mongo/db/repl/replset_commands.h"
#include "mongo/db/repl/rs.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/repl/isself.cpp b/src/mongo/db/repl/isself.cpp
index fc7eca41f34..5d4f003f237 100644
--- a/src/mongo/db/repl/isself.cpp
+++ b/src/mongo/db/repl/isself.cpp
@@ -26,6 +26,8 @@
* it in the license file.
*/
+#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kNetworking
+
#include "mongo/platform/basic.h"
#include "mongo/db/repl/isself.h"
@@ -33,6 +35,7 @@
#include <boost/algorithm/string.hpp>
#include "mongo/base/init.h"
+#include "mongo/bson/util/builder.h"
#include "mongo/client/dbclientinterface.h"
#include "mongo/db/commands.h"
#include "mongo/db/auth/action_set.h"
@@ -131,14 +134,12 @@ namespace {
}
if (logger::globalLogDomain()->shouldLog(logger::LogSeverity::Debug(2))) {
- LogstreamBuilder builder(logger::globalLogDomain(),
- getThreadName(),
- logger::LogSeverity::Debug(2));
+ StringBuilder builder;
builder << "getAddrsForHost(\"" << iporhost << ":" << port << "\"):";
for (std::vector<std::string>::const_iterator o = out.begin(); o != out.end(); ++o) {
builder << " [ " << *o << "]";
}
- builder << std::endl;
+ LOG(2) << builder.str();
}
return out;
@@ -338,14 +339,12 @@ namespace {
#endif // defined(_WIN32)
if (logger::globalLogDomain()->shouldLog(logger::LogSeverity::Debug(2))) {
- LogstreamBuilder builder(logger::globalLogDomain(),
- getThreadName(),
- logger::LogSeverity::Debug(2));
+ StringBuilder builder;
builder << "getBoundAddrs():";
for (std::vector<std::string>::const_iterator o = out.begin(); o != out.end(); ++o) {
builder << " [ " << *o << "]";
}
- builder << std::endl;
+ LOG(2) << builder.str();
}
return out;
#else // ifdef FASTPATH
diff --git a/src/mongo/db/repl/multicmd.cpp b/src/mongo/db/repl/multicmd.cpp
new file mode 100644
index 00000000000..7889696e809
--- /dev/null
+++ b/src/mongo/db/repl/multicmd.cpp
@@ -0,0 +1,54 @@
+/**
+ * Copyright (C) 2014 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#include "mongo/platform/basic.h"
+
+#include "mongo/db/repl/multicmd.h"
+
+#include "mongo/util/log.h"
+
+namespace mongo {
+
+ MONGO_LOG_DEFAULT_COMPONENT_FILE(::mongo::logger::LogComponent::kReplication);
+
+namespace repl {
+
+ void _MultiCommandJob::run() {
+ try {
+ ScopedConn c(d.toHost);
+ LOG(1) << "multiCommand running on host " << d.toHost;
+ d.ok = c.runCommand("admin", cmd, d.result);
+ LOG(1) << "multiCommand response: " << d.result;
+ }
+ catch (const DBException& e) {
+ LOG(1) << "dev caught " << e.what() << " on multiCommand to " << d.toHost;
+ }
+ }
+
+} // namespace repl
+} // namespace mongo
diff --git a/src/mongo/db/repl/multicmd.h b/src/mongo/db/repl/multicmd.h
index 7848040836a..1705ad17580 100644
--- a/src/mongo/db/repl/multicmd.h
+++ b/src/mongo/db/repl/multicmd.h
@@ -32,7 +32,6 @@
#include "mongo/db/repl/connections.h"
#include "mongo/util/background.h"
-#include "mongo/util/log.h"
namespace mongo {
namespace repl {
@@ -61,19 +60,7 @@ namespace repl {
private:
std::string name() const { return "MultiCommandJob"; }
- void run() {
- MONGO_LOG_DEFAULT_COMPONENT_LOCAL(::mongo::logger::LogComponent::kReplication);
-
- try {
- ScopedConn c(d.toHost);
- LOG(1) << "multiCommand running on host " << d.toHost;
- d.ok = c.runCommand("admin", cmd, d.result);
- LOG(1) << "multiCommand response: " << d.result;
- }
- catch (const DBException& e) {
- LOG(1) << "dev caught " << e.what() << " on multiCommand to " << d.toHost;
- }
- }
+ void run();
};
inline void multiCommand(BSONObj cmd, std::list<Target>& L) {
diff --git a/src/mongo/db/repl/oplogreader.cpp b/src/mongo/db/repl/oplogreader.cpp
index 8cc45e43612..82e45cbb164 100644
--- a/src/mongo/db/repl/oplogreader.cpp
+++ b/src/mongo/db/repl/oplogreader.cpp
@@ -155,6 +155,13 @@ namespace repl {
return false;
}
+ void OplogReader::tailCheck() {
+ if( cursor.get() && cursor->isDead() ) {
+ log() << "repl: old cursor isDead, will initiate a new one" << std::endl;
+ resetCursor();
+ }
+ }
+
bool OplogReader::passthroughHandshake(const mongo::OID& rid, const int nextOnChainId) {
BSONObjBuilder cmd;
cmd.append("handshake", rid);
diff --git a/src/mongo/db/repl/oplogreader.h b/src/mongo/db/repl/oplogreader.h
index 22a20c097b6..0660e081806 100644
--- a/src/mongo/db/repl/oplogreader.h
+++ b/src/mongo/db/repl/oplogreader.h
@@ -80,12 +80,7 @@ namespace repl {
bool connect(const mongo::OID& rid, const int from, const std::string& to);
- void tailCheck() {
- if( cursor.get() && cursor->isDead() ) {
- log() << "repl: old cursor isDead, will initiate a new one" << std::endl;
- resetCursor();
- }
- }
+ void tailCheck();
bool haveCursor() { return cursor.get() != 0; }
diff --git a/src/mongo/db/repl/repl_coordinator_hybrid.cpp b/src/mongo/db/repl/repl_coordinator_hybrid.cpp
index fba4093cdf5..f8d508aaa68 100644
--- a/src/mongo/db/repl/repl_coordinator_hybrid.cpp
+++ b/src/mongo/db/repl/repl_coordinator_hybrid.cpp
@@ -33,6 +33,7 @@
#include "mongo/db/repl/network_interface_impl.h"
#include "mongo/db/repl/repl_coordinator_external_state_impl.h"
#include "mongo/db/repl/topology_coordinator_impl.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/repl/repl_coordinator_impl.cpp b/src/mongo/db/repl/repl_coordinator_impl.cpp
index 121b4f7889d..0137312972a 100644
--- a/src/mongo/db/repl/repl_coordinator_impl.cpp
+++ b/src/mongo/db/repl/repl_coordinator_impl.cpp
@@ -51,6 +51,7 @@
#include "mongo/stdx/functional.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/fail_point_service.h"
+#include "mongo/util/log.h"
#include "mongo/util/time_support.h"
#include "mongo/util/timer.h"
diff --git a/src/mongo/db/repl/replset_commands.cpp b/src/mongo/db/repl/replset_commands.cpp
index 8c8e815308d..30c28b9b575 100644
--- a/src/mongo/db/repl/replset_commands.cpp
+++ b/src/mongo/db/repl/replset_commands.cpp
@@ -40,6 +40,7 @@
#include "mongo/db/repl/rs_config.h"
#include "mongo/db/repl/update_position_args.h"
#include "mongo/db/repl/write_concern.h"
+#include "mongo/util/log.h"
namespace mongo {
namespace repl {
diff --git a/src/mongo/db/repl/rs.cpp b/src/mongo/db/repl/rs.cpp
index ed2f98329c7..34abf39639a 100644
--- a/src/mongo/db/repl/rs.cpp
+++ b/src/mongo/db/repl/rs.cpp
@@ -39,6 +39,7 @@
#include "mongo/db/repl/connections.h"
#include "mongo/db/repl/repl_set_impl.h"
#include "mongo/db/server_parameters.h"
+#include "mongo/util/log.h"
namespace mongo {
namespace repl {
diff --git a/src/mongo/db/repl/rs_base.h b/src/mongo/db/repl/rs_base.h
index 8896b195aea..549fb201d4a 100644
--- a/src/mongo/db/repl/rs_base.h
+++ b/src/mongo/db/repl/rs_base.h
@@ -30,7 +30,6 @@
#include "mongo/db/repl/health.h"
#include "mongo/util/concurrency/mutex.h"
-#include "mongo/util/log.h"
namespace mongo {
namespace repl {
@@ -48,11 +47,7 @@ namespace repl {
ThreadLocalValue<bool> _lockedByMe;
protected:
RSBase() : m("RSBase"), _locked(0) { }
- ~RSBase() {
- // this can happen if we throw in the constructor; otherwise never happens. thus we
- // logit as it is quite unusual.
- log() << "replSet ~RSBase called" << rsLog;
- }
+ ~RSBase() { }
public:
class lock {
diff --git a/src/mongo/db/repl/rs_initiate.cpp b/src/mongo/db/repl/rs_initiate.cpp
index 8356b51897f..ac56e20c923 100644
--- a/src/mongo/db/repl/rs_initiate.cpp
+++ b/src/mongo/db/repl/rs_initiate.cpp
@@ -49,6 +49,7 @@
#include "mongo/db/repl/replset_commands.h"
#include "mongo/db/repl/rs.h"
#include "mongo/db/repl/rs_config.h"
+#include "mongo/util/log.h"
#include "mongo/util/mmap.h"
#include "mongo/util/mongoutils/str.h"
diff --git a/src/mongo/db/repl/rs_sync.cpp b/src/mongo/db/repl/rs_sync.cpp
index a755e778d12..82ec24381a9 100644
--- a/src/mongo/db/repl/rs_sync.cpp
+++ b/src/mongo/db/repl/rs_sync.cpp
@@ -55,6 +55,7 @@
#include "mongo/db/operation_context_impl.h"
#include "mongo/db/storage_options.h"
#include "mongo/util/fail_point_service.h"
+#include "mongo/util/log.h"
namespace mongo {
namespace repl {
diff --git a/src/mongo/db/repl/state_box.cpp b/src/mongo/db/repl/state_box.cpp
new file mode 100644
index 00000000000..eb04d3e2d4e
--- /dev/null
+++ b/src/mongo/db/repl/state_box.cpp
@@ -0,0 +1,57 @@
+/**
+ * Copyright (C) 2014 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#include "mongo/platform/basic.h"
+
+#include "mongo/db/repl/state_box.h"
+
+#include "mongo/util/log.h"
+
+namespace mongo {
+
+ MONGO_LOG_DEFAULT_COMPONENT_FILE(::mongo::logger::LogComponent::kReplication);
+
+namespace repl {
+
+ void StateBox::change(MemberState s, const Member *self) {
+ rwlock lk(m, true);
+ if( sp.state != s ) {
+ log() << "replSet " << s.toString() << rsLog;
+ }
+ sp.state = s;
+ if( s.primary() ) {
+ sp.primary = self;
+ }
+ else {
+ if( self == sp.primary )
+ sp.primary = 0;
+ }
+ }
+
+} // namespace repl
+} // namespace mongo
diff --git a/src/mongo/db/repl/state_box.h b/src/mongo/db/repl/state_box.h
index 8e4a09a78d3..1a889ee3035 100644
--- a/src/mongo/db/repl/state_box.h
+++ b/src/mongo/db/repl/state_box.h
@@ -57,20 +57,7 @@ namespace repl {
rwlock lk(m, false);
return sp.primary;
}
- void change(MemberState s, const Member *self) {
- rwlock lk(m, true);
- if( sp.state != s ) {
- log() << "replSet " << s.toString() << rsLog;
- }
- sp.state = s;
- if( s.primary() ) {
- sp.primary = self;
- }
- else {
- if( self == sp.primary )
- sp.primary = 0;
- }
- }
+ void change(MemberState s, const Member *self);
void set(MemberState s, const Member *p) {
rwlock lk(m, true);
sp.state = s;
diff --git a/src/mongo/db/repl/sync_source_feedback.cpp b/src/mongo/db/repl/sync_source_feedback.cpp
index c85f7357f1b..2b47c5a3f53 100644
--- a/src/mongo/db/repl/sync_source_feedback.cpp
+++ b/src/mongo/db/repl/sync_source_feedback.cpp
@@ -58,6 +58,11 @@ namespace repl {
_shutdownSignaled(false) {}
SyncSourceFeedback::~SyncSourceFeedback() {}
+ void SyncSourceFeedback::_resetConnection() {
+ LOG(1) << "resetting connection in sync source feedback";
+ _connection.reset();
+ }
+
bool SyncSourceFeedback::replAuthenticate() {
if (!getGlobalAuthorizationManager()->isAuthEnabled())
return true;
diff --git a/src/mongo/db/repl/sync_source_feedback.h b/src/mongo/db/repl/sync_source_feedback.h
index a1a3c09c034..5becbcc84aa 100644
--- a/src/mongo/db/repl/sync_source_feedback.h
+++ b/src/mongo/db/repl/sync_source_feedback.h
@@ -35,7 +35,6 @@
#include "mongo/client/constants.h"
#include "mongo/client/dbclientcursor.h"
-#include "mongo/util/log.h"
namespace mongo {
@@ -75,12 +74,7 @@ namespace repl {
void shutdown();
private:
- void _resetConnection() {
- MONGO_LOG_DEFAULT_COMPONENT_FILE(::mongo::logger::LogComponent::kReplication);
-
- LOG(1) << "resetting connection in sync source feedback";
- _connection.reset();
- }
+ void _resetConnection();
/**
* Authenticates _connection using the server's cluster-membership credentials.
diff --git a/src/mongo/db/repl/write_concern.cpp b/src/mongo/db/repl/write_concern.cpp
index adf1dc9f35f..cce25fe36e3 100644
--- a/src/mongo/db/repl/write_concern.cpp
+++ b/src/mongo/db/repl/write_concern.cpp
@@ -38,6 +38,7 @@
#include "mongo/db/instance.h"
#include "mongo/db/repl/repl_coordinator_global.h"
#include "mongo/db/operation_context_impl.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
//#define REPLDEBUG(x) log() << "replBlock: " << x << endl;
diff --git a/src/mongo/db/restapi.cpp b/src/mongo/db/restapi.cpp
index f1399a22a65..c1d5c329773 100644
--- a/src/mongo/db/restapi.cpp
+++ b/src/mongo/db/restapi.cpp
@@ -43,6 +43,7 @@
#include "mongo/db/instance.h"
#include "mongo/db/repl/master_slave.h"
#include "mongo/db/repl/repl_coordinator_global.h"
+#include "mongo/util/log.h"
#include "mongo/util/md5.hpp"
#include "mongo/util/mongoutils/html.h"
#include "mongo/util/net/miniwebserver.h"
diff --git a/src/mongo/db/server_options_helpers.cpp b/src/mongo/db/server_options_helpers.cpp
index 94333afc673..376fe51b87a 100644
--- a/src/mongo/db/server_options_helpers.cpp
+++ b/src/mongo/db/server_options_helpers.cpp
@@ -44,6 +44,7 @@
#include "mongo/logger/log_component.h"
#include "mongo/logger/message_event_utf8_encoder.h"
#include "mongo/util/cmdline_utils/censor_cmdline.h"
+#include "mongo/util/log.h"
#include "mongo/util/map_util.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/net/listen.h" // For DEFAULT_MAX_CONN
diff --git a/src/mongo/db/sorter/sorter.cpp b/src/mongo/db/sorter/sorter.cpp
index 113813d22f3..2844cc9f4a8 100644
--- a/src/mongo/db/sorter/sorter.cpp
+++ b/src/mongo/db/sorter/sorter.cpp
@@ -57,7 +57,6 @@
#include "mongo/util/assert_util.h"
#include "mongo/util/bufreader.h"
#include "mongo/util/goodies.h"
-#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
diff --git a/src/mongo/db/stats/counters.cpp b/src/mongo/db/stats/counters.cpp
index eba6ae93b0b..a422116eafc 100644
--- a/src/mongo/db/stats/counters.cpp
+++ b/src/mongo/db/stats/counters.cpp
@@ -33,6 +33,7 @@
#include "mongo/db/stats/counters.h"
#include "mongo/db/jsobj.h"
+#include "mongo/util/log.h"
namespace mongo {
OpCounters::OpCounters() {}
diff --git a/src/mongo/db/stats/snapshots.cpp b/src/mongo/db/stats/snapshots.cpp
index ecd392decea..d540bc558bb 100644
--- a/src/mongo/db/stats/snapshots.cpp
+++ b/src/mongo/db/stats/snapshots.cpp
@@ -34,6 +34,7 @@
#include "mongo/db/client.h"
#include "mongo/db/clientcursor.h"
+#include "mongo/util/log.h"
/**
handles snapshotting performance metrics and other such things
diff --git a/src/mongo/db/stats/top.cpp b/src/mongo/db/stats/top.cpp
index 2ec710ae57d..00d057a2973 100644
--- a/src/mongo/db/stats/top.cpp
+++ b/src/mongo/db/stats/top.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/auth/action_type.h"
#include "mongo/db/auth/authorization_manager.h"
#include "mongo/db/auth/privilege.h"
+#include "mongo/util/log.h"
#include "mongo/util/net/message.h"
#include "mongo/db/commands.h"
diff --git a/src/mongo/db/storage/heap1/SConscript b/src/mongo/db/storage/heap1/SConscript
index 948a430820a..ecc27938906 100644
--- a/src/mongo/db/storage/heap1/SConscript
+++ b/src/mongo/db/storage/heap1/SConscript
@@ -23,6 +23,7 @@ env.Library(
'$BUILD_DIR/mongo/bson',
'$BUILD_DIR/mongo/db/catalog/collection_options',
'$BUILD_DIR/mongo/db/storage/index_entry_comparison',
+ '$BUILD_DIR/mongo/db/index/index_descriptor',
'$BUILD_DIR/mongo/foundation',
]
)
diff --git a/src/mongo/db/storage/heap1/heap1_database_catalog_entry_index_real.cpp b/src/mongo/db/storage/heap1/heap1_database_catalog_entry_index_real.cpp
index 69a665f6029..0ebaf3bd52f 100644
--- a/src/mongo/db/storage/heap1/heap1_database_catalog_entry_index_real.cpp
+++ b/src/mongo/db/storage/heap1/heap1_database_catalog_entry_index_real.cpp
@@ -37,6 +37,7 @@
#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/index/s2_access_method.h"
#include "mongo/db/storage/heap1/heap1_btree_impl.h"
+#include "mongo/util/log.h"
namespace mongo {
IndexAccessMethod* Heap1DatabaseCatalogEntry::getIndex( OperationContext* txn,
diff --git a/src/mongo/db/storage/heap1/record_store_heap.cpp b/src/mongo/db/storage/heap1/record_store_heap.cpp
index a1157df4a90..3145e6f1c75 100644
--- a/src/mongo/db/storage/heap1/record_store_heap.cpp
+++ b/src/mongo/db/storage/heap1/record_store_heap.cpp
@@ -29,6 +29,7 @@
#include "mongo/db/storage/heap1/record_store_heap.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
diff --git a/src/mongo/db/storage/mmap_v1/SConscript b/src/mongo/db/storage/mmap_v1/SConscript
index ad6ab270785..20edaaa5934 100644
--- a/src/mongo/db/storage/mmap_v1/SConscript
+++ b/src/mongo/db/storage/mmap_v1/SConscript
@@ -2,7 +2,8 @@ Import("env")
env.Library(
target = 'storage_mmapv1',
- source = [ "catalog/index_details.cpp",
+ source = [ "catalog/hashtab.cpp",
+ "catalog/index_details.cpp",
"catalog/namespace.cpp",
"catalog/namespace_details.cpp",
"catalog/namespace_details_collection_entry.cpp",
@@ -93,6 +94,7 @@ env.Library(
source= [
'btree/btree_logic.cpp',
'btree/btree_interface.cpp',
+ 'btree/btree_ondisk.cpp',
'btree/key.cpp'
],
LIBDEPS= [
diff --git a/src/mongo/db/storage/mmap_v1/btree/btree_logic_test.cpp b/src/mongo/db/storage/mmap_v1/btree/btree_logic_test.cpp
index ee52e8796aa..88fb0653c42 100644
--- a/src/mongo/db/storage/mmap_v1/btree/btree_logic_test.cpp
+++ b/src/mongo/db/storage/mmap_v1/btree/btree_logic_test.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/operation_context_noop.h"
#include "mongo/db/storage/mmap_v1/btree/btree_test_help.h"
#include "mongo/unittest/unittest.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/storage/mmap_v1/btree/btree_ondisk.cpp b/src/mongo/db/storage/mmap_v1/btree/btree_ondisk.cpp
new file mode 100644
index 00000000000..cdf89eff1c3
--- /dev/null
+++ b/src/mongo/db/storage/mmap_v1/btree/btree_ondisk.cpp
@@ -0,0 +1,53 @@
+/**
+ * Copyright (C) 2014 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#include "mongo/platform/basic.h"
+
+#include "mongo/db/storage/mmap_v1/btree/btree_ondisk.h"
+
+#include "mongo/util/assert_util.h"
+#include "mongo/util/log.h"
+
+namespace mongo {
+
+ void DiskLoc56Bit::operator=(const DiskLoc& loc) {
+ ofs = loc.getOfs();
+ int la = loc.a();
+ invariant( la <= 0xffffff ); // must fit in 3 bytes
+ if( la < 0 ) {
+ if ( la != -1 ) {
+ log() << "btree diskloc isn't negative 1: " << la << std::endl;
+ invariant ( la == -1 );
+ }
+ la = 0;
+ ofs = OurNullOfs;
+ }
+ memcpy(_a, &la, 3); // endian
+ }
+
+} // namespace mongo
diff --git a/src/mongo/db/storage/mmap_v1/btree/btree_ondisk.h b/src/mongo/db/storage/mmap_v1/btree/btree_ondisk.h
index 7f91cd2fb27..dcb0697a2b0 100644
--- a/src/mongo/db/storage/mmap_v1/btree/btree_ondisk.h
+++ b/src/mongo/db/storage/mmap_v1/btree/btree_ondisk.h
@@ -267,20 +267,7 @@ namespace mongo {
_a[0] = _a[1] = _a[2] = 0;
}
- void operator=(const DiskLoc& loc) {
- ofs = loc.getOfs();
- int la = loc.a();
- invariant( la <= 0xffffff ); // must fit in 3 bytes
- if( la < 0 ) {
- if ( la != -1 ) {
- log() << "btree diskloc isn't negative 1: " << la << std::endl;
- invariant ( la == -1 );
- }
- la = 0;
- ofs = OurNullOfs;
- }
- memcpy(_a, &la, 3); // endian
- }
+ void operator=(const DiskLoc& loc);
//
// Type Conversion
diff --git a/src/mongo/db/storage/mmap_v1/btree/key.cpp b/src/mongo/db/storage/mmap_v1/btree/key.cpp
index a6ccd61d2cf..22218911618 100644
--- a/src/mongo/db/storage/mmap_v1/btree/key.cpp
+++ b/src/mongo/db/storage/mmap_v1/btree/key.cpp
@@ -30,6 +30,7 @@
#include "mongo/bson/util/builder.h"
#include "mongo/platform/float_utils.h"
+#include "mongo/util/log.h"
#include "mongo/util/startup_test.h"
diff --git a/src/mongo/db/storage/mmap_v1/catalog/hashtab.cpp b/src/mongo/db/storage/mmap_v1/catalog/hashtab.cpp
new file mode 100644
index 00000000000..0f5691ce783
--- /dev/null
+++ b/src/mongo/db/storage/mmap_v1/catalog/hashtab.cpp
@@ -0,0 +1,95 @@
+// hashtab.cpp
+
+/**
+* Copyright (C) 2014 MongoDB Inc.
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License, version 3,
+* as published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* As a special exception, the copyright holders give permission to link the
+* code of portions of this program with the OpenSSL library under certain
+* conditions as described in each individual source file and distribute
+* linked combinations including the program with the OpenSSL library. You
+* must comply with the GNU Affero General Public License in all respects for
+* all of the code used other than as permitted herein. If you modify file(s)
+* with this exception, you may extend this exception to your version of the
+* file(s), but you are not obligated to do so. If you do not wish to do so,
+* delete this exception statement from your version. If you delete this
+* exception statement from all source files in the program, then also delete
+* it in the license file.
+*/
+
+#include "mongo/platform/basic.h"
+
+#include "mongo/db/storage/mmap_v1/catalog/hashtab.h"
+
+#include "mongo/util/log.h"
+
+namespace mongo {
+
+ MONGO_LOG_DEFAULT_COMPONENT_FILE(::mongo::logger::LogComponent::kIndexing);
+
+ int NamespaceHashTable::_find(const Key& k, bool& found) {
+ found = false;
+ int h = k.hash();
+ int i = h % n;
+ int start = i;
+ int chain = 0;
+ int firstNonUsed = -1;
+ while ( 1 ) {
+ if ( !nodes(i).inUse() ) {
+ if ( firstNonUsed < 0 )
+ firstNonUsed = i;
+ }
+
+ if ( nodes(i).hash == h && nodes(i).k == k ) {
+ if ( chain >= 200 )
+ log() << "warning: hashtable " << name << " long chain " << std::endl;
+ found = true;
+ return i;
+ }
+ chain++;
+ i = (i+1) % n;
+ if ( i == start ) {
+ // shouldn't get here / defensive for infinite loops
+ log() << "error: hashtable " << name << " is full n:" << n << std::endl;
+ return -1;
+ }
+ if( chain >= maxChain ) {
+ if ( firstNonUsed >= 0 )
+ return firstNonUsed;
+ log() << "error: hashtable " << name << " max chain reached:" << maxChain << std::endl;
+ return -1;
+ }
+ }
+ }
+
+ /* buf must be all zeroes on initialization. */
+ NamespaceHashTable::NamespaceHashTable(void* buf, int buflen, const char *_name)
+ : name(_name) {
+ int m = sizeof(Node);
+ // log() << "hashtab init, buflen:" << buflen << " m:" << m << std::endl;
+ n = buflen / m;
+ if ( (n & 1) == 0 )
+ n--;
+ maxChain = (int) (n * 0.05);
+ _buf = buf;
+ //nodes = (Node *) buf;
+
+ if ( sizeof(Node) != 628 ) {
+ log() << "HashTable() " << _name << " sizeof(node):" << sizeof(Node) << " n:" << n
+ << " sizeof(Key): " << sizeof(Key) << " sizeof(Type):" << sizeof(Type) << std::endl;
+ verify( sizeof(Node) == 628 );
+ }
+
+ }
+} // namespace mongo
diff --git a/src/mongo/db/storage/mmap_v1/catalog/hashtab.h b/src/mongo/db/storage/mmap_v1/catalog/hashtab.h
index 07916dc873d..125387feac9 100644
--- a/src/mongo/db/storage/mmap_v1/catalog/hashtab.h
+++ b/src/mongo/db/storage/mmap_v1/catalog/hashtab.h
@@ -34,8 +34,10 @@
#pragma once
-#include "mongo/pch.h"
#include <map>
+
+#include "mongo/db/storage/mmap_v1/catalog/namespace.h"
+#include "mongo/db/storage/mmap_v1/catalog/namespace_details.h"
#include "mongo/db/storage/mmap_v1/dur.h"
#include "mongo/db/operation_context.h"
#include "mongo/stdx/functional.h"
@@ -47,11 +49,14 @@ namespace mongo {
/* you should define:
int Key::hash() return > 0 always.
+ Used in NamespaceIndex only.
*/
- template <class Key,class Type>
- class HashTable : boost::noncopyable {
+ class NamespaceHashTable : boost::noncopyable {
public:
+ typedef Namespace Key;
+ typedef NamespaceDetails Type;
+
const char *name;
struct Node {
int hash;
@@ -73,59 +78,11 @@ namespace mongo {
return nodes[i];
}
- int _find(const Key& k, bool& found) {
- found = false;
- int h = k.hash();
- int i = h % n;
- int start = i;
- int chain = 0;
- int firstNonUsed = -1;
- while ( 1 ) {
- if ( !nodes(i).inUse() ) {
- if ( firstNonUsed < 0 )
- firstNonUsed = i;
- }
-
- if ( nodes(i).hash == h && nodes(i).k == k ) {
- if ( chain >= 200 )
- log() << "warning: hashtable " << name << " long chain " << std::endl;
- found = true;
- return i;
- }
- chain++;
- i = (i+1) % n;
- if ( i == start ) {
- // shouldn't get here / defensive for infinite loops
- log() << "error: hashtable " << name << " is full n:" << n << std::endl;
- return -1;
- }
- if( chain >= maxChain ) {
- if ( firstNonUsed >= 0 )
- return firstNonUsed;
- log() << "error: hashtable " << name << " max chain reached:" << maxChain << std::endl;
- return -1;
- }
- }
- }
+ int _find(const Key& k, bool& found);
public:
/* buf must be all zeroes on initialization. */
- HashTable(void* buf, int buflen, const char *_name) : name(_name) {
- int m = sizeof(Node);
- // log() << "hashtab init, buflen:" << buflen << " m:" << m << std::endl;
- n = buflen / m;
- if ( (n & 1) == 0 )
- n--;
- maxChain = (int) (n * 0.05);
- _buf = buf;
- //nodes = (Node *) buf;
-
- if ( sizeof(Node) != 628 ) {
- log() << "HashTable() " << _name << " sizeof(node):" << sizeof(Node) << " n:" << n << " sizeof(Key): " << sizeof(Key) << " sizeof(Type):" << sizeof(Type) << std::endl;
- verify( sizeof(Node) == 628 );
- }
-
- }
+ NamespaceHashTable(void* buf, int buflen, const char *_name);
Type* get(const Key& k) {
bool found;
diff --git a/src/mongo/db/storage/mmap_v1/catalog/namespace-inl.h b/src/mongo/db/storage/mmap_v1/catalog/namespace-inl.h
index 5cd45963f1f..02b8b5167b6 100644
--- a/src/mongo/db/storage/mmap_v1/catalog/namespace-inl.h
+++ b/src/mongo/db/storage/mmap_v1/catalog/namespace-inl.h
@@ -30,6 +30,10 @@
#pragma once
+#include <boost/filesystem/path.hpp>
+
+#include "mongo/util/assert_util.h"
+
namespace mongo {
inline Namespace& Namespace::operator=(const StringData& ns) {
diff --git a/src/mongo/db/storage/mmap_v1/catalog/namespace_details.cpp b/src/mongo/db/storage/mmap_v1/catalog/namespace_details.cpp
index 2fe3d226e5d..c84bb6a3cdf 100644
--- a/src/mongo/db/storage/mmap_v1/catalog/namespace_details.cpp
+++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_details.cpp
@@ -44,6 +44,7 @@
#include "mongo/db/ops/delete.h"
#include "mongo/db/ops/update.h"
#include "mongo/db/storage/mmap_v1/catalog/hashtab.h"
+#include "mongo/db/storage/mmap_v1/catalog/namespace_index.h"
#include "mongo/db/operation_context.h"
#include "mongo/scripting/engine.h"
#include "mongo/util/startup_test.h"
diff --git a/src/mongo/db/storage/mmap_v1/catalog/namespace_details.h b/src/mongo/db/storage/mmap_v1/catalog/namespace_details.h
index 0a6734e7d9d..cdda3b89d11 100644
--- a/src/mongo/db/storage/mmap_v1/catalog/namespace_details.h
+++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_details.h
@@ -32,11 +32,11 @@
#include "mongo/db/namespace_string.h"
#include "mongo/db/storage/mmap_v1/catalog/index_details.h"
#include "mongo/db/storage/mmap_v1/catalog/namespace.h"
-#include "mongo/db/storage/mmap_v1/catalog/namespace_index.h"
namespace mongo {
class Collection;
+ class NamespaceIndex;
class OperationContext;
/* deleted lists -- linked lists of deleted records -- are placed in 'buckets' of various sizes
diff --git a/src/mongo/db/storage/mmap_v1/catalog/namespace_index.cpp b/src/mongo/db/storage/mmap_v1/catalog/namespace_index.cpp
index 9bbf8ef6303..1324b2c7b36 100644
--- a/src/mongo/db/storage/mmap_v1/catalog/namespace_index.cpp
+++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_index.cpp
@@ -197,7 +197,7 @@ namespace mongo {
verify( len <= 0x7fffffff );
- _ht.reset(new HashTable<Namespace,NamespaceDetails>(p, (int) len, "namespace index"));
+ _ht.reset(new NamespaceHashTable(p, (int) len, "namespace index"));
}
diff --git a/src/mongo/db/storage/mmap_v1/catalog/namespace_index.h b/src/mongo/db/storage/mmap_v1/catalog/namespace_index.h
index 3ce2c2e0194..59c0a98a9ad 100644
--- a/src/mongo/db/storage/mmap_v1/catalog/namespace_index.h
+++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_index.h
@@ -37,6 +37,7 @@
#include "mongo/db/diskloc.h"
#include "mongo/db/storage/mmap_v1/catalog/hashtab.h"
#include "mongo/db/storage/mmap_v1/catalog/namespace.h"
+#include "mongo/db/storage/mmap_v1/durable_mapped_file.h"
namespace mongo {
@@ -86,7 +87,7 @@ namespace mongo {
void maybeMkdir() const;
DurableMappedFile _f;
- scoped_ptr<HashTable<Namespace,NamespaceDetails> > _ht;
+ scoped_ptr<NamespaceHashTable> _ht;
std::string _dir;
std::string _database;
};
diff --git a/src/mongo/db/storage/mmap_v1/data_file.cpp b/src/mongo/db/storage/mmap_v1/data_file.cpp
index 044f2ef3656..422ca1c6ce0 100644
--- a/src/mongo/db/storage/mmap_v1/data_file.cpp
+++ b/src/mongo/db/storage/mmap_v1/data_file.cpp
@@ -39,6 +39,7 @@
#include "mongo/db/lockstate.h"
#include "mongo/db/operation_context.h"
#include "mongo/util/file_allocator.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/storage/mmap_v1/dur.cpp b/src/mongo/db/storage/mmap_v1/dur.cpp
index b8258571670..c903b2e8bb3 100644
--- a/src/mongo/db/storage/mmap_v1/dur.cpp
+++ b/src/mongo/db/storage/mmap_v1/dur.cpp
@@ -94,7 +94,7 @@ using namespace mongoutils;
namespace mongo {
- MONGO_LOG_DEFAULT_COMPONENT_FILE(::mongo::logger::LogComponent::kStorage);
+ MONGO_LOG_DEFAULT_COMPONENT_FILE(::mongo::logger::LogComponent::kJournaling);
namespace dur {
@@ -889,6 +889,10 @@ namespace mongo {
boost::thread t(durThread);
}
+ DurableInterface::~DurableInterface() {
+ log() << "ERROR warning ~DurableInterface not intended to be called" << std::endl;
+ }
+
void DurableImpl::syncDataAndTruncateJournal(OperationContext* txn) {
invariant(txn->lockState()->isW());
diff --git a/src/mongo/db/storage/mmap_v1/dur.h b/src/mongo/db/storage/mmap_v1/dur.h
index 065d39ecd2d..730f631ced5 100644
--- a/src/mongo/db/storage/mmap_v1/dur.h
+++ b/src/mongo/db/storage/mmap_v1/dur.h
@@ -57,7 +57,7 @@ namespace mongo {
class DurableInterface : boost::noncopyable {
public:
- virtual ~DurableInterface() { log() << "ERROR warning ~DurableInterface not intended to be called" << std::endl; }
+ virtual ~DurableInterface();
/** Declare that a file has been created
Normally writes are applied only after journaling, for safety. But here the file
diff --git a/src/mongo/db/storage/mmap_v1/dur_commitjob.cpp b/src/mongo/db/storage/mmap_v1/dur_commitjob.cpp
index 60a5c932a8c..6a071648212 100644
--- a/src/mongo/db/storage/mmap_v1/dur_commitjob.cpp
+++ b/src/mongo/db/storage/mmap_v1/dur_commitjob.cpp
@@ -35,6 +35,7 @@
#include "mongo/db/client.h"
#include "mongo/db/storage/mmap_v1/dur_stats.h"
#include "mongo/util/concurrency/threadlocal.h"
+#include "mongo/util/log.h"
#include "mongo/util/stacktrace.h"
namespace mongo {
diff --git a/src/mongo/db/storage/mmap_v1/dur_journal.cpp b/src/mongo/db/storage/mmap_v1/dur_journal.cpp
index 0933c762ed6..c48afef8660 100644
--- a/src/mongo/db/storage/mmap_v1/dur_journal.cpp
+++ b/src/mongo/db/storage/mmap_v1/dur_journal.cpp
@@ -60,7 +60,7 @@ using namespace mongoutils;
namespace mongo {
- MONGO_LOG_DEFAULT_COMPONENT_FILE(::mongo::logger::LogComponent::kStorage);
+ MONGO_LOG_DEFAULT_COMPONENT_FILE(::mongo::logger::LogComponent::kJournaling);
class AlignedBuilder;
diff --git a/src/mongo/db/storage/mmap_v1/dur_preplogbuffer.cpp b/src/mongo/db/storage/mmap_v1/dur_preplogbuffer.cpp
index 4e1bc7a7b4e..994b28b91c2 100644
--- a/src/mongo/db/storage/mmap_v1/dur_preplogbuffer.cpp
+++ b/src/mongo/db/storage/mmap_v1/dur_preplogbuffer.cpp
@@ -45,6 +45,7 @@
#include "mongo/db/storage/mmap_v1/dur_stats.h"
#include "mongo/server.h"
#include "mongo/util/alignedbuilder.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/stacktrace.h"
#include "mongo/util/timer.h"
diff --git a/src/mongo/db/storage/mmap_v1/dur_recover.cpp b/src/mongo/db/storage/mmap_v1/dur_recover.cpp
index 18b2baa67ce..e552a32c868 100644
--- a/src/mongo/db/storage/mmap_v1/dur_recover.cpp
+++ b/src/mongo/db/storage/mmap_v1/dur_recover.cpp
@@ -52,6 +52,7 @@
#include "mongo/util/bufreader.h"
#include "mongo/util/checksum.h"
#include "mongo/util/compress.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/startup_test.h"
diff --git a/src/mongo/db/storage/mmap_v1/durable_mapped_file.cpp b/src/mongo/db/storage/mmap_v1/durable_mapped_file.cpp
index 0a4c6e8a7e9..e717ce47638 100644
--- a/src/mongo/db/storage/mmap_v1/durable_mapped_file.cpp
+++ b/src/mongo/db/storage/mmap_v1/durable_mapped_file.cpp
@@ -38,6 +38,7 @@
#include "mongo/db/d_concurrency.h"
+#include "mongo/db/storage_options.h"
#include "mongo/db/storage/mmap_v1/dur.h"
#include "mongo/db/storage/mmap_v1/dur_journalformat.h"
#include "mongo/util/mongoutils/str.h"
@@ -139,7 +140,7 @@ namespace mongo {
else
_fileSuffixNo = (int) str::toUnsigned(suffix);
- _p = RelativePath::fromFullPath(prefix);
+ _p = RelativePath::fromFullPath(storageGlobalParams.dbpath, prefix);
}
bool DurableMappedFile::open(const std::string& fname, bool sequentialHint) {
diff --git a/src/mongo/db/storage/mmap_v1/durop.cpp b/src/mongo/db/storage/mmap_v1/durop.cpp
index c3dc60c875b..b1c778fa459 100644
--- a/src/mongo/db/storage/mmap_v1/durop.cpp
+++ b/src/mongo/db/storage/mmap_v1/durop.cpp
@@ -98,7 +98,7 @@ namespace mongo {
FileCreatedOp::FileCreatedOp(const std::string& f, unsigned long long l) :
DurOp(JEntry::OpCode_FileCreated) {
- _p = RelativePath::fromFullPath(f);
+ _p = RelativePath::fromFullPath(storageGlobalParams.dbpath, f);
_len = l;
}
diff --git a/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp b/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp
index 9a77b192c7e..96768ef5983 100644
--- a/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp
+++ b/src/mongo/db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp
@@ -50,6 +50,7 @@
#include "mongo/db/storage/mmap_v1/dur_recovery_unit.h"
#include "mongo/db/storage/mmap_v1/record_store_v1_capped.h"
#include "mongo/db/storage/mmap_v1/record_store_v1_simple.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/storage/mmap_v1/mmap_v1_engine.cpp b/src/mongo/db/storage/mmap_v1/mmap_v1_engine.cpp
index 66436256c09..14217369464 100644
--- a/src/mongo/db/storage/mmap_v1/mmap_v1_engine.cpp
+++ b/src/mongo/db/storage/mmap_v1/mmap_v1_engine.cpp
@@ -50,6 +50,7 @@
#include "mongo/db/storage_options.h"
#include "mongo/platform/process_id.h"
#include "mongo/util/file_allocator.h"
+#include "mongo/util/log.h"
#include "mongo/util/mmap.h"
namespace mongo {
diff --git a/src/mongo/db/storage/mmap_v1/record_store_v1_base.cpp b/src/mongo/db/storage/mmap_v1/record_store_v1_base.cpp
index 3a1bed72dd9..47ca3498893 100644
--- a/src/mongo/db/storage/mmap_v1/record_store_v1_base.cpp
+++ b/src/mongo/db/storage/mmap_v1/record_store_v1_base.cpp
@@ -37,6 +37,7 @@
#include "mongo/db/storage/mmap_v1/extent_manager.h"
#include "mongo/db/storage/mmap_v1/record.h"
#include "mongo/db/storage/mmap_v1/record_store_v1_repair_iterator.h"
+#include "mongo/util/log.h"
#include "mongo/util/progress_meter.h"
#include "mongo/util/timer.h"
#include "mongo/util/touch_pages.h"
diff --git a/src/mongo/db/storage/mmap_v1/record_store_v1_capped.cpp b/src/mongo/db/storage/mmap_v1/record_store_v1_capped.cpp
index c8524c76e22..ab704ef4505 100644
--- a/src/mongo/db/storage/mmap_v1/record_store_v1_capped.cpp
+++ b/src/mongo/db/storage/mmap_v1/record_store_v1_capped.cpp
@@ -35,6 +35,7 @@
#include "mongo/db/storage/mmap_v1/extent_manager.h"
#include "mongo/db/storage/mmap_v1/record.h"
#include "mongo/db/storage/mmap_v1/record_store_v1_capped_iterator.h"
+#include "mongo/util/log.h"
#include "mongo/util/mmap.h"
#include "mongo/util/mongoutils/str.h"
diff --git a/src/mongo/db/storage/mmap_v1/record_store_v1_repair_iterator.cpp b/src/mongo/db/storage/mmap_v1/record_store_v1_repair_iterator.cpp
index a210c0dc0f3..be42a991929 100644
--- a/src/mongo/db/storage/mmap_v1/record_store_v1_repair_iterator.cpp
+++ b/src/mongo/db/storage/mmap_v1/record_store_v1_repair_iterator.cpp
@@ -32,6 +32,7 @@
#include "mongo/db/storage/mmap_v1/extent.h"
#include "mongo/db/storage/mmap_v1/extent_manager.h"
#include "mongo/db/storage/mmap_v1/record_store_v1_simple.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/storage/mmap_v1/record_store_v1_test_help.cpp b/src/mongo/db/storage/mmap_v1/record_store_v1_test_help.cpp
index 3ea4298332f..be5364ada69 100644
--- a/src/mongo/db/storage/mmap_v1/record_store_v1_test_help.cpp
+++ b/src/mongo/db/storage/mmap_v1/record_store_v1_test_help.cpp
@@ -38,6 +38,7 @@
#include "mongo/db/storage/mmap_v1/extent.h"
#include "mongo/db/storage/mmap_v1/record.h"
#include "mongo/unittest/unittest.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/storage/rocks/rocks_database_catalog_entry.cpp b/src/mongo/db/storage/rocks/rocks_database_catalog_entry.cpp
index dcf49210bf3..7c074a1529f 100644
--- a/src/mongo/db/storage/rocks/rocks_database_catalog_entry.cpp
+++ b/src/mongo/db/storage/rocks/rocks_database_catalog_entry.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/storage/rocks/rocks_collection_catalog_entry.h"
#include "mongo/db/storage/rocks/rocks_engine.h"
#include "mongo/db/storage/rocks/rocks_record_store.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/db/storage/rocks/rocks_record_store.cpp b/src/mongo/db/storage/rocks/rocks_record_store.cpp
index 3dbde39c5ee..268ec0af86d 100644
--- a/src/mongo/db/storage/rocks/rocks_record_store.cpp
+++ b/src/mongo/db/storage/rocks/rocks_record_store.cpp
@@ -38,6 +38,8 @@
#include <rocksdb/options.h>
#include <rocksdb/slice.h>
+#include "mongo/util/log.h"
+
namespace mongo {
RocksRecordStore::RocksRecordStore( const StringData& ns,
diff --git a/src/mongo/dbtests/config_server_fixture.cpp b/src/mongo/dbtests/config_server_fixture.cpp
index d7109cfe577..5b1a25636c0 100644
--- a/src/mongo/dbtests/config_server_fixture.cpp
+++ b/src/mongo/dbtests/config_server_fixture.cpp
@@ -39,6 +39,7 @@
#include "mongo/s/type_database.h"
#include "mongo/s/type_mongos.h"
#include "mongo/s/type_shard.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/dbtests/framework.cpp b/src/mongo/dbtests/framework.cpp
index 062b6a7edca..c0704f60e2d 100644
--- a/src/mongo/dbtests/framework.cpp
+++ b/src/mongo/dbtests/framework.cpp
@@ -47,6 +47,7 @@
#include "mongo/util/background.h"
#include "mongo/util/concurrency/mutex.h"
#include "mongo/util/exit.h"
+#include "mongo/util/log.h"
#include "mongo/util/version_reporting.h"
namespace moe = mongo::optionenvironment;
diff --git a/src/mongo/dbtests/framework_options.cpp b/src/mongo/dbtests/framework_options.cpp
index 4e482589331..ef3300c8aa2 100644
--- a/src/mongo/dbtests/framework_options.cpp
+++ b/src/mongo/dbtests/framework_options.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/storage_options.h"
#include "mongo/dbtests/dbtests.h"
#include "mongo/unittest/unittest.h"
+#include "mongo/util/log.h"
#include "mongo/util/options_parser/startup_options.h"
#include "mongo/util/password.h"
diff --git a/src/mongo/dbtests/jsobjtests.cpp b/src/mongo/dbtests/jsobjtests.cpp
index 43aa6587531..63bb0f18363 100644
--- a/src/mongo/dbtests/jsobjtests.cpp
+++ b/src/mongo/dbtests/jsobjtests.cpp
@@ -38,6 +38,7 @@
#include "mongo/dbtests/dbtests.h"
#include "mongo/platform/float_utils.h"
#include "mongo/util/embedded_builder.h"
+#include "mongo/util/log.h"
#include "mongo/util/stringutils.h"
namespace mongo {
diff --git a/src/mongo/dbtests/jsontests.cpp b/src/mongo/dbtests/jsontests.cpp
index a561fca0fe5..97477327984 100644
--- a/src/mongo/dbtests/jsontests.cpp
+++ b/src/mongo/dbtests/jsontests.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/json.h"
#include "mongo/dbtests/dbtests.h"
+#include "mongo/util/log.h"
namespace JsonTests {
diff --git a/src/mongo/dbtests/jstests.cpp b/src/mongo/dbtests/jstests.cpp
index 09b93f01919..08bd04bce4f 100644
--- a/src/mongo/dbtests/jstests.cpp
+++ b/src/mongo/dbtests/jstests.cpp
@@ -40,6 +40,7 @@
#include "mongo/dbtests/dbtests.h"
#include "mongo/scripting/engine.h"
#include "mongo/util/concurrency/thread_name.h"
+#include "mongo/util/log.h"
#include "mongo/util/timer.h"
using std::string;
diff --git a/src/mongo/dbtests/namespacetests.cpp b/src/mongo/dbtests/namespacetests.cpp
index 68509e068d6..6c5b444e68b 100644
--- a/src/mongo/dbtests/namespacetests.cpp
+++ b/src/mongo/dbtests/namespacetests.cpp
@@ -51,6 +51,7 @@
#include "mongo/db/storage/mmap_v1/catalog/namespace_details_rsv1_metadata.h"
#include "mongo/db/storage/storage_engine.h"
#include "mongo/dbtests/dbtests.h"
+#include "mongo/util/log.h"
namespace NamespaceTests {
diff --git a/src/mongo/dbtests/perftests.cpp b/src/mongo/dbtests/perftests.cpp
index 6125b91eeb5..1acc5a4d805 100644
--- a/src/mongo/dbtests/perftests.cpp
+++ b/src/mongo/dbtests/perftests.cpp
@@ -54,6 +54,7 @@
#include "mongo/util/compress.h"
#include "mongo/util/concurrency/qlock.h"
#include "mongo/util/fail_point.h"
+#include "mongo/util/log.h"
#include "mongo/util/mmap.h"
#include "mongo/util/timer.h"
#include "mongo/util/version.h"
diff --git a/src/mongo/dbtests/repltests.cpp b/src/mongo/dbtests/repltests.cpp
index 6c5fbf2a56d..dc00e4f6e7e 100644
--- a/src/mongo/dbtests/repltests.cpp
+++ b/src/mongo/dbtests/repltests.cpp
@@ -44,6 +44,7 @@
#include "mongo/db/ops/update.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/db/operation_context_impl.h"
+#include "mongo/util/log.h"
#include "mongo/dbtests/dbtests.h"
diff --git a/src/mongo/dbtests/sharding.cpp b/src/mongo/dbtests/sharding.cpp
index c0ade14cf91..73501e551ea 100644
--- a/src/mongo/dbtests/sharding.cpp
+++ b/src/mongo/dbtests/sharding.cpp
@@ -40,6 +40,7 @@
#include "mongo/s/config.h"
#include "mongo/s/type_chunk.h"
#include "mongo/s/type_collection.h"
+#include "mongo/util/log.h"
namespace ShardingTests {
diff --git a/src/mongo/pch.h b/src/mongo/pch.h
index 617eeeb95ca..96cc3e0c0d1 100644
--- a/src/mongo/pch.h
+++ b/src/mongo/pch.h
@@ -77,6 +77,5 @@ namespace mongo {
#include "mongo/util/debug_util.h"
#include "mongo/util/goodies.h"
#include "mongo/util/allocator.h"
-#include "mongo/util/log.h"
#endif // MONGO_PCH_H
diff --git a/src/mongo/s/balancer_policy_tests.cpp b/src/mongo/s/balancer_policy_tests.cpp
index cde493c5876..57d7ef0165f 100644
--- a/src/mongo/s/balancer_policy_tests.cpp
+++ b/src/mongo/s/balancer_policy_tests.cpp
@@ -31,6 +31,7 @@
#include "mongo/s/config.h"
#include "mongo/s/type_chunk.h"
#include "mongo/unittest/unittest.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/s/chunk_diff-inl.cpp b/src/mongo/s/chunk_diff-inl.cpp
index d4818dbd107..efb09ad3bdc 100644
--- a/src/mongo/s/chunk_diff-inl.cpp
+++ b/src/mongo/s/chunk_diff-inl.cpp
@@ -31,9 +31,13 @@
#pragma once
#include "mongo/s/chunk_diff.h"
+
+#include "mongo/logger/log_severity.h"
+#include "mongo/logger/logger.h"
+#include "mongo/logger/logstream_builder.h"
#include "mongo/s/chunk_version.h"
#include "mongo/s/type_chunk.h"
-#include "mongo/util/log.h"
+#include "mongo/util/concurrency/thread_name.h"
namespace mongo {
@@ -122,8 +126,6 @@ namespace mongo {
int ConfigDiffTracker<ValType,ShardType>::
calculateConfigDiff( DBClientCursorInterface& diffCursor )
{
- MONGO_LOG_DEFAULT_COMPONENT_LOCAL(::mongo::logger::LogComponent::kSharding);
-
verifyAttached();
// Apply the chunk changes to the ranges and versions
@@ -151,14 +153,20 @@ namespace mongo {
diffChunkDoc[ChunkType::max()].type() != Object ||
diffChunkDoc[ChunkType::shard()].type() != String )
{
- warning() << "got invalid chunk document " << diffChunkDoc
+ using namespace logger;
+ LogstreamBuilder(globalLogDomain(), getThreadName(), LogSeverity::Warning(),
+ LogComponent::kSharding)
+ << "got invalid chunk document " << diffChunkDoc
<< " when trying to load differing chunks" << endl;
continue;
}
if( ! chunkVersion.isSet() || ! chunkVersion.hasEqualEpoch( currEpoch ) ){
- warning() << "got invalid chunk version " << chunkVersion << " in document " << diffChunkDoc
+ using namespace logger;
+ LogstreamBuilder(globalLogDomain(), getThreadName(), LogSeverity::Warning(),
+ LogComponent::kSharding)
+ << "got invalid chunk version " << chunkVersion << " in document " << diffChunkDoc
<< " when trying to load differing chunks at version "
<< ChunkVersion( _maxVersion->majorVersion(),
_maxVersion->minorVersion(),
@@ -189,11 +197,16 @@ namespace mongo {
if( isTracked( diffChunkDoc ) ) newTracked.push_back( diffChunkDoc.getOwned() );
}
- LOG(3) << "found " << _validDiffs
- << " new chunks for collection " << _ns
- << " (tracking " << newTracked.size()
- << "), new version is " << *_maxVersion
- << endl;
+ using namespace logger;
+ if (globalLogDomain()->shouldLog(LogComponent::kSharding, LogSeverity::Debug(3))) {
+ LogstreamBuilder(globalLogDomain(), getThreadName(), LogSeverity::Debug(3),
+ LogComponent::kSharding)
+ << "found " << _validDiffs
+ << " new chunks for collection " << _ns
+ << " (tracking " << newTracked.size()
+ << "), new version is " << *_maxVersion
+ << endl;
+ }
for( vector<BSONObj>::iterator it = newTracked.begin(); it != newTracked.end(); it++ ){
@@ -245,8 +258,13 @@ namespace mongo {
Query queryObj(query);
queryObj.sort(BSON( "lastmod" << 1 ));
- LOG(2) << "major version query from " << *_maxVersion << " and over "
- << _maxShardVersions->size() << " shards is " << queryObj << endl;
+ using namespace logger;
+ if (globalLogDomain()->shouldLog(LogComponent::kSharding, LogSeverity::Debug(2))) {
+ LogstreamBuilder(globalLogDomain(), getThreadName(), LogSeverity::Debug(2),
+ LogComponent::kSharding)
+ << "major version query from " << *_maxVersion << " and over "
+ << _maxShardVersions->size() << " shards is " << queryObj << endl;
+ }
return queryObj;
}
diff --git a/src/mongo/s/chunk_manager_targeter.cpp b/src/mongo/s/chunk_manager_targeter.cpp
index 6c03eb96376..316a8040d9f 100644
--- a/src/mongo/s/chunk_manager_targeter.cpp
+++ b/src/mongo/s/chunk_manager_targeter.cpp
@@ -30,6 +30,7 @@
#include "mongo/s/config.h"
#include "mongo/s/grid.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
diff --git a/src/mongo/s/chunk_manager_targeter_test.cpp b/src/mongo/s/chunk_manager_targeter_test.cpp
index c04494685fc..00fc22d1ae7 100644
--- a/src/mongo/s/chunk_manager_targeter_test.cpp
+++ b/src/mongo/s/chunk_manager_targeter_test.cpp
@@ -31,6 +31,7 @@
#include "mongo/db/query/interval.h"
#include "mongo/s/chunk.h"
#include "mongo/unittest/unittest.h"
+#include "mongo/util/log.h"
namespace {
diff --git a/src/mongo/s/cluster_write.cpp b/src/mongo/s/cluster_write.cpp
index 8a79b4ddcd0..178964a2176 100644
--- a/src/mongo/s/cluster_write.cpp
+++ b/src/mongo/s/cluster_write.cpp
@@ -42,6 +42,7 @@
#include "mongo/s/grid.h"
#include "mongo/s/write_ops/batch_write_exec.h"
#include "mongo/s/write_ops/config_coordinator.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/net/hostandport.h"
diff --git a/src/mongo/s/collection_metadata.cpp b/src/mongo/s/collection_metadata.cpp
index 0a57b78c520..49b966fc1fb 100644
--- a/src/mongo/s/collection_metadata.cpp
+++ b/src/mongo/s/collection_metadata.cpp
@@ -29,6 +29,7 @@
#include "mongo/s/collection_metadata.h"
#include "mongo/bson/util/builder.h" // for StringBuilder
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
diff --git a/src/mongo/s/commands/auth_schema_upgrade_s.cpp b/src/mongo/s/commands/auth_schema_upgrade_s.cpp
index 41f569815b1..747624a125a 100644
--- a/src/mongo/s/commands/auth_schema_upgrade_s.cpp
+++ b/src/mongo/s/commands/auth_schema_upgrade_s.cpp
@@ -44,6 +44,7 @@
#include "mongo/s/config.h"
#include "mongo/s/shard.h"
#include "mongo/s/type_shard.h"
+#include "mongo/util/log.h"
namespace mongo {
namespace {
diff --git a/src/mongo/s/config_upgrade.cpp b/src/mongo/s/config_upgrade.cpp
index e9ef27af369..a38525a7d23 100644
--- a/src/mongo/s/config_upgrade.cpp
+++ b/src/mongo/s/config_upgrade.cpp
@@ -39,6 +39,7 @@
#include "mongo/s/type_shard.h"
#include "mongo/stdx/functional.h"
#include "mongo/util/assert_util.h"
+#include "mongo/util/log.h"
#include "mongo/util/version.h"
namespace mongo {
diff --git a/src/mongo/s/config_upgrade_helpers.cpp b/src/mongo/s/config_upgrade_helpers.cpp
index 54fc191f263..60a821bfa74 100644
--- a/src/mongo/s/config_upgrade_helpers.cpp
+++ b/src/mongo/s/config_upgrade_helpers.cpp
@@ -35,6 +35,7 @@
#include "mongo/s/cluster_client_internal.h"
#include "mongo/s/cluster_write.h"
#include "mongo/s/type_config_version.h"
+#include "mongo/util/log.h"
#include "mongo/util/timer.h"
namespace mongo {
diff --git a/src/mongo/s/config_upgrade_v0_to_v5.cpp b/src/mongo/s/config_upgrade_v0_to_v5.cpp
index 4058f493c8f..c5726a86554 100644
--- a/src/mongo/s/config_upgrade_v0_to_v5.cpp
+++ b/src/mongo/s/config_upgrade_v0_to_v5.cpp
@@ -33,6 +33,7 @@
#include "mongo/s/cluster_client_internal.h"
#include "mongo/s/cluster_write.h"
#include "mongo/s/type_config_version.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
diff --git a/src/mongo/s/d_merge.cpp b/src/mongo/s/d_merge.cpp
index 060a903d027..6a4cb65dfdf 100644
--- a/src/mongo/s/d_merge.cpp
+++ b/src/mongo/s/d_merge.cpp
@@ -34,6 +34,7 @@
#include "mongo/s/distlock.h"
#include "mongo/s/chunk.h" // needed for genID
#include "mongo/s/config.h" // needed for changelog write
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
diff --git a/src/mongo/s/distlock.h b/src/mongo/s/distlock.h
index fc7fb27c16b..8516392df27 100644
--- a/src/mongo/s/distlock.h
+++ b/src/mongo/s/distlock.h
@@ -33,6 +33,7 @@
#include "mongo/client/connpool.h"
#include "mongo/client/export_macros.h"
#include "mongo/client/syncclusterconnection.h"
+#include "mongo/logger/labeled_level.h"
#define LOCK_TIMEOUT (15 * 60 * 1000)
#define LOCK_SKEW_FACTOR (30)
@@ -100,7 +101,7 @@ namespace mongo {
class MONGO_CLIENT_API DistributedLock {
public:
- static LabeledLevel logLvl;
+ static logger::LabeledLevel logLvl;
struct PingData {
diff --git a/src/mongo/s/mongos_options.cpp b/src/mongo/s/mongos_options.cpp
index d30b86feb5a..a9fe58c1b66 100644
--- a/src/mongo/s/mongos_options.cpp
+++ b/src/mongo/s/mongos_options.cpp
@@ -37,6 +37,7 @@
#include "mongo/db/server_options_helpers.h"
#include "mongo/s/chunk.h"
#include "mongo/s/version_mongos.h"
+#include "mongo/util/log.h"
#include "mongo/util/net/ssl_options.h"
#include "mongo/util/options_parser/startup_options.h"
#include "mongo/util/startup_test.h"
diff --git a/src/mongo/s/s_only.cpp b/src/mongo/s/s_only.cpp
index eea7e4804f2..f925d13ce84 100644
--- a/src/mongo/s/s_only.cpp
+++ b/src/mongo/s/s_only.cpp
@@ -40,6 +40,7 @@
#include "mongo/s/grid.h"
#include "mongo/s/request.h"
#include "mongo/s/shard.h"
+#include "mongo/util/log.h"
#include "mongo/util/concurrency/thread_name.h"
/*
diff --git a/src/mongo/s/scc_fast_query_handler.cpp b/src/mongo/s/scc_fast_query_handler.cpp
index 86e22927525..89565388f17 100644
--- a/src/mongo/s/scc_fast_query_handler.cpp
+++ b/src/mongo/s/scc_fast_query_handler.cpp
@@ -37,6 +37,7 @@
#include "mongo/client/dbclientinterface.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/server_parameters.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/s/server.cpp b/src/mongo/s/server.cpp
index bc3d6be2ab5..bdba4eef3ea 100644
--- a/src/mongo/s/server.cpp
+++ b/src/mongo/s/server.cpp
@@ -325,7 +325,6 @@ static void startupConfigActions(const std::vector<std::string>& argv) {
}
static int _main() {
-
if (!initializeServerGlobalState())
return EXIT_FAILURE;
diff --git a/src/mongo/s/shardconnection.cpp b/src/mongo/s/shardconnection.cpp
index 8d43f8826cb..ca2c7dfdaf9 100644
--- a/src/mongo/s/shardconnection.cpp
+++ b/src/mongo/s/shardconnection.cpp
@@ -44,6 +44,7 @@
#include "mongo/s/version_manager.h"
#include "mongo/server.h"
#include "mongo/util/concurrency/spin_lock.h"
+#include "mongo/util/log.h"
#include "mongo/util/stacktrace.h"
namespace mongo {
diff --git a/src/mongo/scripting/engine.cpp b/src/mongo/scripting/engine.cpp
index 449fe15ee08..e6ffb6e309d 100644
--- a/src/mongo/scripting/engine.cpp
+++ b/src/mongo/scripting/engine.cpp
@@ -38,6 +38,7 @@
#include "mongo/client/dbclientinterface.h"
#include "mongo/platform/unordered_set.h"
#include "mongo/util/file.h"
+#include "mongo/util/log.h"
#include "mongo/util/text.h"
namespace mongo {
diff --git a/src/mongo/scripting/engine_v8-3.25.cpp b/src/mongo/scripting/engine_v8-3.25.cpp
index a2c57034e26..c9b6274e642 100644
--- a/src/mongo/scripting/engine_v8-3.25.cpp
+++ b/src/mongo/scripting/engine_v8-3.25.cpp
@@ -1865,6 +1865,51 @@ namespace mongo {
*v8::String::Utf8Value(args[0]->ToString())));
}
+ /**
+ * Check for an error condition (e.g. empty handle, JS exception, OOM) after executing
+ * a v8 operation.
+ * @resultHandle handle storing the result of the preceding v8 operation
+ * @try_catch the active v8::TryCatch exception handler
+ * @param reportError if true, log an error message
+ * @param assertOnError if true, throw an exception if an error is detected
+ * if false, return value indicates error state
+ * @return true if an error was detected and assertOnError is set to false
+ * false if no error was detected
+ */
+ template <typename _HandleType>
+ bool V8Scope::checkV8ErrorState(const _HandleType& resultHandle,
+ const v8::TryCatch& try_catch,
+ bool reportError,
+ bool assertOnError) {
+ bool haveError = false;
+
+ if (try_catch.HasCaught() && try_catch.CanContinue()) {
+ // normal JS exception
+ _error = v8ExceptionToSTLString(&try_catch);
+ haveError = true;
+ }
+ else if (hasOutOfMemoryException()) {
+ // out of memory exception (treated as terminal)
+ _error = "JavaScript execution failed -- v8 is out of memory";
+ haveError = true;
+ }
+ else if (resultHandle.IsEmpty() || try_catch.HasCaught()) {
+ // terminal exception (due to empty handle, termination, etc.)
+ _error = "JavaScript execution failed";
+ haveError = true;
+ }
+
+ if (haveError) {
+ if (reportError)
+ log() << _error << endl;
+ if (assertOnError)
+ uasserted(16722, _error);
+ return true;
+ }
+
+ return false;
+ }
+
MONGO_INITIALIZER(JavascriptPrintDomain)(InitializerContext*) {
jsPrintLogDomain = logger::globalLogManager()->getNamedDomain("javascriptOutput");
return Status::OK();
diff --git a/src/mongo/scripting/engine_v8-3.25.h b/src/mongo/scripting/engine_v8-3.25.h
index c75c626019d..d5eae0c7417 100644
--- a/src/mongo/scripting/engine_v8-3.25.h
+++ b/src/mongo/scripting/engine_v8-3.25.h
@@ -41,7 +41,6 @@
#include "mongo/scripting/engine.h"
#include "mongo/scripting/v8_deadline_monitor.h"
#include "mongo/scripting/v8-3.25_profiler.h"
-#include "mongo/util/log.h"
/**
* V8_SIMPLE_HEADER must be placed in any function called from a public API
@@ -93,12 +92,6 @@ namespace mongo {
* V8Scope is destructed.
*/
~ObjTracker() {
- MONGO_LOG_DEFAULT_COMPONENT_LOCAL(::mongo::logger::LogComponent::kQuery);
-
- if (!_container.empty()) {
- LOG(1) << "freeing " << _container.size() << " uncollected "
- << typeid(_ObjType).name() << " objects" << endl;
- }
typename set<TrackedPtr*>::iterator it = _container.begin();
while (it != _container.end()) {
delete *it;
@@ -600,51 +593,6 @@ namespace mongo {
set<string> _removed;
};
- /**
- * Check for an error condition (e.g. empty handle, JS exception, OOM) after executing
- * a v8 operation.
- * @resultHandle handle storing the result of the preceding v8 operation
- * @try_catch the active v8::TryCatch exception handler
- * @param reportError if true, log an error message
- * @param assertOnError if true, throw an exception if an error is detected
- * if false, return value indicates error state
- * @return true if an error was detected and assertOnError is set to false
- * false if no error was detected
- */
- template <typename _HandleType>
- bool V8Scope::checkV8ErrorState(const _HandleType& resultHandle,
- const v8::TryCatch& try_catch,
- bool reportError,
- bool assertOnError) {
- bool haveError = false;
-
- if (try_catch.HasCaught() && try_catch.CanContinue()) {
- // normal JS exception
- _error = v8ExceptionToSTLString(&try_catch);
- haveError = true;
- }
- else if (hasOutOfMemoryException()) {
- // out of memory exception (treated as terminal)
- _error = "JavaScript execution failed -- v8 is out of memory";
- haveError = true;
- }
- else if (resultHandle.IsEmpty() || try_catch.HasCaught()) {
- // terminal exception (due to empty handle, termination, etc.)
- _error = "JavaScript execution failed";
- haveError = true;
- }
-
- if (haveError) {
- if (reportError)
- log() << _error << endl;
- if (assertOnError)
- uasserted(16722, _error);
- return true;
- }
-
- return false;
- }
-
extern ScriptEngine* globalScriptEngine;
}
diff --git a/src/mongo/scripting/engine_v8.cpp b/src/mongo/scripting/engine_v8.cpp
index 05e6aa54017..65604bb0306 100644
--- a/src/mongo/scripting/engine_v8.cpp
+++ b/src/mongo/scripting/engine_v8.cpp
@@ -1786,6 +1786,51 @@ namespace mongo {
*v8::String::Utf8Value(args[0]->ToString())));
}
+ /**
+ * Check for an error condition (e.g. empty handle, JS exception, OOM) after executing
+ * a v8 operation.
+ * @resultHandle handle storing the result of the preceding v8 operation
+ * @try_catch the active v8::TryCatch exception handler
+ * @param reportError if true, log an error message
+ * @param assertOnError if true, throw an exception if an error is detected
+ * if false, return value indicates error state
+ * @return true if an error was detected and assertOnError is set to false
+ * false if no error was detected
+ */
+ template <typename _HandleType>
+ bool V8Scope::checkV8ErrorState(const _HandleType& resultHandle,
+ const v8::TryCatch& try_catch,
+ bool reportError,
+ bool assertOnError) {
+ bool haveError = false;
+
+ if (try_catch.HasCaught() && try_catch.CanContinue()) {
+ // normal JS exception
+ _error = v8ExceptionToSTLString(&try_catch);
+ haveError = true;
+ }
+ else if (hasOutOfMemoryException()) {
+ // out of memory exception (treated as terminal)
+ _error = "JavaScript execution failed -- v8 is out of memory";
+ haveError = true;
+ }
+ else if (resultHandle.IsEmpty() || try_catch.HasCaught()) {
+ // terminal exception (due to empty handle, termination, etc.)
+ _error = "JavaScript execution failed";
+ haveError = true;
+ }
+
+ if (haveError) {
+ if (reportError)
+ log() << _error << std::endl;
+ if (assertOnError)
+ uasserted(16722, _error);
+ return true;
+ }
+
+ return false;
+ }
+
MONGO_INITIALIZER(JavascriptPrintDomain)(InitializerContext*) {
jsPrintLogDomain = logger::globalLogManager()->getNamedDomain("javascriptOutput");
return Status::OK();
diff --git a/src/mongo/scripting/engine_v8.h b/src/mongo/scripting/engine_v8.h
index 9c3de0f732a..4e2bceceea1 100644
--- a/src/mongo/scripting/engine_v8.h
+++ b/src/mongo/scripting/engine_v8.h
@@ -41,7 +41,6 @@
#include "mongo/scripting/engine.h"
#include "mongo/scripting/v8_deadline_monitor.h"
#include "mongo/scripting/v8_profiler.h"
-#include "mongo/util/log.h"
/**
* V8_SIMPLE_HEADER must be placed in any function called from a public API
@@ -90,12 +89,6 @@ namespace mongo {
* V8Scope is destructed.
*/
~ObjTracker() {
- MONGO_LOG_DEFAULT_COMPONENT_LOCAL(::mongo::logger::LogComponent::kQuery);
-
- if (!_container.empty()) {
- LOG(1) << "freeing " << _container.size() << " uncollected "
- << typeid(_ObjType).name() << " objects" << std::endl;
- }
typename std::set<TrackedPtr*>::iterator it = _container.begin();
while (it != _container.end()) {
delete *it;
@@ -574,51 +567,6 @@ namespace mongo {
std::set<std::string> _removed;
};
- /**
- * Check for an error condition (e.g. empty handle, JS exception, OOM) after executing
- * a v8 operation.
- * @resultHandle handle storing the result of the preceding v8 operation
- * @try_catch the active v8::TryCatch exception handler
- * @param reportError if true, log an error message
- * @param assertOnError if true, throw an exception if an error is detected
- * if false, return value indicates error state
- * @return true if an error was detected and assertOnError is set to false
- * false if no error was detected
- */
- template <typename _HandleType>
- bool V8Scope::checkV8ErrorState(const _HandleType& resultHandle,
- const v8::TryCatch& try_catch,
- bool reportError,
- bool assertOnError) {
- bool haveError = false;
-
- if (try_catch.HasCaught() && try_catch.CanContinue()) {
- // normal JS exception
- _error = v8ExceptionToSTLString(&try_catch);
- haveError = true;
- }
- else if (hasOutOfMemoryException()) {
- // out of memory exception (treated as terminal)
- _error = "JavaScript execution failed -- v8 is out of memory";
- haveError = true;
- }
- else if (resultHandle.IsEmpty() || try_catch.HasCaught()) {
- // terminal exception (due to empty handle, termination, etc.)
- _error = "JavaScript execution failed";
- haveError = true;
- }
-
- if (haveError) {
- if (reportError)
- log() << _error << std::endl;
- if (assertOnError)
- uasserted(16722, _error);
- return true;
- }
-
- return false;
- }
-
extern ScriptEngine* globalScriptEngine;
}
diff --git a/src/mongo/scripting/v8-3.25_utils.cpp b/src/mongo/scripting/v8-3.25_utils.cpp
index 9c2043431ea..6a6241db324 100644
--- a/src/mongo/scripting/v8-3.25_utils.cpp
+++ b/src/mongo/scripting/v8-3.25_utils.cpp
@@ -40,6 +40,7 @@
#include "mongo/platform/cstdint.h"
#include "mongo/scripting/engine_v8-3.25.h"
#include "mongo/scripting/v8-3.25_db.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
using namespace std;
diff --git a/src/mongo/scripting/v8_utils.cpp b/src/mongo/scripting/v8_utils.cpp
index 14c17cbe4e9..88974a52a00 100644
--- a/src/mongo/scripting/v8_utils.cpp
+++ b/src/mongo/scripting/v8_utils.cpp
@@ -40,6 +40,7 @@
#include "mongo/platform/cstdint.h"
#include "mongo/scripting/engine_v8.h"
#include "mongo/scripting/v8_db.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
using namespace std;
diff --git a/src/mongo/server.h b/src/mongo/server.h
index 0565511b09f..dbf594313c0 100644
--- a/src/mongo/server.h
+++ b/src/mongo/server.h
@@ -57,9 +57,3 @@
// prefetch data from memory
//#define PREFETCH MONGOPREFETCH
-
-// logs at most once per secs
-#define LOGATMOST(secs) static time_t __last = 0; time_t __now=time(0); if(__last+secs>__now) {} else if ( ( __last = __now ) > 0 ) log()
-
-// log but not too fast. this is rather simplistic we can do something fancier later
-#define LOGSOME LOGATMOST(20)
diff --git a/src/mongo/shell/bench.cpp b/src/mongo/shell/bench.cpp
index c1253e7710e..94394d1e57d 100644
--- a/src/mongo/shell/bench.cpp
+++ b/src/mongo/shell/bench.cpp
@@ -41,6 +41,7 @@
#include "mongo/client/dbclientcursor.h"
#include "mongo/scripting/bson_template_evaluator.h"
#include "mongo/scripting/engine.h"
+#include "mongo/util/log.h"
#include "mongo/util/md5.h"
#include "mongo/util/timer.h"
#include "mongo/util/version.h"
diff --git a/src/mongo/shell/dbshell.cpp b/src/mongo/shell/dbshell.cpp
index d493ca7a351..e313035e454 100644
--- a/src/mongo/shell/dbshell.cpp
+++ b/src/mongo/shell/dbshell.cpp
@@ -52,6 +52,7 @@
#include "mongo/shell/shell_utils_launcher.h"
#include "mongo/util/exit_code.h"
#include "mongo/util/file.h"
+#include "mongo/util/log.h"
#include "mongo/util/net/ssl_options.h"
#include "mongo/util/password.h"
#include "mongo/util/signal_handlers.h"
diff --git a/src/mongo/shell/shell_utils_extended.cpp b/src/mongo/shell/shell_utils_extended.cpp
index cd9f6a7aeea..3dcdb62340c 100644
--- a/src/mongo/shell/shell_utils_extended.cpp
+++ b/src/mongo/shell/shell_utils_extended.cpp
@@ -36,6 +36,7 @@
#include "mongo/shell/shell_utils.h"
#include "mongo/shell/shell_utils_launcher.h"
#include "mongo/util/file.h"
+#include "mongo/util/log.h"
#include "mongo/util/md5.hpp"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/net/sock.h"
diff --git a/src/mongo/shell/shell_utils_launcher.cpp b/src/mongo/shell/shell_utils_launcher.cpp
index dc2965bbee2..2e8c52d908d 100644
--- a/src/mongo/shell/shell_utils_launcher.cpp
+++ b/src/mongo/shell/shell_utils_launcher.cpp
@@ -52,6 +52,7 @@
#include "mongo/client/dbclientinterface.h"
#include "mongo/scripting/engine.h"
#include "mongo/shell/shell_utils.h"
+#include "mongo/util/log.h"
#include "mongo/util/scopeguard.h"
#include "mongo/util/signal_win32.h"
diff --git a/src/mongo/tools/bridge.cpp b/src/mongo/tools/bridge.cpp
index 7181258505c..df0b812399a 100644
--- a/src/mongo/tools/bridge.cpp
+++ b/src/mongo/tools/bridge.cpp
@@ -34,6 +34,7 @@
#include "mongo/client/dbclientinterface.h"
#include "mongo/db/dbmessage.h"
#include "mongo/tools/mongobridge_options.h"
+#include "mongo/util/log.h"
#include "mongo/util/net/listen.h"
#include "mongo/util/net/message.h"
#include "mongo/util/stacktrace.h"
diff --git a/src/mongo/tools/dump.cpp b/src/mongo/tools/dump.cpp
index 0b6eafb2e58..d02a4812f4f 100644
--- a/src/mongo/tools/dump.cpp
+++ b/src/mongo/tools/dump.cpp
@@ -46,6 +46,7 @@
#include "mongo/tools/mongodump_options.h"
#include "mongo/tools/tool.h"
#include "mongo/util/options_parser/option_section.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
using namespace mongo;
diff --git a/src/mongo/tools/import.cpp b/src/mongo/tools/import.cpp
index 21d6bbbe599..9d2f45ae472 100644
--- a/src/mongo/tools/import.cpp
+++ b/src/mongo/tools/import.cpp
@@ -37,6 +37,7 @@
#include "mongo/db/json.h"
#include "mongo/tools/mongoimport_options.h"
#include "mongo/tools/tool.h"
+#include "mongo/util/log.h"
#include "mongo/util/options_parser/option_section.h"
#include "mongo/util/text.h"
diff --git a/src/mongo/tools/tool.cpp b/src/mongo/tools/tool.cpp
index be176133832..0921b358338 100644
--- a/src/mongo/tools/tool.cpp
+++ b/src/mongo/tools/tool.cpp
@@ -53,6 +53,7 @@
#include "mongo/platform/posix_fadvise.h"
#include "mongo/util/exception_filter_win32.h"
#include "mongo/util/exit.h"
+#include "mongo/util/log.h"
#include "mongo/util/options_parser/option_section.h"
#include "mongo/util/password.h"
#include "mongo/util/net/ssl_options.h"
diff --git a/src/mongo/util/alignedbuilder.cpp b/src/mongo/util/alignedbuilder.cpp
index da650bc15ab..ae557b26edd 100644
--- a/src/mongo/util/alignedbuilder.cpp
+++ b/src/mongo/util/alignedbuilder.cpp
@@ -31,6 +31,7 @@
#include "mongo/pch.h"
#include "mongo/util/alignedbuilder.h"
+#include "mongo/util/log.h"
namespace mongo {
diff --git a/src/mongo/util/alignedbuilder.h b/src/mongo/util/alignedbuilder.h
index 600ea1c1914..460e737ba87 100644
--- a/src/mongo/util/alignedbuilder.h
+++ b/src/mongo/util/alignedbuilder.h
@@ -31,6 +31,7 @@
#pragma once
#include "mongo/base/string_data.h"
+#include "mongo/bson/util/builder.h"
namespace mongo {
diff --git a/src/mongo/util/assert_util.cpp b/src/mongo/util/assert_util.cpp
index 61d970364c8..db876bede64 100644
--- a/src/mongo/util/assert_util.cpp
+++ b/src/mongo/util/assert_util.cpp
@@ -27,7 +27,7 @@
* then also delete it in the license file.
*/
-#include "mongo/pch.h"
+#include "mongo/platform/basic.h"
#include "mongo/util/assert_util.h"
@@ -39,6 +39,8 @@ using namespace std;
#endif
#include "mongo/bson/bsonobjbuilder.h"
+#include "mongo/util/debug_util.h"
+#include "mongo/util/log.h"
#include "mongo/util/stacktrace.h"
namespace mongo {
diff --git a/src/mongo/util/assert_util.h b/src/mongo/util/assert_util.h
index 525631e2e48..d10ea6df6a9 100644
--- a/src/mongo/util/assert_util.h
+++ b/src/mongo/util/assert_util.h
@@ -37,6 +37,10 @@
#include "mongo/bson/inline_decls.h"
#include "mongo/client/export_macros.h"
#include "mongo/platform/compiler.h"
+#include "mongo/logger/log_severity.h"
+#include "mongo/logger/logger.h"
+#include "mongo/logger/logstream_builder.h"
+#include "mongo/util/concurrency/thread_name.h"
namespace mongo {
@@ -311,10 +315,16 @@ namespace mongo {
try { \
expression; \
} catch ( const std::exception &e ) { \
- ::mongo::log() << "caught exception (" << e.what() << ") in destructor (" << __FUNCTION__ \
- << ")" << std::endl; \
+ ::mongo::logger::LogstreamBuilder(::mongo::logger::globalLogDomain(), \
+ ::mongo::getThreadName(), \
+ ::mongo::logger::LogSeverity::Log()) \
+ << "caught exception (" << e.what() << ") in destructor (" << __FUNCTION__ \
+ << ")" << std::endl; \
} catch ( ... ) { \
- ::mongo::log() << "caught unknown exception in destructor (" << __FUNCTION__ << ")" \
- << std::endl; \
+ ::mongo::logger::LogstreamBuilder(::mongo::logger::globalLogDomain(), \
+ ::mongo::getThreadName(), \
+ ::mongo::logger::LogSeverity::Log()) \
+ << "caught unknown exception in destructor (" << __FUNCTION__ << ")" \
+ << std::endl; \
}
diff --git a/src/mongo/util/concurrency/list.h b/src/mongo/util/concurrency/list.h
index 37afe1736d9..450cb6f3dce 100644
--- a/src/mongo/util/concurrency/list.h
+++ b/src/mongo/util/concurrency/list.h
@@ -30,8 +30,6 @@
#pragma once
-#include "mongo/util/log.h"
-
namespace mongo {
/* DON'T USE THIS. it was a dumb idea.
@@ -100,8 +98,6 @@ namespace mongo {
n = prev;
}
prev = t->_next;
- if( ++_orphans > 500 )
- log() << "warning List1 orphans=" << _orphans;
}
private:
diff --git a/src/mongo/util/concurrency/rwlock.h b/src/mongo/util/concurrency/rwlock.h
index 3ee18969db6..edb76e1d5ea 100644
--- a/src/mongo/util/concurrency/rwlock.h
+++ b/src/mongo/util/concurrency/rwlock.h
@@ -34,7 +34,6 @@
#include "mongo/util/concurrency/rwlockimpl.h"
#include "mongo/util/concurrency/simplerwlock.h"
#include "mongo/util/debug_util.h"
-#include "mongo/util/log.h"
#include "mongo/util/time_support.h"
namespace mongo {
@@ -233,7 +232,6 @@ namespace mongo {
i += ( sleep - 1 );
}
if ( ! got ) {
- log() << "couldn't lazily get rwlock";
RWLockBase::lock();
}
}
diff --git a/src/mongo/util/concurrency/task.cpp b/src/mongo/util/concurrency/task.cpp
index 5f7b8acf221..6fa843c3131 100644
--- a/src/mongo/util/concurrency/task.cpp
+++ b/src/mongo/util/concurrency/task.cpp
@@ -35,6 +35,7 @@
#include "mongo/db/repl/server.h"
#include "mongo/util/goodies.h"
+#include "mongo/util/log.h"
#include "mongo/util/startup_test.h"
#include "mongo/util/time_support.h"
diff --git a/src/mongo/util/concurrency/thread_pool.cpp b/src/mongo/util/concurrency/thread_pool.cpp
index 792370ca8e9..ffeecda1be4 100644
--- a/src/mongo/util/concurrency/thread_pool.cpp
+++ b/src/mongo/util/concurrency/thread_pool.cpp
@@ -34,6 +34,7 @@
#include <boost/thread/thread.hpp>
+#include "mongo/util/log.h"
#include "mongo/util/concurrency/mvar.h"
namespace mongo {
diff --git a/src/mongo/util/fail_point.cpp b/src/mongo/util/fail_point.cpp
index abbf324a7ec..09ad57e7423 100644
--- a/src/mongo/util/fail_point.cpp
+++ b/src/mongo/util/fail_point.cpp
@@ -29,6 +29,7 @@
#include "mongo/util/fail_point.h"
#include "mongo/util/mongoutils/str.h"
+#include "mongo/util/log.h"
#include "mongo/util/time_support.h"
using mongoutils::str::stream;
diff --git a/src/mongo/util/fail_point_test.cpp b/src/mongo/util/fail_point_test.cpp
index de9dad03bc6..611407dbf24 100644
--- a/src/mongo/util/fail_point_test.cpp
+++ b/src/mongo/util/fail_point_test.cpp
@@ -32,6 +32,7 @@
#include <vector>
#include "mongo/util/fail_point.h"
+#include "mongo/util/log.h"
#include "mongo/util/time_support.h"
#include "mongo/unittest/unittest.h"
diff --git a/src/mongo/util/goodies.h b/src/mongo/util/goodies.h
index 4be632afed7..2a2991644c5 100644
--- a/src/mongo/util/goodies.h
+++ b/src/mongo/util/goodies.h
@@ -88,8 +88,6 @@ namespace mongo {
// PRINTFL; prints file:line
#define MONGO_PRINTFL std::cout << __FILE__ ":" << __LINE__ << std::endl
#define PRINTFL MONGO_PRINTFL
-#define MONGO_FLOG log() << __FILE__ ":" << __LINE__ << std::endl
-#define FLOG MONGO_FLOG
inline bool startsWith(const char *str, const char *prefix) {
size_t l = strlen(prefix);
diff --git a/src/mongo/util/logfile.cpp b/src/mongo/util/logfile.cpp
index affbba0a9dd..b8d28e3cfa7 100644
--- a/src/mongo/util/logfile.cpp
+++ b/src/mongo/util/logfile.cpp
@@ -33,6 +33,7 @@
#include "mongo/util/logfile.h"
#include "mongo/platform/posix_fadvise.h"
+#include "mongo/util/log.h"
#include "mongo/util/mmap.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/startup_test.h"
diff --git a/src/mongo/util/mmap.cpp b/src/mongo/util/mmap.cpp
index 61e338bc4d0..4ebf58f21c8 100644
--- a/src/mongo/util/mmap.cpp
+++ b/src/mongo/util/mmap.cpp
@@ -35,6 +35,7 @@
#include "mongo/base/owned_pointer_vector.h"
#include "mongo/util/concurrency/rwlock.h"
+#include "mongo/util/log.h"
#include "mongo/util/map_util.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/processinfo.h"
diff --git a/src/mongo/util/mmap_posix.cpp b/src/mongo/util/mmap_posix.cpp
index 110bda3253f..3e0b2d89a5a 100644
--- a/src/mongo/util/mmap_posix.cpp
+++ b/src/mongo/util/mmap_posix.cpp
@@ -38,6 +38,7 @@
#include "mongo/platform/atomic_word.h"
#include "mongo/db/d_concurrency.h"
#include "mongo/util/file_allocator.h"
+#include "mongo/util/log.h"
#include "mongo/util/mmap.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/processinfo.h"
diff --git a/src/mongo/util/mmap_win.cpp b/src/mongo/util/mmap_win.cpp
index fbea0a2a143..9865784dc0a 100644
--- a/src/mongo/util/mmap_win.cpp
+++ b/src/mongo/util/mmap_win.cpp
@@ -32,6 +32,7 @@
#include "mongo/db/d_concurrency.h"
#include "mongo/db/storage/mmap_v1/durable_mapped_file.h"
#include "mongo/util/file_allocator.h"
+#include "mongo/util/log.h"
#include "mongo/util/mmap.h"
#include "mongo/util/processinfo.h"
#include "mongo/util/text.h"
diff --git a/src/mongo/util/net/listen.cpp b/src/mongo/util/net/listen.cpp
index 5252f24e5f8..4f83e53e111 100644
--- a/src/mongo/util/net/listen.cpp
+++ b/src/mongo/util/net/listen.cpp
@@ -590,4 +590,30 @@ namespace mongo {
TicketHolder Listener::globalTicketHolder(DEFAULT_MAX_CONN);
AtomicInt64 Listener::globalConnectionNumber;
+
+ void ListeningSockets::closeAll() {
+ std::set<int>* sockets;
+ std::set<std::string>* paths;
+
+ {
+ scoped_lock lk( _mutex );
+ sockets = _sockets;
+ _sockets = new std::set<int>();
+ paths = _socketPaths;
+ _socketPaths = new std::set<std::string>();
+ }
+
+ for ( std::set<int>::iterator i=sockets->begin(); i!=sockets->end(); i++ ) {
+ int sock = *i;
+ log() << "closing listening socket: " << sock << std::endl;
+ closesocket( sock );
+ }
+
+ for ( std::set<std::string>::iterator i=paths->begin(); i!=paths->end(); i++ ) {
+ std::string path = *i;
+ log() << "removing socket file: " << path << std::endl;
+ ::remove( path.c_str() );
+ }
+ }
+
}
diff --git a/src/mongo/util/net/listen.h b/src/mongo/util/net/listen.h
index f997f0bea1e..8af354efd18 100644
--- a/src/mongo/util/net/listen.h
+++ b/src/mongo/util/net/listen.h
@@ -35,7 +35,6 @@
#include "mongo/platform/atomic_word.h"
#include "mongo/util/concurrency/ticketholder.h"
-#include "mongo/util/log.h"
#include "mongo/util/net/sock.h"
namespace mongo {
@@ -143,30 +142,7 @@ namespace mongo {
scoped_lock lk( _mutex );
_sockets->erase( sock );
}
- void closeAll() {
- std::set<int>* sockets;
- std::set<std::string>* paths;
-
- {
- scoped_lock lk( _mutex );
- sockets = _sockets;
- _sockets = new std::set<int>();
- paths = _socketPaths;
- _socketPaths = new std::set<std::string>();
- }
-
- for ( std::set<int>::iterator i=sockets->begin(); i!=sockets->end(); i++ ) {
- int sock = *i;
- log() << "closing listening socket: " << sock << std::endl;
- closesocket( sock );
- }
-
- for ( std::set<std::string>::iterator i=paths->begin(); i!=paths->end(); i++ ) {
- std::string path = *i;
- log() << "removing socket file: " << path << std::endl;
- ::remove( path.c_str() );
- }
- }
+ void closeAll();
static ListeningSockets* get();
private:
mongo::mutex _mutex;
diff --git a/src/mongo/util/net/message_server_port.cpp b/src/mongo/util/net/message_server_port.cpp
index 77526c47f6b..34ba0d13460 100644
--- a/src/mongo/util/net/message_server_port.cpp
+++ b/src/mongo/util/net/message_server_port.cpp
@@ -41,6 +41,7 @@
#include "mongo/util/concurrency/thread_name.h"
#include "mongo/util/concurrency/ticketholder.h"
#include "mongo/util/exit.h"
+#include "mongo/util/log.h"
#include "mongo/util/net/listen.h"
#include "mongo/util/net/message.h"
#include "mongo/util/net/message_port.h"
diff --git a/src/mongo/util/net/ssl_options.cpp b/src/mongo/util/net/ssl_options.cpp
index 37814a6d80a..e94dde422fb 100644
--- a/src/mongo/util/net/ssl_options.cpp
+++ b/src/mongo/util/net/ssl_options.cpp
@@ -33,6 +33,7 @@
#include "mongo/base/status.h"
#include "mongo/db/server_options.h"
+#include "mongo/util/log.h"
#include "mongo/util/options_parser/startup_options.h"
namespace mongo {
diff --git a/src/mongo/util/ntservice.cpp b/src/mongo/util/ntservice.cpp
index f5d569135d8..888a27c9bf4 100644
--- a/src/mongo/util/ntservice.cpp
+++ b/src/mongo/util/ntservice.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/client.h"
#include "mongo/db/instance.h"
#include "mongo/util/assert_util.h"
+#include "mongo/util/log.h"
#include "mongo/util/options_parser/environment.h"
#include "mongo/util/text.h"
#include "mongo/util/winutil.h"
diff --git a/src/mongo/util/password.cpp b/src/mongo/util/password.cpp
index e29cb8926ce..493f30dd4ea 100644
--- a/src/mongo/util/password.cpp
+++ b/src/mongo/util/password.cpp
@@ -36,6 +36,8 @@
#include <termios.h>
#endif
+#include "mongo/util/log.h"
+
using namespace std;
namespace mongo {
diff --git a/src/mongo/util/paths.cpp b/src/mongo/util/paths.cpp
index 56ac3a68b59..d309f3f21bf 100644
--- a/src/mongo/util/paths.cpp
+++ b/src/mongo/util/paths.cpp
@@ -35,6 +35,36 @@ namespace mongo {
MONGO_LOG_DEFAULT_COMPONENT_FILE(::mongo::logger::LogComponent::kStorage);
+ /** from a full path */
+ RelativePath RelativePath::fromFullPath(boost::filesystem::path dbp,
+ boost::filesystem::path f) {
+ // filesystem::path normalizes / and backslash
+ std::string fullpath = f.string();
+ std::string relative = str::after(fullpath, dbp.string());
+ if( relative.empty() ) {
+ log() << "warning file is not under db path? " << fullpath << ' ' << dbp.string();
+ RelativePath rp;
+ rp._p = fullpath;
+ return rp;
+ }
+ if( str::startsWith(relative, "/") || str::startsWith(relative, "\\") ) {
+ relative.erase(0, 1);
+ }
+ RelativePath rp;
+ rp._p = relative;
+ return rp;
+ }
+
+ dev_t getPartition(const std::string& path){
+ struct stat stats;
+
+ if (stat(path.c_str(), &stats) != 0){
+ uasserted(13646, str::stream() << "stat() failed for file: " << path << " " << errnoWithDescription());
+ }
+
+ return stats.st_dev;
+ }
+
void flushMyDirectory(const boost::filesystem::path& file) {
#ifdef __linux__ // this isn't needed elsewhere
static bool _warnedAboutFilesystem = false;
diff --git a/src/mongo/util/paths.h b/src/mongo/util/paths.h
index f06c24bf500..8286c920566 100644
--- a/src/mongo/util/paths.h
+++ b/src/mongo/util/paths.h
@@ -35,7 +35,6 @@
#include <sys/stat.h>
#include <fcntl.h>
-#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/db/storage_options.h"
@@ -58,24 +57,11 @@ namespace mongo {
return rp;
}
- /** from a full path */
- static RelativePath fromFullPath(boost::filesystem::path f) {
- boost::filesystem::path dbp(storageGlobalParams.dbpath); // normalizes / and backslash
- std::string fullpath = f.string();
- std::string relative = str::after(fullpath, dbp.string());
- if( relative.empty() ) {
- log() << "warning file is not under db path? " << fullpath << ' ' << dbp.string();
- RelativePath rp;
- rp._p = fullpath;
- return rp;
- }
- if( str::startsWith(relative, "/") || str::startsWith(relative, "\\") ) {
- relative.erase(0, 1);
- }
- RelativePath rp;
- rp._p = relative;
- return rp;
- }
+ /**
+ * Returns path relative to 'dbpath' from a full path 'f'.
+ */
+ static RelativePath fromFullPath(boost::filesystem::path dbpath,
+ boost::filesystem::path f);
std::string toString() const { return _p; }
@@ -91,15 +77,7 @@ namespace mongo {
};
- inline dev_t getPartition(const std::string& path){
- struct stat stats;
-
- if (stat(path.c_str(), &stats) != 0){
- uasserted(13646, str::stream() << "stat() failed for file: " << path << " " << errnoWithDescription());
- }
-
- return stats.st_dev;
- }
+ dev_t getPartition(const std::string& path);
inline bool onSamePartition(const std::string& path1, const std::string& path2){
dev_t dev1 = getPartition(path1);
diff --git a/src/mongo/util/processinfo.cpp b/src/mongo/util/processinfo.cpp
index 59daa2908c6..8d0265fc8ca 100644
--- a/src/mongo/util/processinfo.cpp
+++ b/src/mongo/util/processinfo.cpp
@@ -35,6 +35,8 @@
#include <iostream>
#include <fstream>
+#include "mongo/util/log.h"
+
using namespace std;
namespace mongo {
diff --git a/src/mongo/util/processinfo_freebsd.cpp b/src/mongo/util/processinfo_freebsd.cpp
index f8b1d1f58ad..208b3905c14 100644
--- a/src/mongo/util/processinfo_freebsd.cpp
+++ b/src/mongo/util/processinfo_freebsd.cpp
@@ -40,6 +40,7 @@
#include <vm/vm_param.h>
#include "mongo/util/scopeguard.h"
+#include "mongo/util/log.h"
#include "processinfo.h"
namespace mongo {
diff --git a/src/mongo/util/processinfo_linux2.cpp b/src/mongo/util/processinfo_linux2.cpp
index 53d1ab90b6d..777ad2e5890 100644
--- a/src/mongo/util/processinfo_linux2.cpp
+++ b/src/mongo/util/processinfo_linux2.cpp
@@ -38,6 +38,7 @@
#include "processinfo.h"
#include "boost/filesystem.hpp"
#include <mongo/util/file.h>
+#include "mongo/util/log.h"
using namespace std;
diff --git a/src/mongo/util/processinfo_openbsd5.cpp b/src/mongo/util/processinfo_openbsd5.cpp
index f1fcc0d29aa..e995f14ce9f 100644
--- a/src/mongo/util/processinfo_openbsd5.cpp
+++ b/src/mongo/util/processinfo_openbsd5.cpp
@@ -39,6 +39,7 @@
#include <unistd.h>
#include "mongo/util/scopeguard.h"
+#include "mongo/util/log.h"
#include "processinfo.h"
namespace mongo {
diff --git a/src/mongo/util/processinfo_sunos5.cpp b/src/mongo/util/processinfo_sunos5.cpp
index 2591456147b..fdfbe54d2db 100644
--- a/src/mongo/util/processinfo_sunos5.cpp
+++ b/src/mongo/util/processinfo_sunos5.cpp
@@ -39,6 +39,7 @@
#include <vector>
#include "mongo/util/file.h"
+#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
#include "mongo/util/processinfo.h"
diff --git a/src/mongo/util/processinfo_win32.cpp b/src/mongo/util/processinfo_win32.cpp
index 47d3e15ad76..0b5a6a147a5 100644
--- a/src/mongo/util/processinfo_win32.cpp
+++ b/src/mongo/util/processinfo_win32.cpp
@@ -33,6 +33,7 @@
#include <psapi.h>
#include "mongo/util/processinfo.h"
+#include "mongo/util/log.h"
using namespace std;
diff --git a/src/mongo/util/signal_handlers_synchronous.cpp b/src/mongo/util/signal_handlers_synchronous.cpp
index 37d6fbad02e..9453e64801d 100644
--- a/src/mongo/util/signal_handlers_synchronous.cpp
+++ b/src/mongo/util/signal_handlers_synchronous.cpp
@@ -45,6 +45,7 @@
#include "mongo/util/debug_util.h"
#include "mongo/util/exception_filter_win32.h"
#include "mongo/util/exit_code.h"
+#include "mongo/util/log.h"
#include "mongo/util/stacktrace.h"
#include "mongo/util/text.h"
diff --git a/src/mongo/util/stacktrace.h b/src/mongo/util/stacktrace.h
index 8e10932a6ab..40fa666fdaf 100644
--- a/src/mongo/util/stacktrace.h
+++ b/src/mongo/util/stacktrace.h
@@ -33,7 +33,10 @@
#include <iostream>
-#include "mongo/util/log.h"
+#include "mongo/logger/log_severity.h"
+#include "mongo/logger/logger.h"
+#include "mongo/logger/logstream_builder.h"
+#include "mongo/util/concurrency/thread_name.h"
#if defined(_WIN32)
// We need to pick up a decl for CONTEXT. Forward declaring would be preferable, but it is
@@ -43,12 +46,21 @@
namespace mongo {
+ /**
+ * Returns a log stream builder suitable for printStackTrace() default argument
+ * Do not use in any other context.
+ */
+ inline logger::LogstreamBuilder getStackTraceLogger() {
+ using namespace logger;
+ return LogstreamBuilder(globalLogDomain(), getThreadName(), LogSeverity::Log());
+ }
+
// Print stack trace information to "os", default to the log stream.
- void printStackTrace(std::ostream &os=log().stream());
+ void printStackTrace(std::ostream &os=getStackTraceLogger().stream());
#if defined(_WIN32)
// Print stack trace (using a specified stack context) to "os", default to the log stream.
- void printWindowsStackTrace(CONTEXT &context, std::ostream &os=log().stream());
+ void printWindowsStackTrace(CONTEXT &context, std::ostream &os=getStackTraceLogger().stream());
// Print error message from C runtime followed by stack trace
int crtDebugCallback(int, char* originalMessage, int*);
diff --git a/src/mongo/util/version_reporting.cpp b/src/mongo/util/version_reporting.cpp
index 19dea284c2b..15f5acd8c91 100644
--- a/src/mongo/util/version_reporting.cpp
+++ b/src/mongo/util/version_reporting.cpp
@@ -36,6 +36,7 @@
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/db/jsobj.h"
+#include "mongo/util/log.h"
#include "mongo/util/net/ssl_manager.h"
#include "mongo/util/version.h"