#ifndef  OpenTestSystem_OtxDiagManager_Common_DiagnosticLogger_H
#define OpenTestSystem_OtxDiagManager_Common_DiagnosticLogger_H

#include <string>
#include <memory>
#include <mutex>
#include <map>
#include "CommonDefs.h"
#include "TypeDefs.h"

#define LOGDIRECTION_RECIEVED "Rx"
#define LOGDIRECTION_SENT "Tx"
#define LOGDIRECTION_NONE ""
namespace spdlog
{
	class logger;
}

namespace OpenTestSystem { namespace  OtxDiagManager { namespace Common {
	enum DiagnosticLogLevels
	{
		off = 0,
		header = 1,
		pdu = 2,
		shortnames = 3,
		all = 4
	};

	class COMMON_EXPORTS DiagnosticLogger
	{
	public:
		DiagnosticLogger();
		virtual ~DiagnosticLogger();		
		void WritePdu(uint16 clientId, const std::string& clientName, const std::string& direction, const std::string pdu);
		void WriteShortName(uint16 clientId, const std::string& clientName, const std::string& direction, const std::string shortName);
		void WriteAll(uint16 clientId, const std::string& clientName, const std::string& direction, const std::string description);
		void SetupLogConfig(const std::string &path, const std::string &fileName, const std::string &testObjectName, std::map<std::string, std::string> headerMap,  DiagnosticLogLevels logLevel, bool isAsync);
		void Close();
		void SetLogLevel(DiagnosticLogLevels logLevel);
		DiagnosticLogLevels GetLogLevel();
		static std::shared_ptr<DiagnosticLogger> Get();
	private:
		void Log(DiagnosticLogLevels level, uint16 clientId, const std::string& clientName, const std::string& direction, const std::string description);
		void ShowHeader();
		void SetupLogger();
		void ReplaceAll(std::string& str, const std::string& from, const std::string& to);
		std::string CorrectPathDelimiter(const std::string& path);
		std::string _path;
		std::string _fileName;
		std::string _testObjectName;
		std::map<std::string, std::string> _headerMap;
		bool _isAsync;
		std::shared_ptr<spdlog::logger> _spdLogger;
		DiagnosticLogLevels _logLevel;
	};
}}}

#endif // OpenTestSystem_OtxDiagManager_Common_DiagnosticLogger_H