Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve log in dbms/src/client, dbms/src/common, and dbms/src/databases #4374

Merged
merged 19 commits into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
57fe294
replace LOG_XXX with LOG_FMT_XXX in dbms/src/Client
Lloyd-Pottiger Mar 22, 2022
ed4ff9d
replace LOG_XXX with LOG_FMT_XXX in dbms/src/Common
Lloyd-Pottiger Mar 22, 2022
8791b56
replace LOG_XXX with LOG_FMT_XXX in dbms/src/Databases
Lloyd-Pottiger Mar 22, 2022
df390c7
Merge branch 'pingcap:master' into improve-client-common-databases-log
Lloyd-Pottiger Mar 22, 2022
326ac8a
fix some errors
Lloyd-Pottiger Mar 22, 2022
d489030
Merge branch 'improve-client-common-databases-log' of github.com:Lloy…
Lloyd-Pottiger Mar 22, 2022
ac239ee
format files
Lloyd-Pottiger Mar 22, 2022
7d84cc1
format dbms/src/Client/Connection.cpp
Lloyd-Pottiger Mar 22, 2022
e5868d1
Update dbms/src/Common/PoolWithFailoverBase.h
Lloyd-Pottiger Mar 22, 2022
1125dab
Merge branch 'pingcap:master' into improve-client-common-databases-log
Lloyd-Pottiger Mar 22, 2022
d841be5
Merge branch 'improve-client-common-databases-log' of github.com:Lloy…
Lloyd-Pottiger Mar 22, 2022
7a5c564
recover dbms/src/Common/tests/bench_unified_log_formatter.cpp
Lloyd-Pottiger Mar 22, 2022
eb3514c
Update dbms/src/Common/Config/ConfigReloader.cpp
Lloyd-Pottiger Mar 23, 2022
baddaf8
Update dbms/src/Common/LRUCache.h
Lloyd-Pottiger Mar 23, 2022
486b20b
Merge branch 'master' into improve-client-common-databases-log
Lloyd-Pottiger Mar 23, 2022
0f55a10
Merge branch 'master' into improve-client-common-databases-log
Lloyd-Pottiger Mar 23, 2022
d7541cb
Merge branch 'master' into improve-client-common-databases-log
ti-chi-bot Mar 23, 2022
e1646bd
Merge branch 'master' into improve-client-common-databases-log
ti-chi-bot Mar 23, 2022
1140695
Merge branch 'master' into improve-client-common-databases-log
ti-chi-bot Mar 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions dbms/src/Client/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>(secure) ? ". Secure" : "") << (static_cast<bool>(compression) ? "" : ". Uncompressed"));

LOG_FMT_TRACE(log_wrapper.get(), "Connecting. Database: {}. User: {}. {}, {}", (default_database.empty() ? "(not specified)" : default_database), user, (static_cast<bool>(secure) ? ". Secure" : ""), (static_cast<bool>(compression) ? "" : ". Uncompressed"));
if (static_cast<bool>(secure))
{
#if Poco_NetSSL_FOUND
Expand All @@ -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)
{
Expand Down Expand Up @@ -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();
}
}
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Common/AIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class AIOContextPool : public ext::Singleton<AIOContextPool>
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;
}

Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Common/Config/ConfigReloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions dbms/src/Common/FileChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
8 changes: 4 additions & 4 deletions dbms/src/Common/LRUCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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();
}

Expand All @@ -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();
}
}
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Common/PoolWithFailoverBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ PoolWithFailoverBase<TNestedPool>::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;
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Common/tests/bench_unified_log_formatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,4 @@ BENCHMARK_REGISTER_F(UnifiedLogBM, LoogFmt)->Iterations(200);

} // namespace bench

} // namespace DB
} // namespace DB
4 changes: 2 additions & 2 deletions dbms/src/Databases/test/gtest_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ASTDropQuery>();
Expand Down Expand Up @@ -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);
Expand Down