Abort program execution if STOP_ON_WARNING is defined when formatting an invalid log entry.

master
faluco 3 years ago committed by faluco
parent 8cde3f20e7
commit 9571109a69

@ -32,6 +32,9 @@ void json_formatter::format(detail::log_entry_metadata&& metadata, fmt::memory_b
fmt::vprintf(buffer, fmt::to_string_view(metadata.fmtstring), args); fmt::vprintf(buffer, fmt::to_string_view(metadata.fmtstring), args);
} catch (...) { } catch (...) {
fmt::print(stderr, "srsLog error - Invalid format string: \"{}\"\n", metadata.fmtstring); fmt::print(stderr, "srsLog error - Invalid format string: \"{}\"\n", metadata.fmtstring);
#ifdef STOP_ON_WARNING
std::abort();
#endif
} }
fmt::format_to(buffer, fmt::to_string_view("\"")); fmt::format_to(buffer, fmt::to_string_view("\""));
} else { } else {
@ -66,6 +69,9 @@ void json_formatter::format_context_begin(const detail::log_entry_metadata& md,
fmt::vprintf(buffer, fmt::to_string_view(md.fmtstring), args); fmt::vprintf(buffer, fmt::to_string_view(md.fmtstring), args);
} catch (...) { } catch (...) {
fmt::print(stderr, "srsLog error - Invalid format string: \"{}\"\n", md.fmtstring); fmt::print(stderr, "srsLog error - Invalid format string: \"{}\"\n", md.fmtstring);
#ifdef STOP_ON_WARNING
std::abort();
#endif
} }
fmt::format_to(buffer, "\",\n"); fmt::format_to(buffer, "\",\n");
} else { } else {

@ -70,6 +70,9 @@ void text_formatter::format(detail::log_entry_metadata&& metadata, fmt::memory_b
fmt::vprintf(buffer, fmt::to_string_view(metadata.fmtstring), args); fmt::vprintf(buffer, fmt::to_string_view(metadata.fmtstring), args);
} catch (...) { } catch (...) {
fmt::print(stderr, "srsLog error - Invalid format string: \"{}\"\n", metadata.fmtstring); fmt::print(stderr, "srsLog error - Invalid format string: \"{}\"\n", metadata.fmtstring);
#ifdef STOP_ON_WARNING
std::abort();
#endif
} }
fmt::format_to(buffer, "\n"); fmt::format_to(buffer, "\n");
} else { } else {
@ -114,6 +117,9 @@ void text_formatter::format_context_end(const detail::log_entry_metadata& md,
fmt::vprintf(buffer, fmt::to_string_view(md.fmtstring), args); fmt::vprintf(buffer, fmt::to_string_view(md.fmtstring), args);
} catch (...) { } catch (...) {
fmt::print(stderr, "srsLog error - Invalid format string: \"{}\"\n", md.fmtstring); fmt::print(stderr, "srsLog error - Invalid format string: \"{}\"\n", md.fmtstring);
#ifdef STOP_ON_WARNING
std::abort();
#endif
} }
fmt::format_to(buffer, "\n"); fmt::format_to(buffer, "\n");
} else { } else {

Loading…
Cancel
Save