Change important printfs to lg::print (#3355)

This allows them to be logged into a file, useful for debugging.

With this, GOAL `format` and C-kernel `Msg` (and its variants) will be
logged.
This commit is contained in:
ManDude
2024-02-01 18:01:41 +00:00
committed by GitHub
parent b331d16bcc
commit d67b441dac
21 changed files with 124 additions and 80 deletions
+23
View File
@@ -112,8 +112,31 @@ void log_print(const char* message) {
}
}
}
void log_vprintf(const char* format, va_list arg_list) {
{
// We always immediately flush prints because since it has no associated level
// it could be anything from a fatal error to a useless debug log.
std::lock_guard<std::mutex> lock(gLogger.mutex);
if (gLogger.fp) {
// Log to File
vfprintf(gLogger.fp, format, arg_list);
fflush(gLogger.fp);
}
if (gLogger.stdout_log_level < lg::level::off_unless_die) {
vprintf(format, arg_list);
fflush(stdout);
fflush(stderr);
}
}
}
} // namespace internal
void printstd(const std::string& format, va_list arg_list) {
internal::log_vprintf(format.c_str(), arg_list);
}
// how many extra log files for a single program should be kept?
constexpr int LOG_ROTATE_MAX = 10;