From 0d91eae1aa2fc05591f0814a143d8fef4d74c843 Mon Sep 17 00:00:00 2001 From: Saleel Kudchadker Date: Fri, 14 May 2021 10:31:22 -0700 Subject: [PATCH] SWDEV-286092 - Flush log file Flush log file for every log line, helps in cases where there is a softhang. Change-Id: I3e396678d82b57ec275c3a079fafd1d08f0706a3 [ROCm/clr commit: ce0f1c7c350198649cc452d2371dd3e54ae1af4f] --- projects/clr/rocclr/utils/debug.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/projects/clr/rocclr/utils/debug.cpp b/projects/clr/rocclr/utils/debug.cpp index e533b6ac69..21c329341f 100644 --- a/projects/clr/rocclr/utils/debug.cpp +++ b/projects/clr/rocclr/utils/debug.cpp @@ -67,6 +67,7 @@ void log_entry(LogLevel level, const char* file, int line, const char* message) return; } fprintf(outFile, ":%d:%s:%d: %s\n", level, file, line, message); + fflush(outFile); } // ================================================================================================ @@ -89,6 +90,7 @@ void log_timestamped(LogLevel level, const char* file, int line, const char* mes fprintf(outFile, ":% 2d:%15s:% 5d: (%010lld) us %s\n", level, file, line, time / 1000ULL, message); #endif + fflush(outFile); } // ================================================================================================ @@ -101,7 +103,7 @@ void log_printf(LogLevel level, const char* file, int line, const char* format, va_end(ap); uint64_t timeUs = Os::timeNanos() / 1000ULL; fprintf(outFile, ":%d:%-25s:%-4d: %010lld us: %s\n", level, file, line, timeUs/1ULL, message); - + fflush(outFile); } // ================================================================================================ @@ -120,6 +122,7 @@ void log_printf(LogLevel level, const char* file, int line, uint64_t* start, fprintf(outFile, ":%d:%-25s:%-4d: %010lld us: %s: duration: %lld us\n", level, file, line, timeUs/1ULL, message, (timeUs - *start)/1ULL); } + fflush(outFile); if (*start == 0) { *start = timeUs; }