Skip to content

Commit

Permalink
remove some redundant log macro (#6095)
Browse files Browse the repository at this point in the history
close #5531
  • Loading branch information
Lloyd-Pottiger authored Oct 10, 2022
1 parent 72d0678 commit 187a46c
Show file tree
Hide file tree
Showing 157 changed files with 1,127 additions and 1,357 deletions.
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_FMT_ERROR(&Poco::Logger::get("AIOcontextPool"), "Found io_event with unknown id {}", id);
LOG_ERROR(Logger::get("AIOcontextPool"), "Found io_event with unknown id {}", id);
continue;
}

Expand Down
22 changes: 11 additions & 11 deletions dbms/src/Common/CPUAffinityManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void CPUAffinityManager::bindSelfQueryThread() const
{
if (enable())
{
LOG_FMT_INFO(log, "Thread: {} bindQueryThread.", ::getThreadName());
LOG_INFO(log, "Thread: {} bindQueryThread.", ::getThreadName());
// If tid is zero, then the calling thread is used.
bindQueryThread(0);
}
Expand All @@ -134,7 +134,7 @@ void CPUAffinityManager::bindSelfOtherThread() const
{
if (enable())
{
LOG_FMT_INFO(log, "Thread: {} bindOtherThread.", ::getThreadName());
LOG_INFO(log, "Thread: {} bindOtherThread.", ::getThreadName());
// If tid is zero, then the calling thread is used.
bindOtherThread(0);
}
Expand Down Expand Up @@ -197,7 +197,7 @@ void CPUAffinityManager::setAffinity(pid_t tid, const cpu_set_t & cpu_set) const
int ret = sched_setaffinity(tid, sizeof(cpu_set), &cpu_set);
if (ret != 0)
{
LOG_FMT_ERROR(log, "sched_setaffinity fail but ignore error: {}", std::strerror(errno));
LOG_ERROR(log, "sched_setaffinity fail but ignore error: {}", std::strerror(errno));
}
}

Expand Down Expand Up @@ -257,7 +257,7 @@ std::vector<pid_t> CPUAffinityManager::getThreadIDs(const std::string & dir) con
}
catch (std::exception & e)
{
LOG_FMT_ERROR(log, "dir {} path {} exception {}", dir, iter->path(), e.what());
LOG_ERROR(log, "dir {} path {} exception {}", dir, iter->path(), e.what());
}
}
return tids;
Expand All @@ -279,7 +279,7 @@ std::unordered_map<pid_t, std::string> CPUAffinityManager::getThreads(pid_t pid)
{
std::string task_dir = "/proc/" + std::to_string(pid) + "/task";
auto tids = getThreadIDs(task_dir);
LOG_FMT_DEBUG(log, "{} thread count {}", task_dir, tids.size());
LOG_DEBUG(log, "{} thread count {}", task_dir, tids.size());
std::unordered_map<pid_t, std::string> threads;
for (auto tid : tids)
{
Expand All @@ -300,12 +300,12 @@ void CPUAffinityManager::bindThreadCPUAffinity() const
{
if (isQueryThread(t.second))
{
LOG_FMT_INFO(log, "Thread: {} {} bindQueryThread.", t.first, t.second);
LOG_INFO(log, "Thread: {} {} bindQueryThread.", t.first, t.second);
bindQueryThread(t.first);
}
else
{
LOG_FMT_INFO(log, "Thread: {} {} bindOtherThread.", t.first, t.second);
LOG_INFO(log, "Thread: {} {} bindOtherThread.", t.first, t.second);
bindOtherThread(t.first);
}
}
Expand All @@ -323,17 +323,17 @@ void CPUAffinityManager::checkThreadCPUAffinity() const
int ret = sched_getaffinity(t.first, sizeof(cpu_set), &cpu_set);
if (ret != 0)
{
LOG_FMT_ERROR(log, "Thread: {} {} sched_getaffinity ret {} error {}", t.first, t.second, ret, strerror(errno));
LOG_ERROR(log, "Thread: {} {} sched_getaffinity ret {} error {}", t.first, t.second, ret, strerror(errno));
continue;
}
LOG_FMT_INFO(log, "Thread: {} {} bind on CPU: {}", t.first, t.second, cpuSetToString(cpu_set));
LOG_INFO(log, "Thread: {} {} bind on CPU: {}", t.first, t.second, cpuSetToString(cpu_set));
if (isQueryThread(t.second) && !CPU_EQUAL(&cpu_set, &query_cpu_set))
{
LOG_FMT_ERROR(log, "Thread: {} {} is query thread and bind CPU info is error.", t.first, t.second);
LOG_ERROR(log, "Thread: {} {} is query thread and bind CPU info is error.", t.first, t.second);
}
else if (!isQueryThread(t.second) && !CPU_EQUAL(&cpu_set, &other_cpu_set))
{
LOG_FMT_ERROR(log, "Thread: {} {} is other thread and bind CPU info is error.", t.first, t.second);
LOG_ERROR(log, "Thread: {} {} is other thread and bind CPU info is error.", t.first, t.second);
}
}
}
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_FMT_DEBUG(log, "Loading config `{}`", path);
LOG_DEBUG(log, "Loading config `{}`", path);

loaded_config = config_processor.loadConfig();
}
Expand Down
14 changes: 7 additions & 7 deletions dbms/src/Common/Exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ void tryLogCurrentException(const char * log_name,
tryLogCurrentException(&Poco::Logger::get(log_name), start_of_message);
}

#define TRY_LOG_CURRENT_EXCEPTION(logger, start_of_message) \
try \
{ \
LOG_FMT_ERROR((logger), "{}{}{}", (start_of_message), ((start_of_message).empty() ? "" : ": "), getCurrentExceptionMessage(true)); \
} \
catch (...) \
{ \
#define TRY_LOG_CURRENT_EXCEPTION(logger, start_of_message) \
try \
{ \
LOG_ERROR((logger), "{}{}{}", (start_of_message), ((start_of_message).empty() ? "" : ": "), getCurrentExceptionMessage(true)); \
} \
catch (...) \
{ \
}

void tryLogCurrentException(const LoggerPtr & logger,
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Common/FailPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void FailPointHelper::initRandomFailPoints(Poco::Util::LayeredConfiguration & co
RUNTIME_ASSERT((0 <= rate && rate <= 1.0), log, "RandomFailPoint trigger rate should in [0,1], while {}", rate);
enableRandomFailPoint(pair_tokens[0], rate);
}
LOG_FMT_INFO(log, "Enable RandomFailPoints: {}", random_fail_point_cfg);
LOG_INFO(log, "Enable RandomFailPoints: {}", random_fail_point_cfg);
}

void FailPointHelper::enableRandomFailPoint(const String & fail_point_name, double rate)
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_FMT_ERROR(log, "File {} doesn't exist", file.path());
LOG_ERROR(log, "File {} doesn't exist", file.path());
return false;
}

size_t real_size = file.getSize();
if (real_size != name_size.second)
{
LOG_FMT_ERROR(log, "Size of {} is wrong. Size is {} but should be {}", file.path(), real_size, name_size.second);
LOG_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_FMT_ERROR(&Poco::Logger::get("LRUCache"), "queue.insert throw std::exception: {}", e.what());
LOG_ERROR(Logger::get("LRUCache"), "queue.insert throw std::exception: {}", e.what());
throw;
}
catch (...)
{
cells.erase(res.first);
LOG_FMT_ERROR(&Poco::Logger::get("LRUCache"), "queue.insert throw unknown exception");
LOG_ERROR(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_FMT_ERROR(&Poco::Logger::get("LRUCache"), "LRUCache became inconsistent. There must be a bug in it.");
LOG_ERROR(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_FMT_ERROR(&Poco::Logger::get("LRUCache"), "LRUCache became inconsistent. There must be a bug in it.");
LOG_ERROR(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/MemoryTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static Poco::Logger * getLogger()

void MemoryTracker::logPeakMemoryUsage() const
{
LOG_FMT_DEBUG(getLogger(), "Peak memory usage{}: {}.", (description ? " " + std::string(description) : ""), formatReadableSizeWithBinarySuffix(peak));
LOG_DEBUG(getLogger(), "Peak memory usage{}: {}.", (description ? " " + std::string(description) : ""), formatReadableSizeWithBinarySuffix(peak));
}

void MemoryTracker::alloc(Int64 size, bool check_memory_limit)
Expand Down
20 changes: 10 additions & 10 deletions dbms/src/Common/SyncPoint/Ctl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void SyncPointCtl::enable(const char * name)
std::make_shared<SyncChannel>()));
}
fiu_enable(name, 1, nullptr, 0);
LOG_FMT_DEBUG(getLogger(), "Enabled: {}", name);
LOG_DEBUG(getLogger(), "Enabled: {}", name);
}

void SyncPointCtl::disable(const char * name)
Expand All @@ -50,7 +50,7 @@ void SyncPointCtl::disable(const char * name)
channels.erase(iter);
}
}
LOG_FMT_DEBUG(getLogger(), "Disabled: {}", name);
LOG_DEBUG(getLogger(), "Disabled: {}", name);
}

std::pair<SyncPointCtl::SyncChannelPtr, SyncPointCtl::SyncChannelPtr> SyncPointCtl::mustGetChannel(const char * name)
Expand All @@ -69,31 +69,31 @@ std::pair<SyncPointCtl::SyncChannelPtr, SyncPointCtl::SyncChannelPtr> SyncPointC
void SyncPointCtl::waitAndPause(const char * name)
{
auto ch = mustGetChannel(name).first;
LOG_FMT_DEBUG(getLogger(), "waitAndPause({}) waiting...", name);
LOG_DEBUG(getLogger(), "waitAndPause({}) waiting...", name);
auto result = ch->recv();
LOG_FMT_DEBUG(getLogger(), "waitAndPause({}) {}", name, result ? "finished" : "cancelled");
LOG_DEBUG(getLogger(), "waitAndPause({}) {}", name, result ? "finished" : "cancelled");
}

void SyncPointCtl::next(const char * name)
{
auto ch = mustGetChannel(name).second;
LOG_FMT_DEBUG(getLogger(), "next({}) trying...", name);
LOG_DEBUG(getLogger(), "next({}) trying...", name);
auto result = ch->send();
LOG_FMT_DEBUG(getLogger(), "next({}) {}", name, result ? "done" : "cancelled");
LOG_DEBUG(getLogger(), "next({}) {}", name, result ? "done" : "cancelled");
}

void SyncPointCtl::sync(const char * name)
{
auto [ch_1, ch_2] = mustGetChannel(name);
// Print a stack, which is helpful to know where undesired SYNC_FOR comes from.
LOG_FMT_DEBUG(getLogger(), "SYNC_FOR({}) trying... \n\n# Current Stack: {}", name, StackTrace().toString());
LOG_DEBUG(getLogger(), "SYNC_FOR({}) trying... \n\n# Current Stack: {}", name, StackTrace().toString());
auto result = ch_1->send();
LOG_FMT_DEBUG(getLogger(), "SYNC_FOR({}) {}", name, //
result ? "matched waitAndPause(), paused until calling next()..." : "cancelled");
LOG_DEBUG(getLogger(), "SYNC_FOR({}) {}", name, //
result ? "matched waitAndPause(), paused until calling next()..." : "cancelled");
if (!result)
return;
result = ch_2->recv();
LOG_FMT_DEBUG(getLogger(), "SYNC_FOR({}) {}", name, result ? "done" : "cancelled");
LOG_DEBUG(getLogger(), "SYNC_FOR({}) {}", name, result ? "done" : "cancelled");
}

#else
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Common/TiFlashSecurity.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct TiFlashSecurityConfig
else
{
has_tls_config = true;
LOG_FMT_INFO(
LOG_INFO(
log,
"security config is set: ca path is {} cert path is {} key path is {}",
ca_path,
Expand Down
5 changes: 0 additions & 5 deletions dbms/src/Common/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,3 @@ target_link_libraries (mpmc_queue_perftest clickhouse_common_io)

add_executable (allocator_perf allocator_perf.cpp)
target_link_libraries (allocator_perf clickhouse_common_io)

add_executable(bench_common
bench_unified_log_formatter.cpp
)
target_link_libraries(bench_common benchmark::benchmark_main clickhouse_common_io)
Loading

0 comments on commit 187a46c

Please sign in to comment.