.. _program_listing_file_include_flamegpu_io_LoggerFactory.h: Program Listing for File LoggerFactory.h ======================================== |exhale_lsh| :ref:`Return to documentation for file ` (``include/flamegpu/io/LoggerFactory.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #ifndef INCLUDE_FLAMEGPU_IO_LOGGERFACTORY_H_ #define INCLUDE_FLAMEGPU_IO_LOGGERFACTORY_H_ #include #include #include #include #include #include #include "flamegpu/io/Logger.h" #include "flamegpu/io/JSONLogger.h" #include "flamegpu/io/XMLLogger.h" namespace flamegpu { namespace io { class LoggerFactory { public: static std::unique_ptr createLogger(const std::string &output_path, bool prettyPrint, bool truncateFile = true) { const std::string extension = std::filesystem::path(output_path).extension().string(); if (extension == ".xml") { return std::make_unique(output_path, prettyPrint, truncateFile); } else if (extension == ".json") { return std::make_unique(output_path, prettyPrint, truncateFile); } THROW exception::UnsupportedFileType("File '%s' is not a type which can be written " "by StateWriterFactory::createLogger().", output_path.c_str()); } }; } // namespace io } // namespace flamegpu #endif // INCLUDE_FLAMEGPU_IO_LOGGERFACTORY_H_