diff --git a/env/env.cc b/env/env.cc index 187bf688b..829fcefb1 100644 --- a/env/env.cc +++ b/env/env.cc @@ -208,6 +208,14 @@ void Logger::Logv(const InfoLogLevel log_level, const char* format, va_list ap) kInfoLogLevelNames[log_level], format); Logv(new_format, ap); } + + if (log_level >= InfoLogLevel::WARN_LEVEL && + log_level != InfoLogLevel::HEADER_LEVEL) { + // Log messages with severity of warning or higher should be rare and are + // sometimes followed by an unclean crash. We want to be sure important + // messages are not lost in an application buffer when that happens. + Flush(); + } } static void Logv(const InfoLogLevel log_level, Logger *info_log, const char *format, va_list ap) {