Output log tag before stack trace.

This commit is contained in:
levlam 2022-11-12 11:15:33 +03:00
parent 84ceee07bf
commit c833612414

View File

@ -67,6 +67,7 @@ static void quit_signal_handler(int sig) {
static td::MemoryLog<1 << 20> memory_log; static td::MemoryLog<1 << 20> memory_log;
void print_log() { void print_log() {
td::LogGuard log_guard;
auto buf = memory_log.get_buffer(); auto buf = memory_log.get_buffer();
auto pos = memory_log.get_pos(); auto pos = memory_log.get_pos();
size_t tail_length = buf.size() - pos; size_t tail_length = buf.size() - pos;
@ -89,15 +90,23 @@ static void dump_stacktrace_signal_handler(int sig) {
if (has_failed) { if (has_failed) {
return; return;
} }
td::LogGuard log_guard;
if (LOG_TAG != nullptr && *LOG_TAG) {
td::signal_safe_write(td::Slice(LOG_TAG));
td::signal_safe_write(td::Slice("\n"), false);
}
td::Stacktrace::print_to_stderr(); td::Stacktrace::print_to_stderr();
} }
static void fail_signal_handler(int sig) { static void fail_signal_handler(int sig) {
has_failed = true; has_failed = true;
td::signal_safe_write_signal_number(sig); {
td::Stacktrace::PrintOptions options; td::LogGuard log_guard;
options.use_gdb = true; td::signal_safe_write_signal_number(sig);
td::Stacktrace::print_to_stderr(options); td::Stacktrace::PrintOptions options;
options.use_gdb = true;
td::Stacktrace::print_to_stderr(options);
}
print_log(); print_log();
_Exit(EXIT_FAILURE); _Exit(EXIT_FAILURE);
} }