diff --git a/inst/include/bvharforecaster.h b/inst/include/bvharforecaster.h index 42f87b1f..b322fcda 100644 --- a/inst/include/bvharforecaster.h +++ b/inst/include/bvharforecaster.h @@ -599,7 +599,7 @@ class McmcOutforecastRun { std::string log_name = fmt::format("Chain {} / Window {}", chain + 1, window + 1); auto logger = SPDLOG_SINK_MT(log_name); logger->set_pattern("[%n] [Thread " + std::to_string(omp_get_thread_num()) + "] %v"); - int logging_freq = num_iter / 10; // 10 percent + int logging_freq = num_iter / 20; // 5 percent if (logging_freq == 0) { logging_freq = 1; } @@ -610,6 +610,7 @@ class McmcOutforecastRun { logger->info("{} / {} (Warmup)", i + 1, num_iter); } } + logger->flush(); for (int i = num_burn; i < num_iter; ++i) { if (bvharinterrupt::is_interrupted()) { RecordType reg_record = model[window][chain]->template returnStructRecords(0, thin, sparse); @@ -624,6 +625,7 @@ class McmcOutforecastRun { RecordType reg_record = model[window][chain]->template returnStructRecords(0, thin, sparse); updateForecaster(reg_record, window, chain); model[window][chain].reset(); + logger->flush(); spdlog::drop(log_name); } void forecastWindow(int window, int chain) { diff --git a/inst/include/bvharmcmc.h b/inst/include/bvharmcmc.h index b7c3780c..1faff3af 100644 --- a/inst/include/bvharmcmc.h +++ b/inst/include/bvharmcmc.h @@ -1067,7 +1067,7 @@ class McmcRun : public McmcInterface { std::string log_name = fmt::format("Chain {}", chain + 1); auto logger = SPDLOG_SINK_MT(log_name); logger->set_pattern("[%n] [Thread " + std::to_string(omp_get_thread_num()) + "] %v"); - int logging_freq = num_iter / 10; // 10 percent + int logging_freq = num_iter / 20; // 5 percent if (logging_freq == 0) { logging_freq = 1; } @@ -1078,6 +1078,7 @@ class McmcRun : public McmcInterface { logger->info("{} / {} (Warmup)", i + 1, num_iter); } } + logger->flush(); for (int i = num_burn; i < num_iter; ++i) { if (bvharinterrupt::is_interrupted()) { logger->warn("User interrupt in {} / {}", i + 1, num_iter); @@ -1100,6 +1101,7 @@ class McmcRun : public McmcInterface { { res[chain] = mcmc_ptr[chain]->returnRecords(0, thin); } + logger->flush(); spdlog::drop(log_name); }