diff --git a/dbms/src/Client/Connection.cpp b/dbms/src/Client/Connection.cpp index c9ed2b1a106..ce3e46704a8 100644 --- a/dbms/src/Client/Connection.cpp +++ b/dbms/src/Client/Connection.cpp @@ -63,8 +63,7 @@ void Connection::connect() if (connected) disconnect(); - LOG_TRACE(log_wrapper.get(), "Connecting. Database: " << (default_database.empty() ? "(not specified)" : default_database) << ". User: " << user << (static_cast(secure) ? ". Secure" : "") << (static_cast(compression) ? "" : ". Uncompressed")); - + LOG_FMT_TRACE(log_wrapper.get(), "Connecting. Database: {}. User: {}. {}, {}", (default_database.empty() ? "(not specified)" : default_database), user, (static_cast(secure) ? ". Secure" : ""), (static_cast(compression) ? "" : ". Uncompressed")); if (static_cast(secure)) { #if Poco_NetSSL_FOUND @@ -90,7 +89,7 @@ void Connection::connect() sendHello(); receiveHello(); - LOG_TRACE(log_wrapper.get(), "Connected to " << server_name << " server version " << server_version_major << "." << server_version_minor << "." << server_revision << "."); + LOG_FMT_TRACE(log_wrapper.get(), "Connected to {} server version {}.{}.{}.", server_name, server_version_major, server_version_minor, server_revision); } catch (Poco::Net::NetException & e) { @@ -232,7 +231,7 @@ void Connection::forceConnected() } else if (!ping()) { - LOG_TRACE(log_wrapper.get(), "Connection was closed, will reconnect."); + LOG_FMT_TRACE(log_wrapper.get(), "Connection was closed, will reconnect."); connect(); } } diff --git a/dbms/src/Common/AIO.h b/dbms/src/Common/AIO.h index ae97b80a6b3..f2e5b2adbd3 100644 --- a/dbms/src/Common/AIO.h +++ b/dbms/src/Common/AIO.h @@ -176,7 +176,7 @@ class AIOContextPool : public ext::Singleton const auto it = promises.find(id); if (it == std::end(promises)) { - LOG_ERROR(&Poco::Logger::get("AIOcontextPool"), "Found io_event with unknown id " << id); + LOG_FMT_ERROR(&Poco::Logger::get("AIOcontextPool"), "Found io_event with unknown id {}", id); continue; } diff --git a/dbms/src/Common/Config/ConfigReloader.cpp b/dbms/src/Common/Config/ConfigReloader.cpp index f9f466cfb82..8761198cc77 100644 --- a/dbms/src/Common/Config/ConfigReloader.cpp +++ b/dbms/src/Common/Config/ConfigReloader.cpp @@ -84,7 +84,7 @@ void ConfigReloader::reloadIfNewer(bool force, bool throw_on_error) ConfigProcessor::LoadedConfig loaded_config; try { - LOG_DEBUG(log, "Loading config `" << path << "'"); + LOG_FMT_DEBUG(log, "Loading config `{}`", path); loaded_config = config_processor.loadConfig(); } diff --git a/dbms/src/Common/FileChecker.cpp b/dbms/src/Common/FileChecker.cpp index b83ed097c8a..1669fb07d50 100644 --- a/dbms/src/Common/FileChecker.cpp +++ b/dbms/src/Common/FileChecker.cpp @@ -69,14 +69,14 @@ bool FileChecker::check() const Poco::File file(Poco::Path(files_info_path).parent().toString() + "/" + name_size.first); if (!file.exists()) { - LOG_ERROR(log, "File " << file.path() << " doesn't exist"); + LOG_FMT_ERROR(log, "File {} doesn't exist", file.path()); return false; } size_t real_size = file.getSize(); if (real_size != name_size.second) { - LOG_ERROR(log, "Size of " << file.path() << " is wrong. Size is " << real_size << " but should be " << name_size.second); + LOG_FMT_ERROR(log, "Size of {} is wrong. Size is {} but should be {}", file.path(), real_size, name_size.second); return false; } } diff --git a/dbms/src/Common/LRUCache.h b/dbms/src/Common/LRUCache.h index fdc871a9309..58d038843b8 100644 --- a/dbms/src/Common/LRUCache.h +++ b/dbms/src/Common/LRUCache.h @@ -322,13 +322,13 @@ class LRUCache { // If queue.insert() throws exception, cells and queue will be in inconsistent. cells.erase(res.first); - LOG_ERROR(&Poco::Logger::get("LRUCache"), "queue.insert throw std::exception: " << e.what()); + LOG_FMT_ERROR(&Poco::Logger::get("LRUCache"), "queue.insert throw std::exception: {}", e.what()); throw; } catch (...) { cells.erase(res.first); - LOG_ERROR(&Poco::Logger::get("LRUCache"), "queue.insert throw unknow exception"); + LOG_FMT_ERROR(&Poco::Logger::get("LRUCache"), "queue.insert throw unknown exception"); throw; } } @@ -363,7 +363,7 @@ class LRUCache auto it = cells.find(key); if (it == cells.end()) { - LOG_ERROR(&Poco::Logger::get("LRUCache"), "LRUCache became inconsistent. There must be a bug in it."); + LOG_FMT_ERROR(&Poco::Logger::get("LRUCache"), "LRUCache became inconsistent. There must be a bug in it."); abort(); } @@ -383,7 +383,7 @@ class LRUCache if (current_size > (1ull << 63)) { - LOG_ERROR(&Poco::Logger::get("LRUCache"), "LRUCache became inconsistent. There must be a bug in it."); + LOG_FMT_ERROR(&Poco::Logger::get("LRUCache"), "LRUCache became inconsistent. There must be a bug in it."); abort(); } } diff --git a/dbms/src/Common/PoolWithFailoverBase.h b/dbms/src/Common/PoolWithFailoverBase.h index e874d095cbd..7fcdf7f65e9 100644 --- a/dbms/src/Common/PoolWithFailoverBase.h +++ b/dbms/src/Common/PoolWithFailoverBase.h @@ -253,7 +253,7 @@ PoolWithFailoverBase::getMany( } else { - LOG_WARNING(log, "Connection failed at try №" << (shuffled_pool.error_count + 1) << ", reason: " << fail_message); + LOG_FMT_WARNING(log, "Connection failed at try No.{}, reason: {}", shuffled_pool.error_count + 1, fail_message); ProfileEvents::increment(ProfileEvents::DistributedConnectionFailTry); ++shuffled_pool.error_count; diff --git a/dbms/src/Common/tests/bench_unified_log_formatter.cpp b/dbms/src/Common/tests/bench_unified_log_formatter.cpp index 8f81ea17e63..004750444d2 100644 --- a/dbms/src/Common/tests/bench_unified_log_formatter.cpp +++ b/dbms/src/Common/tests/bench_unified_log_formatter.cpp @@ -219,4 +219,4 @@ BENCHMARK_REGISTER_F(UnifiedLogBM, LoogFmt)->Iterations(200); } // namespace bench -} // namespace DB +} // namespace DB \ No newline at end of file diff --git a/dbms/src/Databases/test/gtest_database.cpp b/dbms/src/Databases/test/gtest_database.cpp index 365c36639d3..149420f09e5 100644 --- a/dbms/src/Databases/test/gtest_database.cpp +++ b/dbms/src/Databases/test/gtest_database.cpp @@ -800,7 +800,7 @@ String readFile(Context & ctx, const String & file) DatabasePtr detachThenAttach(Context & ctx, const String & db_name, DatabasePtr && db, Poco::Logger * log) { auto meta = readFile(ctx, getDatabaseMetadataPath(db->getMetadataPath())); - LOG_DEBUG(log, "After tombstone [meta=" << meta << "]"); + LOG_FMT_DEBUG(log, "After tombstone [meta={}]", meta); { // Detach and load again auto detach_query = std::make_shared(); @@ -864,7 +864,7 @@ try auto db = ctx.getDatabase(db_name); auto meta = readFile(ctx, getDatabaseMetadataPath(db->getMetadataPath())); - LOG_DEBUG(log, "After create [meta=" << meta << "]"); + LOG_FMT_DEBUG(log, "After create [meta={}]", meta); DB::Timestamp tso = 1000; db->alterTombstone(ctx, tso);