#pragma once

// C++ STL headers
#include <string>

#ifdef BUILD_COMMDLL
#define COMMDLL_DLLCLASS __declspec(dllexport)
#else
#define COMMDLL_DLLCLASS __declspec(dllimport)
#endif

class COMMDLL_DLLCLASS CommLog
{
public:
	CommLog(std::string strConfigIni, std::string strSection);
	virtual ~CommLog();

	inline bool isEnable() { return m_bEnable;  }

	void setBaseFolder(const std::string& strFolder);
	void setSubFolder(const std::string& strSubFolder);
	void setFilename(const std::string& strFilename);
	bool log(const std::string& strMsg, bool bSend);
	bool saveFile(const std::string& strFileName, const std::string& strContent);
	std::string readFile(const std::string& strFileName);

private:
	inline std::string getFilePath(std::string strFileName = "") {
		if (!m_strFilename.empty())
		{
			strFileName = m_strFilename;
		}
		//
		return m_strFolder + R"(\)" + m_strSubFolder + R"(\)" + strFileName;
	}

	std::string m_strConfigIni;
	std::string m_strSection;
	std::string m_strFolder;
	std::string m_strSubFolder;
	std::string m_strFilename{};

	bool m_bEnable;
};

