CommunicationLogger.cpp 777 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "stdafx.h"
  2. #include "CommunicationLogger.h"
  3. #include "LogFacade.h"
  4. using namespace DIOS::Dev::Detail::MachineryECOM;
  5. CommunicationLogger *CommunicationLogger::m_instance = nullptr;
  6. CommunicationLogger::CommunicationLogger() :m_logger(nullptr)
  7. {
  8. }
  9. CommunicationLogger::~CommunicationLogger()
  10. {
  11. if (m_logger)
  12. {
  13. LogFacade::Release(m_logger);
  14. }
  15. }
  16. CommunicationLogger *CommunicationLogger::Instance()
  17. {
  18. if (m_instance == nullptr)
  19. {
  20. m_instance = new CommunicationLogger();
  21. }
  22. return m_instance;
  23. }
  24. void CommunicationLogger::Initialize(const std::string &workpath)
  25. {
  26. SYSTEMTIME st;
  27. GetLocalTime(&st);
  28. char tmp[32] = { 0 };
  29. sprintf_s(tmp, "A_Communication");
  30. m_logger = LogFacade::CreateLogger(workpath, tmp);
  31. }