diff --git a/include/flamegpu/sim/SimLogger.h b/include/flamegpu/sim/SimLogger.h index 3a0291687..17af45136 100644 --- a/include/flamegpu/sim/SimLogger.h +++ b/include/flamegpu/sim/SimLogger.h @@ -28,6 +28,8 @@ class SimLogger { * @param log_export_queue The queue of logs to exported to disk * @param log_export_queue_mutex This mutex must be locked to access log_export_queue * @param log_export_queue_cdn The condition is notified every time a log has been added to the queue + * @param _export_step If true step logs will be exported + * @param _export_exit If true exit logs will be exported */ SimLogger(const std::vector &run_logs, const RunPlanVector &run_plans, @@ -35,7 +37,9 @@ class SimLogger { const std::string &out_format, std::queue &log_export_queue, std::mutex &log_export_queue_mutex, - std::condition_variable &log_export_queue_cdn); + std::condition_variable &log_export_queue_cdn, + bool _export_step, + bool _export_exit); /** * The thread which the logger is executing on, created by the constructor */ @@ -73,6 +77,15 @@ class SimLogger { * The condition is notified every time a log has been added to the queue */ std::condition_variable &log_export_queue_cdn; + /** + * If true step log files will be exported + */ + + bool export_step; + /** + * If true exit log files will be exported + */ + bool export_exit; }; } // namespace flamegpu diff --git a/src/flamegpu/gpu/CUDAEnsemble.cu b/src/flamegpu/gpu/CUDAEnsemble.cu index e827060e5..012e39dd3 100644 --- a/src/flamegpu/gpu/CUDAEnsemble.cu +++ b/src/flamegpu/gpu/CUDAEnsemble.cu @@ -127,7 +127,7 @@ void CUDAEnsemble::simulate(const RunPlanVector &plans) { // Init log worker SimLogger *log_worker = nullptr; if (!config.out_directory.empty() && !config.out_format.empty()) { - log_worker = new SimLogger(run_logs, plans, config.out_directory, config.out_format, log_export_queue, log_export_queue_mutex, log_export_queue_cdn); + log_worker = new SimLogger(run_logs, plans, config.out_directory, config.out_format, log_export_queue, log_export_queue_mutex, log_export_queue_cdn, step_log_config.get(), exit_log_config.get()); } else if (!config.out_directory.empty() ^ !config.out_format.empty()) { fprintf(stderr, "Warning: Only 1 of out_directory and out_format is set, both must be set for logging to commence to file.\n"); } diff --git a/src/flamegpu/sim/SimLogger.cu b/src/flamegpu/sim/SimLogger.cu index e2fe6c54c..a4be32730 100644 --- a/src/flamegpu/sim/SimLogger.cu +++ b/src/flamegpu/sim/SimLogger.cu @@ -32,14 +32,18 @@ SimLogger::SimLogger(const std::vector &_run_logs, const std::string &_out_format, std::queue &_log_export_queue, std::mutex &_log_export_queue_mutex, - std::condition_variable &_log_export_queue_cdn) + std::condition_variable &_log_export_queue_cdn, + bool _export_step, + bool _export_exit) : run_logs(_run_logs) , run_plans(_run_plans) , out_directory(_out_directory) , out_format(_out_format) , log_export_queue(_log_export_queue) , log_export_queue_mutex(_log_export_queue_mutex) - , log_export_queue_cdn(_log_export_queue_cdn) { + , log_export_queue_cdn(_log_export_queue_cdn) + , export_step(_export_step) + , export_exit(_export_exit) { this->thread = std::thread(&SimLogger::start, this); // Attempt to name the thread #ifdef _MSC_VER @@ -78,13 +82,16 @@ void SimLogger::start() { break; } // Log items - const path exit_path = p_out_directory/path(run_plans[target_log].getOutputSubdirectory())/path("exit." + out_format); - const auto exit_logger = io::LoggerFactory::createLogger(exit_path.generic_string(), false, false); - exit_logger->log(run_logs[target_log], true, false, true); - const path step_path = p_out_directory/path(run_plans[target_log].getOutputSubdirectory())/path(std::to_string(target_log)+"."+out_format); - const auto step_logger = io::LoggerFactory::createLogger(step_path.generic_string(), false, false); - step_logger->log(run_logs[target_log], true, true, false); - + if (export_exit) { + const path exit_path = p_out_directory / path(run_plans[target_log].getOutputSubdirectory()) / path("exit." + out_format); + const auto exit_logger = io::LoggerFactory::createLogger(exit_path.generic_string(), false, false); + exit_logger->log(run_logs[target_log], true, false, true); + } + if (export_step) { + const path step_path = p_out_directory/path(run_plans[target_log].getOutputSubdirectory())/path(std::to_string(target_log)+"."+out_format); + const auto step_logger = io::LoggerFactory::createLogger(step_path.generic_string(), false, false); + step_logger->log(run_logs[target_log], true, true, false); + } // Continue ++logs_processed; lock.lock();