diff options
author | Gabriel Russell <gabriel.russell@mongodb.com> | 2020-02-28 15:46:04 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-02-28 23:25:35 +0000 |
commit | 74cb40385caadff986539d3b274b60e74772eda1 (patch) | |
tree | 01c9db53fae553d49be8cd614a87fe6b95d85449 | |
parent | f9c85d489e1d0dd7e9458d67af3a7675c0f2200c (diff) | |
download | mongo-74cb40385caadff986539d3b274b60e74772eda1.tar.gz |
SERVER-45567 removing util/log.h where I can
59 files changed, 99 insertions, 135 deletions
diff --git a/src/mongo/client/connpool.cpp b/src/mongo/client/connpool.cpp index 7c035961eb4..bdfae49529c 100644 --- a/src/mongo/client/connpool.cpp +++ b/src/mongo/client/connpool.cpp @@ -47,7 +47,6 @@ #include "mongo/logv2/log.h" #include "mongo/stdx/chrono.h" #include "mongo/util/exit.h" -#include "mongo/util/log.h" #include "mongo/util/net/socket_exception.h" #if !defined(__has_feature) @@ -91,8 +90,11 @@ PoolForHost::~PoolForHost() { void PoolForHost::clear() { if (!_parentDestroyed) { - logNoCache() << "Dropping all pooled connections to " << _hostName << "(with timeout of " - << _socketTimeoutSecs << " seconds)"; + LOGV2(24124, + "Dropping all pooled connections to {hostName}(with timeout of {socketTimeoutSecs} " + "seconds)", + "hostName"_attr = _hostName, + "socketTimeoutSecs"_attr = _socketTimeoutSecs); } _pool = decltype(_pool){}; @@ -112,17 +114,23 @@ auto PoolForHost::done(DBConnectionPool* pool, DBClientBase* c) -> ConnectionHea bool isBroken = c->getSockCreationMicroSec() < _minValidCreationTimeMicroSec; if (isFailed || isBroken) { _badConns++; - logNoCache() << "Ending connection to host " << _hostName << "(with timeout of " - << _socketTimeoutSecs << " seconds)" - << " due to bad connection status; " << openConnections() - << " connections to that host remain open"; + LOGV2( + 24125, + "Ending connection to host {hostName}(with timeout of {socketTimeoutSecs} seconds) due " + "to bad connection status; {openConnections} connections to that host remain open", + "hostName"_attr = _hostName, + "socketTimeoutSecs"_attr = _socketTimeoutSecs, + "openConnections"_attr = openConnections()); return ConnectionHealth::kFailed; } else if (_maxPoolSize >= 0 && static_cast<int>(_pool.size()) >= _maxPoolSize) { // We have a pool size that we need to enforce - logNoCache() << "Ending idle connection to host " << _hostName << "(with timeout of " - << _socketTimeoutSecs << " seconds)" - << " because the pool meets constraints; " << openConnections() - << " connections to that host remain open"; + LOGV2(24126, + "Ending idle connection to host {hostName}(with timeout of {socketTimeoutSecs} " + "seconds) because the pool meets constraints; {openConnections} connections to that " + "host remain open", + "hostName"_attr = _hostName, + "socketTimeoutSecs"_attr = _socketTimeoutSecs, + "openConnections"_attr = openConnections()); return ConnectionHealth::kTooMany; } @@ -135,9 +143,12 @@ void PoolForHost::reportBadConnectionAt(uint64_t microSec) { if (microSec != DBClientBase::INVALID_SOCK_CREATION_TIME && microSec > _minValidCreationTimeMicroSec) { _minValidCreationTimeMicroSec = microSec; - logNoCache() << "Detected bad connection created at " << _minValidCreationTimeMicroSec - << " microSec, clearing pool for " << _hostName << " of " << openConnections() - << " connections" << endl; + LOGV2(24127, + "Detected bad connection created at {minValidCreationTimeMicroSec} microSec, " + "clearing pool for {hostName} of {openConnections} connections", + "minValidCreationTimeMicroSec"_attr = _minValidCreationTimeMicroSec, + "hostName"_attr = _hostName, + "openConnections"_attr = openConnections()); clear(); } } @@ -689,8 +700,9 @@ ScopedDbConnection::~ScopedDbConnection() { } } else { /* see done() comments above for why we log this line */ - logNoCache() << "scoped connection to " << _conn->getServerAddress() - << " not being returned to the pool" << endl; + LOGV2(24128, + "scoped connection to {conn_getServerAddress} not being returned to the pool", + "conn_getServerAddress"_attr = _conn->getServerAddress()); kill(); } } diff --git a/src/mongo/client/scanning_replica_set_monitor.cpp b/src/mongo/client/scanning_replica_set_monitor.cpp index 9a4c6e30f4b..97cd848281d 100644 --- a/src/mongo/client/scanning_replica_set_monitor.cpp +++ b/src/mongo/client/scanning_replica_set_monitor.cpp @@ -53,7 +53,6 @@ #include "mongo/util/debug_util.h" #include "mongo/util/exit.h" #include "mongo/util/fail_point.h" -#include "mongo/util/log.h" #include "mongo/util/string_map.h" #include "mongo/util/timer.h" diff --git a/src/mongo/client/scanning_replica_set_monitor_test_concurrent.cpp b/src/mongo/client/scanning_replica_set_monitor_test_concurrent.cpp index 1d10a4805ee..7d12919c9d3 100644 --- a/src/mongo/client/scanning_replica_set_monitor_test_concurrent.cpp +++ b/src/mongo/client/scanning_replica_set_monitor_test_concurrent.cpp @@ -39,9 +39,9 @@ #include "mongo/executor/thread_pool_task_executor.h" #include "mongo/executor/thread_pool_task_executor_test_fixture.h" #include "mongo/logv2/log.h" +#include "mongo/unittest/log_test.h" #include "mongo/unittest/unittest.h" #include "mongo/util/duration.h" -#include "mongo/util/log.h" namespace mongo { namespace { @@ -61,11 +61,7 @@ protected: launchExecutorThread(); _startTime = getNet()->now(); - { - using namespace logger; - globalLogDomain()->setMinimumLoggedSeverity(LogComponent::kNetwork, - LogSeverity::Debug(2)); - } + { setMinimumLoggedSeverity(logv2::LogComponent::kNetwork, logv2::LogSeverity::Debug(2)); } setGlobalServiceContext(std::move(serviceContext)); } diff --git a/src/mongo/db/catalog/catalog_control.cpp b/src/mongo/db/catalog/catalog_control.cpp index 47a2b333924..0af48451cd4 100644 --- a/src/mongo/db/catalog/catalog_control.cpp +++ b/src/mongo/db/catalog/catalog_control.cpp @@ -45,7 +45,6 @@ #include "mongo/db/namespace_string.h" #include "mongo/db/rebuild_indexes.h" #include "mongo/logv2/log.h" -#include "mongo/util/log.h" namespace mongo { namespace catalog { diff --git a/src/mongo/db/commands/generic_servers.cpp b/src/mongo/db/commands/generic_servers.cpp index 51bfd5ab8b4..0d0aa8e892f 100644 --- a/src/mongo/db/commands/generic_servers.cpp +++ b/src/mongo/db/commands/generic_servers.cpp @@ -43,6 +43,7 @@ #include "mongo/util/exit.h" #include "mongo/util/fail_point.h" #include "mongo/util/log.h" +#include "mongo/util/log_global_settings.h" #include "mongo/util/net/socket_utils.h" #include "mongo/util/ntservice.h" #include "mongo/util/processinfo.h" diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp index f929b0f3ffa..980697f55b4 100644 --- a/src/mongo/db/index/index_access_method.cpp +++ b/src/mongo/db/index/index_access_method.cpp @@ -53,9 +53,9 @@ #include "mongo/db/storage/durable_catalog.h" #include "mongo/db/storage/storage_options.h" #include "mongo/logv2/log.h" -#include "mongo/util/log.h" #include "mongo/util/progress_meter.h" #include "mongo/util/scopeguard.h" +#include "mongo/util/stacktrace.h" namespace mongo { @@ -214,7 +214,7 @@ void AbstractIndexAccessMethod::removeOneKey(OperationContext* opCtx, "e"_attr = redact(e), "keyString"_attr = keyString, "loc"_attr = loc); - logContext(); + printStackTrace(); } } diff --git a/src/mongo/db/initialize_server_global_state.cpp b/src/mongo/db/initialize_server_global_state.cpp index 22e35f3a753..7d3a9d97628 100644 --- a/src/mongo/db/initialize_server_global_state.cpp +++ b/src/mongo/db/initialize_server_global_state.cpp @@ -62,7 +62,8 @@ #include "mongo/logv2/log.h" #include "mongo/logv2/log_domain_global.h" #include "mongo/platform/process_id.h" -#include "mongo/util/log.h" +#include "mongo/util/exit_code.h" +#include "mongo/util/log_global_settings.h" #include "mongo/util/processinfo.h" #include "mongo/util/quick_exit.h" #include "mongo/util/signal_handlers_synchronous.h" diff --git a/src/mongo/db/matcher/schema/json_schema_parser.cpp b/src/mongo/db/matcher/schema/json_schema_parser.cpp index b1bf59f0334..4cdc0ba0502 100644 --- a/src/mongo/db/matcher/schema/json_schema_parser.cpp +++ b/src/mongo/db/matcher/schema/json_schema_parser.cpp @@ -61,7 +61,6 @@ #include "mongo/db/matcher/schema/json_pointer.h" #include "mongo/logger/log_component_settings.h" #include "mongo/logv2/log.h" -#include "mongo/util/log.h" #include "mongo/util/string_map.h" namespace mongo { diff --git a/src/mongo/db/mongod_options.cpp b/src/mongo/db/mongod_options.cpp index 44ccfbdcfd5..c1926b20762 100644 --- a/src/mongo/db/mongod_options.cpp +++ b/src/mongo/db/mongod_options.cpp @@ -56,7 +56,6 @@ #include "mongo/logv2/log.h" #include "mongo/logv2/log_domain_global.h" #include "mongo/logv2/log_manager.h" -#include "mongo/util/log.h" #include "mongo/util/net/ssl_options.h" #include "mongo/util/options_parser/startup_options.h" #include "mongo/util/str.h" diff --git a/src/mongo/db/pipeline/process_interface/mongos_process_interface.cpp b/src/mongo/db/pipeline/process_interface/mongos_process_interface.cpp index 09fc0fc00d0..346d5aa4a04 100644 --- a/src/mongo/db/pipeline/process_interface/mongos_process_interface.cpp +++ b/src/mongo/db/pipeline/process_interface/mongos_process_interface.cpp @@ -44,6 +44,7 @@ #include "mongo/db/repl/read_concern_args.h" #include "mongo/db/s/scoped_collection_metadata.h" #include "mongo/executor/task_executor_pool.h" +#include "mongo/logger/redaction.h" #include "mongo/s/catalog_cache.h" #include "mongo/s/cluster_commands_helpers.h" #include "mongo/s/grid.h" @@ -52,7 +53,6 @@ #include "mongo/s/query/router_exec_stage.h" #include "mongo/s/transaction_router.h" #include "mongo/util/fail_point.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 09430c49295..ef1eec6c5db 100644 --- a/src/mongo/db/repl/isself.cpp +++ b/src/mongo/db/repl/isself.cpp @@ -45,7 +45,6 @@ #include "mongo/db/commands.h" #include "mongo/db/service_context.h" #include "mongo/logv2/log.h" -#include "mongo/util/log.h" #include "mongo/util/net/socket_utils.h" #include "mongo/util/scopeguard.h" diff --git a/src/mongo/db/repl/oplog_applier_impl.cpp b/src/mongo/db/repl/oplog_applier_impl.cpp index 35557b1309d..bda68314dfc 100644 --- a/src/mongo/db/repl/oplog_applier_impl.cpp +++ b/src/mongo/db/repl/oplog_applier_impl.cpp @@ -49,7 +49,6 @@ #include "mongo/logv2/log.h" #include "mongo/platform/basic.h" #include "mongo/util/fail_point.h" -#include "mongo/util/log.h" #include "mongo/util/log_with_sampling.h" #include "third_party/murmurhash3/MurmurHash3.h" diff --git a/src/mongo/db/repl/repl_set_commands.cpp b/src/mongo/db/repl/repl_set_commands.cpp index 3502678d362..d9557fd599b 100644 --- a/src/mongo/db/repl/repl_set_commands.cpp +++ b/src/mongo/db/repl/repl_set_commands.cpp @@ -69,7 +69,6 @@ #include "mongo/transport/transport_layer.h" #include "mongo/util/decimal_counter.h" #include "mongo/util/fail_point.h" -#include "mongo/util/log.h" #include "mongo/util/net/socket_utils.h" #include "mongo/util/scopeguard.h" diff --git a/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp index e39c06ef556..80e73615e30 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp @@ -48,7 +48,6 @@ #include "mongo/unittest/log_test.h" #include "mongo/unittest/unittest.h" #include "mongo/util/fail_point.h" -#include "mongo/util/log.h" #include <boost/optional/optional_io.hpp> diff --git a/src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp index 4313fa2edb1..30e703d75a6 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp @@ -45,7 +45,6 @@ #include "mongo/rpc/metadata/repl_set_metadata.h" #include "mongo/unittest/log_test.h" #include "mongo/unittest/unittest.h" -#include "mongo/util/log.h" namespace mongo { namespace repl { diff --git a/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp index 70a2f0b4ead..f26f232484b 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp @@ -44,7 +44,6 @@ #include "mongo/unittest/log_test.h" #include "mongo/unittest/unittest.h" #include "mongo/util/fail_point.h" -#include "mongo/util/log.h" namespace mongo { namespace repl { diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp index 1f4e4c4b930..f9af67b85b8 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp @@ -74,7 +74,6 @@ #include "mongo/unittest/log_test.h" #include "mongo/unittest/unittest.h" #include "mongo/util/assert_util.h" -#include "mongo/util/log.h" #include "mongo/util/scopeguard.h" #include "mongo/util/time_support.h" #include "mongo/util/timer.h" diff --git a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp index 6537eccf6ca..3d2070a3f47 100644 --- a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp +++ b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp @@ -53,9 +53,9 @@ #include "mongo/executor/thread_pool_mock.h" #include "mongo/executor/thread_pool_task_executor.h" #include "mongo/logv2/log.h" +#include "mongo/unittest/log_test.h" #include "mongo/unittest/unittest.h" #include "mongo/util/fail_point.h" -#include "mongo/util/log.h" namespace mongo { namespace repl { @@ -87,8 +87,7 @@ ReplCoordTest::ReplCoordTest() { } ReplCoordTest::~ReplCoordTest() { - logger::globalLogDomain()->clearMinimumLoggedSeverity( - logger::LogComponent::kReplicationElection); + clearMinimumLoggedSeverity(logv2::LogComponent::kReplicationElection); globalFailPointRegistry().find("blockHeartbeatReconfigFinish")->setMode(FailPoint::off); if (_callShutdown) { diff --git a/src/mongo/db/repl/replication_recovery.cpp b/src/mongo/db/repl/replication_recovery.cpp index 667170bc97f..0241c5ed1aa 100644 --- a/src/mongo/db/repl/replication_recovery.cpp +++ b/src/mongo/db/repl/replication_recovery.cpp @@ -52,7 +52,6 @@ #include "mongo/db/transaction_history_iterator.h" #include "mongo/db/transaction_participant.h" #include "mongo/logv2/log.h" -#include "mongo/util/log.h" #include "mongo/util/timer.h" namespace mongo { diff --git a/src/mongo/db/repl/topology_coordinator.cpp b/src/mongo/db/repl/topology_coordinator.cpp index f44faa167a9..3ffbbe4a695 100644 --- a/src/mongo/db/repl/topology_coordinator.cpp +++ b/src/mongo/db/repl/topology_coordinator.cpp @@ -62,7 +62,6 @@ #include "mongo/util/assert_util.h" #include "mongo/util/fail_point.h" #include "mongo/util/hex.h" -#include "mongo/util/log.h" #include "mongo/util/scopeguard.h" #include "mongo/util/str.h" diff --git a/src/mongo/db/s/shard_server_catalog_cache_loader.cpp b/src/mongo/db/s/shard_server_catalog_cache_loader.cpp index 4d5221be4af..e6860940940 100644 --- a/src/mongo/db/s/shard_server_catalog_cache_loader.cpp +++ b/src/mongo/db/s/shard_server_catalog_cache_loader.cpp @@ -53,7 +53,6 @@ #include "mongo/s/client/shard_registry.h" #include "mongo/s/grid.h" #include "mongo/util/fail_point.h" -#include "mongo/util/log.h" namespace mongo { diff --git a/src/mongo/db/s/transaction_coordinator.cpp b/src/mongo/db/s/transaction_coordinator.cpp index 37c3e1e67c6..94cc02a01fa 100644 --- a/src/mongo/db/s/transaction_coordinator.cpp +++ b/src/mongo/db/s/transaction_coordinator.cpp @@ -40,7 +40,6 @@ #include "mongo/logv2/log.h" #include "mongo/s/grid.h" #include "mongo/util/fail_point.h" -#include "mongo/util/log.h" namespace mongo { namespace { diff --git a/src/mongo/db/s/transaction_coordinator_test.cpp b/src/mongo/db/s/transaction_coordinator_test.cpp index cc312d67f1f..3f32fb09691 100644 --- a/src/mongo/db/s/transaction_coordinator_test.cpp +++ b/src/mongo/db/s/transaction_coordinator_test.cpp @@ -43,7 +43,6 @@ #include "mongo/unittest/log_test.h" #include "mongo/unittest/unittest.h" #include "mongo/util/clock_source_mock.h" -#include "mongo/util/log.h" #include "mongo/util/tick_source_mock.h" namespace mongo { diff --git a/src/mongo/db/server_options_test.cpp b/src/mongo/db/server_options_test.cpp index bb70d61bd1e..d88412aab46 100644 --- a/src/mongo/db/server_options_test.cpp +++ b/src/mongo/db/server_options_test.cpp @@ -56,7 +56,7 @@ #include "mongo/logger/logger.h" #include "mongo/unittest/log_test.h" #include "mongo/unittest/unittest.h" -#include "mongo/util/log.h" +#include "mongo/util/errno_util.h" #include "mongo/util/options_parser/environment.h" #include "mongo/util/options_parser/option_section.h" #include "mongo/util/options_parser/options_parser.h" diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp index 47587871f62..5786d848792 100644 --- a/src/mongo/db/service_entry_point_common.cpp +++ b/src/mongo/db/service_entry_point_common.cpp @@ -97,7 +97,6 @@ #include "mongo/transport/ismaster_metrics.h" #include "mongo/transport/session.h" #include "mongo/util/fail_point.h" -#include "mongo/util/log.h" #include "mongo/util/scopeguard.h" namespace mongo { diff --git a/src/mongo/db/storage/storage_engine_impl.cpp b/src/mongo/db/storage/storage_engine_impl.cpp index 46f98904947..d249b0a54ea 100644 --- a/src/mongo/db/storage/storage_engine_impl.cpp +++ b/src/mongo/db/storage/storage_engine_impl.cpp @@ -54,7 +54,6 @@ #include "mongo/logv2/log.h" #include "mongo/stdx/unordered_map.h" #include "mongo/util/assert_util.h" -#include "mongo/util/log.h" #include "mongo/util/scopeguard.h" #include "mongo/util/str.h" diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index 09fc723eed9..41795f7d0c5 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -92,7 +92,6 @@ #include "mongo/util/concurrency/ticketholder.h" #include "mongo/util/debug_util.h" #include "mongo/util/exit.h" -#include "mongo/util/log.h" #include "mongo/util/processinfo.h" #include "mongo/util/quick_exit.h" #include "mongo/util/scopeguard.h" diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp index a21f9505916..dc5122b3f8c 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp @@ -67,7 +67,6 @@ #include "mongo/util/assert_util.h" #include "mongo/util/concurrency/idle_thread_block.h" #include "mongo/util/fail_point.h" -#include "mongo/util/log.h" #include "mongo/util/scopeguard.h" #include "mongo/util/str.h" #include "mongo/util/time_support.h" diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp index 642e7b2d0c6..8a0dde07498 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp @@ -42,7 +42,6 @@ #include "mongo/db/storage/wiredtiger/wiredtiger_util.h" #include "mongo/logv2/log.h" #include "mongo/util/hex.h" -#include "mongo/util/log.h" namespace mongo { namespace { diff --git a/src/mongo/db/transaction_participant.cpp b/src/mongo/db/transaction_participant.cpp index d4c4f0c6e9f..c0737906754 100644 --- a/src/mongo/db/transaction_participant.cpp +++ b/src/mongo/db/transaction_participant.cpp @@ -65,7 +65,6 @@ #include "mongo/db/transaction_participant_gen.h" #include "mongo/logv2/log.h" #include "mongo/util/fail_point.h" -#include "mongo/util/log.h" #include "mongo/util/log_with_sampling.h" #include "mongo/util/net/socket_utils.h" diff --git a/src/mongo/dbtests/framework_options.cpp b/src/mongo/dbtests/framework_options.cpp index 7c9eeec52d4..89bed17e859 100644 --- a/src/mongo/dbtests/framework_options.cpp +++ b/src/mongo/dbtests/framework_options.cpp @@ -46,7 +46,6 @@ #include "mongo/logv2/log.h" #include "mongo/unittest/log_test.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/embedded/embedded.cpp b/src/mongo/embedded/embedded.cpp index d9d99b71285..cb5921fb0dc 100644 --- a/src/mongo/embedded/embedded.cpp +++ b/src/mongo/embedded/embedded.cpp @@ -70,7 +70,6 @@ #include "mongo/scripting/dbdirectclient_factory.h" #include "mongo/util/background.h" #include "mongo/util/exit.h" -#include "mongo/util/log.h" #include "mongo/util/periodic_runner_factory.h" #include "mongo/util/quick_exit.h" #include "mongo/util/time_support.h" diff --git a/src/mongo/executor/thread_pool_task_executor_integration_test.cpp b/src/mongo/executor/thread_pool_task_executor_integration_test.cpp index b41d9648f52..d5eeeac0504 100644 --- a/src/mongo/executor/thread_pool_task_executor_integration_test.cpp +++ b/src/mongo/executor/thread_pool_task_executor_integration_test.cpp @@ -39,7 +39,6 @@ #include "mongo/rpc/topology_version_gen.h" #include "mongo/unittest/integration_test.h" #include "mongo/unittest/unittest.h" -#include "mongo/util/log.h" namespace mongo { namespace executor { diff --git a/src/mongo/logger/log_test.cpp b/src/mongo/logger/log_test.cpp index 9ee4e1b6f85..a314450dbbe 100644 --- a/src/mongo/logger/log_test.cpp +++ b/src/mongo/logger/log_test.cpp @@ -61,16 +61,6 @@ namespace { typedef LogTest<MessageEventDetailsEncoder, logv2::TextFormatter> LogTestDetailsEncoder; typedef LogTest<MessageEventUnadornedEncoder, logv2::PlainFormatter> LogTestUnadornedEncoder; -TEST_F(LogTestUnadornedEncoder, logContext) { - logContext("WHA!"); - ASSERT_GREATER_THAN(_logLines.size(), 1U); - ASSERT_NOT_EQUALS(_logLines[0].find("WHA!"), std::string::npos); - - // TODO(schwerin): Ensure that logContext rights a proper context to the log stream, - // including the address of the logContext() function. - // void const* logContextFn = reinterpret_cast<void const*>(logContext); -} - class CountAppender : public Appender<MessageEventEphemeral> { public: CountAppender() : _count(0) {} diff --git a/src/mongo/logv2/log.h b/src/mongo/logv2/log.h index c39ec9a5518..32efccd43c4 100644 --- a/src/mongo/logv2/log.h +++ b/src/mongo/logv2/log.h @@ -80,7 +80,7 @@ const ::mongo::logv2::LogComponent MongoLogV2DefaultComponent_component = namespace mongo { #define LOGV2_IMPL(ID, SEVERITY, OPTIONS, MESSAGE, ...) \ - logv2::detail::doLog(ID, SEVERITY, OPTIONS, FMT_STRING(MESSAGE), ##__VA_ARGS__) + ::mongo::logv2::detail::doLog(ID, SEVERITY, OPTIONS, FMT_STRING(MESSAGE), ##__VA_ARGS__) #define LOGV2(ID, MESSAGE, ...) \ LOGV2_IMPL(ID, \ diff --git a/src/mongo/logv2/log_detail.h b/src/mongo/logv2/log_detail.h index b8916e2353e..90e143d3002 100644 --- a/src/mongo/logv2/log_detail.h +++ b/src/mongo/logv2/log_detail.h @@ -85,8 +85,10 @@ void doLog(int32_t id, } // namespace detail } // namespace logv2 +inline namespace literals { inline fmt::internal::udl_arg<char> operator"" _attr(const char* s, std::size_t) { return {s}; } +} // namespace literals } // namespace mongo diff --git a/src/mongo/rpc/op_msg_test.cpp b/src/mongo/rpc/op_msg_test.cpp index 074b6ae1c05..0ed775fafff 100644 --- a/src/mongo/rpc/op_msg_test.cpp +++ b/src/mongo/rpc/op_msg_test.cpp @@ -42,7 +42,6 @@ #include "mongo/unittest/log_test.h" #include "mongo/unittest/unittest.h" #include "mongo/util/hex.h" -#include "mongo/util/log.h" #include "third_party/wiredtiger/wiredtiger.h" namespace mongo { diff --git a/src/mongo/s/balancer_configuration.cpp b/src/mongo/s/balancer_configuration.cpp index 01b97a9ea54..be3887de2ed 100644 --- a/src/mongo/s/balancer_configuration.cpp +++ b/src/mongo/s/balancer_configuration.cpp @@ -46,7 +46,6 @@ #include "mongo/logv2/log.h" #include "mongo/s/catalog/sharding_catalog_client.h" #include "mongo/s/grid.h" -#include "mongo/util/log.h" #include "mongo/util/str.h" namespace mongo { diff --git a/src/mongo/s/catalog_cache.cpp b/src/mongo/s/catalog_cache.cpp index fe3c2b4f857..4753cf66877 100644 --- a/src/mongo/s/catalog_cache.cpp +++ b/src/mongo/s/catalog_cache.cpp @@ -49,7 +49,6 @@ #include "mongo/s/grid.h" #include "mongo/s/stale_exception.h" #include "mongo/util/concurrency/with_lock.h" -#include "mongo/util/log.h" #include "mongo/util/scopeguard.h" #include "mongo/util/timer.h" diff --git a/src/mongo/s/client/parallel.cpp b/src/mongo/s/client/parallel.cpp index 83cd918d5e9..cda8113ff33 100644 --- a/src/mongo/s/client/parallel.cpp +++ b/src/mongo/s/client/parallel.cpp @@ -45,7 +45,6 @@ #include "mongo/s/client/shard_connection.h" #include "mongo/s/client/shard_registry.h" #include "mongo/s/grid.h" -#include "mongo/util/log.h" #include "mongo/util/net/socket_exception.h" namespace mongo { diff --git a/src/mongo/s/client/shard_remote.cpp b/src/mongo/s/client/shard_remote.cpp index 1421fbbe7e5..9968547adcd 100644 --- a/src/mongo/s/client/shard_remote.cpp +++ b/src/mongo/s/client/shard_remote.cpp @@ -53,7 +53,6 @@ #include "mongo/rpc/metadata/tracking_metadata.h" #include "mongo/s/client/shard_remote_gen.h" #include "mongo/s/grid.h" -#include "mongo/util/log.h" #include "mongo/util/str.h" #include "mongo/util/time_support.h" diff --git a/src/mongo/s/client/version_manager.cpp b/src/mongo/s/client/version_manager.cpp index d720b910ef1..d02870886ff 100644 --- a/src/mongo/s/client/version_manager.cpp +++ b/src/mongo/s/client/version_manager.cpp @@ -47,7 +47,6 @@ #include "mongo/s/transaction_router.h" #include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/itoa.h" -#include "mongo/util/log.h" namespace mongo { diff --git a/src/mongo/s/mongos_options.cpp b/src/mongo/s/mongos_options.cpp index 918344bedce..f77696af1fe 100644 --- a/src/mongo/s/mongos_options.cpp +++ b/src/mongo/s/mongos_options.cpp @@ -45,7 +45,6 @@ #include "mongo/db/server_options_server_helpers.h" #include "mongo/logv2/log.h" #include "mongo/s/version_mongos.h" -#include "mongo/util/log.h" #include "mongo/util/net/socket_utils.h" #include "mongo/util/options_parser/startup_options.h" #include "mongo/util/str.h" @@ -156,11 +155,16 @@ Status storeMongosOptions(const moe::Environment& params) { } if (!resolvedSomeSeedSever) { if (!hostbyname(configdbConnectionString.getValue().getSetName().c_str()).empty()) { - warning() << "The replica set name \"" - << str::escape(configdbConnectionString.getValue().getSetName()) - << "\" resolves as a host name, but none of the servers in the seed list do. " - "Did you reverse the replica set name and the seed list in " - << str::escape(configdbConnectionString.getValue().toString()) << "?"; + LOGV2_WARNING(24131, + "The replica set name " + "\"{str_escape_configdbConnectionString_getValue_getSetName}\" resolves " + "as a host name, but none of the servers in the seed list do. " + "Did you reverse the replica set name and the seed list in " + "{str_escape_configdbConnectionString_getValue}?", + "str_escape_configdbConnectionString_getValue_getSetName"_attr = + str::escape(configdbConnectionString.getValue().getSetName()), + "str_escape_configdbConnectionString_getValue"_attr = + str::escape(configdbConnectionString.getValue().toString())); } } @@ -170,8 +174,9 @@ Status storeMongosOptions(const moe::Environment& params) { configdbConnectionString.getValue().getSetName()}; if (mongosGlobalParams.configdbs.getServers().size() < 3) { - warning() << "Running a sharded cluster with fewer than 3 config servers should only be " - "done for testing purposes and is not recommended for production."; + LOGV2_WARNING(24132, + "Running a sharded cluster with fewer than 3 config servers should only be " + "done for testing purposes and is not recommended for production."); } return Status::OK(); diff --git a/src/mongo/s/transaction_router.cpp b/src/mongo/s/transaction_router.cpp index bf228420fd5..d6c5f75c733 100644 --- a/src/mongo/s/transaction_router.cpp +++ b/src/mongo/s/transaction_router.cpp @@ -54,7 +54,6 @@ #include "mongo/s/router_transactions_metrics.h" #include "mongo/util/assert_util.h" #include "mongo/util/fail_point.h" -#include "mongo/util/log.h" #include "mongo/util/log_with_sampling.h" #include "mongo/util/net/socket_utils.h" diff --git a/src/mongo/s/transaction_router_test.cpp b/src/mongo/s/transaction_router_test.cpp index b507662caeb..9b278c445c1 100644 --- a/src/mongo/s/transaction_router_test.cpp +++ b/src/mongo/s/transaction_router_test.cpp @@ -52,7 +52,6 @@ #include "mongo/unittest/unittest.h" #include "mongo/util/clock_source_mock.h" #include "mongo/util/fail_point.h" -#include "mongo/util/log.h" #include "mongo/util/net/socket_utils.h" #include "mongo/util/tick_source_mock.h" diff --git a/src/mongo/s/version_mongos.cpp b/src/mongo/s/version_mongos.cpp index 75f23049c67..d11b4a2ac17 100644 --- a/src/mongo/s/version_mongos.cpp +++ b/src/mongo/s/version_mongos.cpp @@ -40,7 +40,6 @@ #include "mongo/logv2/log_manager.h" #include "mongo/platform/process_id.h" #include "mongo/util/debug_util.h" -#include "mongo/util/log.h" #include "mongo/util/version.h" namespace mongo { diff --git a/src/mongo/scripting/mozjs/engine.cpp b/src/mongo/scripting/mozjs/engine.cpp index c76cc95d23a..f8031a2372a 100644 --- a/src/mongo/scripting/mozjs/engine.cpp +++ b/src/mongo/scripting/mozjs/engine.cpp @@ -40,7 +40,6 @@ #include "mongo/scripting/mozjs/engine_gen.h" #include "mongo/scripting/mozjs/implscope.h" #include "mongo/scripting/mozjs/proxyscope.h" -#include "mongo/util/log.h" namespace js { void DisableExtraThreads(); diff --git a/src/mongo/scripting/mozjs/implscope.cpp b/src/mongo/scripting/mozjs/implscope.cpp index 795a67cc49f..34729b87a33 100644 --- a/src/mongo/scripting/mozjs/implscope.cpp +++ b/src/mongo/scripting/mozjs/implscope.cpp @@ -52,7 +52,6 @@ #include "mongo/scripting/mozjs/valuereader.h" #include "mongo/scripting/mozjs/valuewriter.h" #include "mongo/util/assert_util.h" -#include "mongo/util/log.h" #include "mongo/util/scopeguard.h" #if !defined(__has_feature) diff --git a/src/mongo/shell/dbshell.cpp b/src/mongo/shell/dbshell.cpp index 946e1e10782..1c73f3dca4f 100644 --- a/src/mongo/shell/dbshell.cpp +++ b/src/mongo/shell/dbshell.cpp @@ -77,7 +77,7 @@ #include "mongo/transport/transport_layer_asio.h" #include "mongo/util/exit.h" #include "mongo/util/file.h" -#include "mongo/util/log.h" +#include "mongo/util/log_global_settings.h" #include "mongo/util/net/ocsp/ocsp_manager.h" #include "mongo/util/net/ssl_options.h" #include "mongo/util/password.h" diff --git a/src/mongo/shell/shell_options.cpp b/src/mongo/shell/shell_options.cpp index 8ce8dc6e2ad..b6eef266cf9 100644 --- a/src/mongo/shell/shell_options.cpp +++ b/src/mongo/shell/shell_options.cpp @@ -48,7 +48,6 @@ #include "mongo/shell/shell_utils.h" #include "mongo/transport/message_compressor_options_client_gen.h" #include "mongo/transport/message_compressor_registry.h" -#include "mongo/util/log.h" #include "mongo/util/net/socket_utils.h" #include "mongo/util/options_parser/startup_options.h" #include "mongo/util/str.h" diff --git a/src/mongo/unittest/benchmark_main.cpp b/src/mongo/unittest/benchmark_main.cpp index 3d68ca5cc3c..08d5c246724 100644 --- a/src/mongo/unittest/benchmark_main.cpp +++ b/src/mongo/unittest/benchmark_main.cpp @@ -53,10 +53,10 @@ int main(int argc, char** argv, char** envp) { return 1; #ifndef MONGO_CONFIG_OPTIMIZED_BUILD - ::mongo::LOGV2(23049, - "***WARNING*** MongoDB was built with --opt=off. Function timings may be " - "affected. Always verify any code change against the production environment " - "(e.g. --opt=on)."); + LOGV2(23049, + "***WARNING*** MongoDB was built with --opt=off. Function timings may be " + "affected. Always verify any code change against the production environment " + "(e.g. --opt=on)."); #endif ::benchmark::RunSpecifiedBenchmarks(); diff --git a/src/mongo/unittest/death_test.cpp b/src/mongo/unittest/death_test.cpp index c15055e1cf5..fe2527f1c2d 100644 --- a/src/mongo/unittest/death_test.cpp +++ b/src/mongo/unittest/death_test.cpp @@ -45,17 +45,21 @@ #include <sstream> +#include "mongo/logv2/log.h" #include "mongo/util/assert_util.h" #include "mongo/util/log.h" #include "mongo/util/quick_exit.h" -#define checkSyscall(EXPR) \ - do { \ - if (-1 == (EXPR)) { \ - const int err = errno; \ - severe() << #EXPR " failed: " << errnoWithDescription(err); \ - invariantFailed("-1 != (" #EXPR ")", __FILE__, __LINE__); \ - } \ +#define checkSyscall(EXPR) \ + do { \ + if (-1 == (EXPR)) { \ + const int err = errno; \ + LOGV2_FATAL(24138, \ + "{expr} failed: {errno}", \ + "expr"_attr = #EXPR, \ + "errno"_attr = errnoWithDescription(err)); \ + invariantFailed("-1 != (" #EXPR ")", __FILE__, __LINE__); \ + } \ } while (false) namespace mongo { @@ -63,10 +67,10 @@ namespace unittest { void DeathTestBase::_doTest() { #if defined(_WIN32) - log() << "Skipping death test on Windows"; + LOGV2(24133, "Skipping death test on Windows"); return; #elif defined(__APPLE__) && (TARGET_OS_TV || TARGET_OS_WATCH) - log() << "Skipping death test on tvOS/watchOS"; + LOGV2(24134, "Skipping death test on tvOS/watchOS"); return; #else int pipes[2]; @@ -78,14 +82,14 @@ void DeathTestBase::_doTest() { char buf[1000]; std::ostringstream os; ssize_t bytesRead; - log() << "========== Beginning of interleaved output of death test =========="; + LOGV2(24135, "========== Beginning of interleaved output of death test =========="); while (0 < (bytesRead = read(pipes[0], buf, sizeof(buf)))) { std::cout.write(buf, bytesRead); invariant(std::cout); os.write(buf, bytesRead); invariant(os); } - log() << "========== End of interleaved output of death test =========="; + LOGV2(24136, "========== End of interleaved output of death test =========="); checkSyscall(bytesRead); pid_t pid; int stat; @@ -96,8 +100,11 @@ void DeathTestBase::_doTest() { case EINTR: continue; default: - severe() << "Unrecoverable error while waiting for " << child << ": " - << errnoWithDescription(err); + LOGV2_FATAL( + 24139, + "Unrecoverable error while waiting for {child}: {errnoWithDescription_err}", + "child"_attr = child, + "errnoWithDescription_err"_attr = errnoWithDescription(err)); MONGO_UNREACHABLE; } } @@ -130,7 +137,7 @@ void DeathTestBase::_doTest() { auto test = _doMakeTest(); test->run(); } catch (const TestAssertionFailureException& tafe) { - log() << "Caught test exception while expecting death: " << tafe; + LOGV2(24137, "Caught test exception while expecting death: {tafe}", "tafe"_attr = tafe); // To fail the test, we must exit with a successful error code, because the parent process // is checking for the child to die with an exit code indicating an error. quickExit(EXIT_SUCCESS); diff --git a/src/mongo/util/assert_util.cpp b/src/mongo/util/assert_util.cpp index c9f5d60fe6c..fcae3206449 100644 --- a/src/mongo/util/assert_util.cpp +++ b/src/mongo/util/assert_util.cpp @@ -47,7 +47,8 @@ #include "mongo/util/debug_util.h" #include "mongo/util/debugger.h" #include "mongo/util/exit.h" -#include "mongo/util/log.h" +#include "mongo/util/exit_code.h" +#include "mongo/util/log_global_settings.h" #include "mongo/util/quick_exit.h" #include "mongo/util/stacktrace.h" #include "mongo/util/str.h" @@ -88,7 +89,7 @@ MONGO_COMPILER_NOINLINE void verifyFailed(const char* expr, const char* file, un "expr"_attr = expr, "file"_attr = file, "line"_attr = line); - logContext(); + printStackTrace(); std::stringstream temp; temp << "assertion " << file << ":" << line; diff --git a/src/mongo/util/fail_point_test.cpp b/src/mongo/util/fail_point_test.cpp index 7b9973a9825..1687d3bf6c9 100644 --- a/src/mongo/util/fail_point_test.cpp +++ b/src/mongo/util/fail_point_test.cpp @@ -37,12 +37,12 @@ #include <vector> #include "mongo/db/client.h" +#include "mongo/logv2/log.h" #include "mongo/platform/mutex.h" #include "mongo/stdx/thread.h" #include "mongo/unittest/unittest.h" #include "mongo/util/clock_source_mock.h" #include "mongo/util/fail_point.h" -#include "mongo/util/log.h" #include "mongo/util/tick_source_mock.h" #include "mongo/util/time_support.h" @@ -177,8 +177,10 @@ private: // Expanded ASSERT_EQUALS since the error is not being // printed out properly if (data["a"].numberInt() != 44) { - mongo::error() << "blockTask thread detected anomaly" - << " - data: " << data << std::endl; + using namespace mongo::literals; + LOGV2_ERROR(24129, + "blockTask thread detected anomaly - data: {data}", + "data"_attr = data); ASSERT(false); } }); @@ -194,8 +196,10 @@ private: try { _fp.execute([](const BSONObj& data) { if (data["a"].numberInt() != 44) { - mongo::error() << "blockWithExceptionTask thread detected anomaly" - << " - data: " << data << std::endl; + using namespace mongo::literals; + LOGV2_ERROR(24130, + "blockWithExceptionTask thread detected anomaly - data: {data}", + "data"_attr = data); ASSERT(false); } diff --git a/src/mongo/util/log.cpp b/src/mongo/util/log.cpp index fdf9bd251ee..b7ab377dd22 100644 --- a/src/mongo/util/log.cpp +++ b/src/mongo/util/log.cpp @@ -100,15 +100,6 @@ bool rotateLogs(bool renameFiles) { return resultv2.isOK() && result.empty(); } -void logContext(const char* errmsg) { - if (errmsg) { - LOGV2(23167, "{errmsg}", "errmsg"_attr = errmsg); - } - // NOTE: We disable long-line truncation for the stack trace, because the JSON representation of - // the stack trace can sometimes exceed the long line limit. - printStackTrace(log().setIsTruncatable(false).stream()); -} - Tee* const startupWarningsLog = RamLog::get("startupWarnings"); // intentionally leaked } // namespace mongo diff --git a/src/mongo/util/log.h b/src/mongo/util/log.h index d723affff0d..c74520ce1fc 100644 --- a/src/mongo/util/log.h +++ b/src/mongo/util/log.h @@ -38,8 +38,7 @@ #if defined(MONGO_UTIL_LOG_H_) #error \ - "mongo/util/log.h cannot be included multiple times. " \ - "This may occur when log.h is included in a header. " \ + "This may occur when log.h is included in a header. " \ "Please check your #include's." #else // MONGO_UTIL_LOG_H_ #define MONGO_UTIL_LOG_H_ @@ -83,9 +82,7 @@ namespace { const ::mongo::logger::LogComponent MongoLogDefaultComponent_component = MONGO_LOG_DEFAULT_COMPONENT; #else -#error \ - "mongo/util/log.h requires MONGO_LOG_DEFAULT_COMPONENT to be defined. " \ - "Please see http://www.mongodb.org/about/contributors/reference/server-logging-rules/ " +#error "Please see http://www.mongodb.org/about/contributors/reference/server-logging-rules/ " #endif // MONGO_LOG_DEFAULT_COMPONENT using logger::LogstreamBuilderDeprecated; @@ -222,11 +219,6 @@ bool rotateLogs(bool renameFiles); extern Tee* const warnings; // Things put here go in serverStatus extern Tee* const startupWarningsLog; // Things put here get reported in MMS -/** - * Write the current context (backtrace), along with the optional "msg". - */ -void logContext(const char* msg = nullptr); - } // namespace mongo #endif // MONGO_UTIL_LOG_H_ diff --git a/src/mongo/util/net/sock.cpp b/src/mongo/util/net/sock.cpp index 05c792ad7b6..66478637344 100644 --- a/src/mongo/util/net/sock.cpp +++ b/src/mongo/util/net/sock.cpp @@ -63,7 +63,6 @@ #include "mongo/util/debug_util.h" #include "mongo/util/fail_point.h" #include "mongo/util/hex.h" -#include "mongo/util/log.h" #include "mongo/util/net/socket_exception.h" #include "mongo/util/net/socket_utils.h" #include "mongo/util/net/ssl_manager.h" diff --git a/src/mongo/util/net/ssl/detail/impl/engine_apple.ipp b/src/mongo/util/net/ssl/detail/impl/engine_apple.ipp index 3a238e154dc..b0d22696a35 100644 --- a/src/mongo/util/net/ssl/detail/impl/engine_apple.ipp +++ b/src/mongo/util/net/ssl/detail/impl/engine_apple.ipp @@ -40,7 +40,7 @@ #include <arpa/inet.h> -#include "mongo/util/log.h" +#include "mongo/logv2/log.h" #include "mongo/util/net/ssl/apple.hpp" #include "mongo/util/net/ssl/detail/engine.hpp" #include "mongo/util/net/ssl/detail/stream_core.hpp" @@ -149,7 +149,7 @@ bool engine::_initSSL(stream_base::handshake_type type, asio::error_code& ec) { const auto side = (type == stream_base::client) ? ::kSSLClientSide : ::kSSLServerSide; _ssl.reset(::SSLCreateContext(nullptr, side, ::kSSLStreamType)); if (!_ssl) { - mongo::error() << "Failed allocating SSLContext"; + LOGV2_ERROR(24140, "Failed allocating SSLContext"); ec = errorCode(::errSSLInternal); return false; } @@ -245,7 +245,7 @@ engine::want engine::shutdown(asio::error_code& ec) { ec = errorCode(status); } } else { - mongo::error() << "SSL connection already shut down"; + LOGV2_ERROR(24141, "SSL connection already shut down"); ec = errorCode(::errSSLInternal); } return want::want_nothing; diff --git a/src/mongo/watchdog/watchdog.cpp b/src/mongo/watchdog/watchdog.cpp index 97d861fc43f..401388c0d3d 100644 --- a/src/mongo/watchdog/watchdog.cpp +++ b/src/mongo/watchdog/watchdog.cpp @@ -48,6 +48,7 @@ #include "mongo/logv2/log.h" #include "mongo/platform/process_id.h" #include "mongo/util/concurrency/idle_thread_block.h" +#include "mongo/util/errno_util.h" #include "mongo/util/exit.h" #include "mongo/util/exit_code.h" #include "mongo/util/hex.h" |