-
Notifications
You must be signed in to change notification settings - Fork 703
Get rid of unsafe logs. Fix NULL UUID case. #3102
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,5 @@ | ||
| #pragma once | ||
|
|
||
| #include <base/backtrace.hpp> | ||
| #include <base/memory_info.hpp> | ||
| #include <base/system_report.hpp> | ||
|
|
||
| #include <chrono> | ||
| #include <csignal> | ||
| #include <string> | ||
|
|
@@ -12,27 +8,8 @@ namespace pg { | |
|
|
||
| extern bool print_runtime_stats; | ||
|
|
||
| inline static void print_memory_report() | ||
| { | ||
| base::memory_info info; | ||
|
|
||
| base::system_report::get_meminfo(info); | ||
| const auto msg = fmt::format("Memory Report:\n" | ||
| "RSS: ({:.2f} MB)" | ||
| ", VM: ({:.2f} MB)" | ||
| ", Peak: ({:.2f} MB)", | ||
| info.process_vm_rss / (1024.0 * 1024.0), | ||
| info.process_vm_size / (1024.0 * 1024.0), | ||
| info.process_peak_mem / (1024.0 * 1024.0)); | ||
| elog(INFO, "%s", msg.c_str()); | ||
| } | ||
|
|
||
| inline static void signal_handler(int signal) | ||
| { | ||
| elog(NOTICE, "Caught signal %d (%s)\n", signal, strsignal(signal)); | ||
| elog(NOTICE, "%s", base::backtrace().c_str()); | ||
| print_memory_report(); | ||
| fflush(stderr); | ||
| _exit(signal); | ||
| } | ||
|
Comment on lines
11
to
14
|
||
|
|
||
|
|
@@ -61,22 +38,7 @@ struct runtime_printer | |
| } | ||
| } | ||
|
|
||
| ~runtime_printer() | ||
| { | ||
| if (pg::print_runtime_stats) { | ||
| auto end_time = std::chrono::high_resolution_clock::now(); | ||
| auto duration = std::chrono::duration<double, PERIOD>(end_time - start_time_).count(); | ||
| std::string period_name = "ms"; | ||
| if constexpr (std::is_same_v<PERIOD, std::micro>) { | ||
| period_name = "µs"; | ||
| } else if constexpr (std::is_same_v<PERIOD, std::nano>) { | ||
| period_name = "ns"; | ||
| } else if constexpr (std::is_same_v<PERIOD, std::ratio<1>>) { | ||
| period_name = "s"; | ||
| } | ||
| elog(INFO, "%s: %.2f %s", task_name_.data(), duration, period_name.data()); | ||
| } | ||
| } | ||
| ~runtime_printer() = default; | ||
|
||
|
|
||
| private: | ||
| std::string_view task_name_; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While silencing errors may prevent cascading failures, completely silent error handling makes debugging difficult. Consider using a safer logging mechanism (e.g., appending to a file) or add a comment explaining what specific cascading error this prevents and how to debug issues when cleanup fails.