Program Listing for File JSONLogger.h
↰ Return to documentation for file (include/flamegpu/io/JSONLogger.h
)
#ifndef INCLUDE_FLAMEGPU_IO_JSONLOGGER_H_
#define INCLUDE_FLAMEGPU_IO_JSONLOGGER_H_
#include <string>
#include <typeindex>
#include <nlohmann/json.hpp>
#include "flamegpu/io/Logger.h"
#include "flamegpu/detail/Any.h"
namespace flamegpu {
struct RunLog;
struct StepLogFrame;
struct ExitLogFrame;
struct LogFrame;
class RunPlan;
namespace io {
class JSONLogger : public Logger{
public:
JSONLogger(const std::string &outPath, bool prettyPrint, bool truncateFile);
void log(const RunLog &log, const RunPlan &plan, bool logSteps = true, bool logExit = true, bool logStepTime = false, bool logExitTime = false) const override;
void log(const RunLog &log, bool logConfig = true, bool logSteps = true, bool logExit = true, bool logStepTime = false, bool logExitTime = false) const override;
private:
void logCommon(const RunLog &log, const RunPlan *plan, bool logConfig, bool logSteps, bool logExit, bool logStepTime, bool logExitTime) const;
void logCommon(nlohmann::ordered_json& j, const RunLog &log, const RunPlan *plan, bool logConfig, bool logSteps, bool logExit, bool logStepTime, bool logExitTime) const;
nlohmann::ordered_json logConfig(const RunLog &log) const;
nlohmann::ordered_json logConfig(const RunPlan &plan) const;
nlohmann::ordered_json logPerformanceSpecs(const RunLog& log) const;
void logSteps(nlohmann::ordered_json& j, const RunLog &log, bool logTime) const;
void logExit(nlohmann::ordered_json& j, const RunLog &log, bool logTime) const;
nlohmann::ordered_json writeLogFrame(const StepLogFrame&log, bool logTime) const;
nlohmann::ordered_json writeLogFrame(const ExitLogFrame& log, bool logTime) const;
void writeCommonLogFrame(nlohmann::ordered_json& j, const LogFrame& log) const;
void writeAny(nlohmann::ordered_json& j, const detail::Any &value, unsigned int elements = 1) const;
std::string out_path;
bool prettyPrint;
bool truncateFile;
};
} // namespace io
} // namespace flamegpu
#endif // INCLUDE_FLAMEGPU_IO_JSONLOGGER_H_