Browse Source

Fixed report handler behavior when having SC_STOP action so that spdlog handler gets flushed

Eyck Jentzsch 1 month ago
parent
commit
469bf27911
1 changed files with 6 additions and 1 deletions
  1. 6
    1
      src/report.cpp

+ 6
- 1
src/report.cpp View File

@@ -190,7 +190,12 @@ inline void log2logger(spdlog::logger& logger, logging::log_level lvl, const str
190 190
 void report_handler(const sc_report &rep, const sc_actions &actions) {
191 191
     if (actions & SC_DISPLAY) log2logger(*log_cfg.console_logger, rep);
192 192
     if ((actions & SC_LOG) && log_cfg.file_logger) log2logger(*log_cfg.file_logger, rep);
193
-    if (actions & SC_STOP) if(sc_is_running()) sc_stop();
193
+    if (actions & SC_STOP) {
194
+      if(sc_is_running()) sc_stop();
195
+      log_cfg.console_logger->flush();
196
+      if(log_cfg.file_logger) log_cfg.file_logger->flush();
197
+      this_thread::sleep_for(chrono::milliseconds(10));
198
+    }
194 199
     if (actions & SC_ABORT) {
195 200
       log_cfg.console_logger->flush();
196 201
       if(log_cfg.file_logger) log_cfg.file_logger->flush();