standardise to SGDebugLog

main
Yik Teng Hie 8 months ago
parent 32bd117a01
commit 269852fa52

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -1,7 +1,7 @@
#pragma once
// STL
#include <map>
#include <unordered_map>
#include <string>
#include <memory>
#include <variant>
@ -11,7 +11,6 @@
// project
#include "ISGManager.h"
#include "BufferedSocket.h"
#include "SGLogger.h"
#define MAXSOCKBUF 4096
@ -186,6 +185,8 @@ protected:
virtual void NotifyHandler(WPARAM wParam, LPARAM lParam);
private:
void InitCommandMap();
/************************** private methods *************************/
bool static SkipToNextData(char** ppStr);
std::string GetNextData(char** ppStr);
@ -205,7 +206,7 @@ private:
"SCHEDULE"
};
const std::map<std::string, int> m_vecMainModes{
const std::unordered_map<std::string, int> m_vecMainModes{
{ "NOMATERIAL", NOMATERIAL_MODE },
{ "PRODUCTION", PRODUCTION_MODE },
{ "ENGINEERING", ENGINEERING_MODE },
@ -220,6 +221,9 @@ private:
"SUPER USER"
};
using CommandHandler = std::function<void(char*&)>;
std::unordered_map<std::string, CommandHandler> m_commandMap;
/************************** private fields **************************/
int m_nSGPort{ 2000 };
std::string m_strSGIpAddress;
@ -245,7 +249,6 @@ private:
std::string m_sGeneralCmdReceived;
std::string m_sSecsGemDataFile;
CSGLogger m_logger;
std::unique_ptr<CBufferedSocket> m_pSocketSecsGem;
};

@ -80,6 +80,24 @@ void GUIEventLog(fmt::format_string<Args...> _fmt, Args&&... args)
CLoggerManagerSingleton::Instance().LoggerManager().GetLogger(eLOGGER::GUI_EVENT_LOG).Log(_fmt, args...);
}
template <typename... Args>
void SGDebugLog(fmt::format_string<Args...> _fmt, Args&&... args)
{
CLoggerManagerSingleton::Instance().LoggerManager().GetLogger(eLOGGER::SG_DEBUG_LOG).Log(_fmt, args...);
}
template <typename... Args>
void SGDebugLogError(fmt::format_string<Args...> _fmt, Args&&... args)
{
CLoggerManagerSingleton::Instance().LoggerManager().GetLogger(eLOGGER::SG_DEBUG_LOG).Error(_fmt, args...);
}
template <typename... Args>
void SGDebugLogInfo(fmt::format_string<Args...> _fmt, Args&&... args)
{
CLoggerManagerSingleton::Instance().LoggerManager().GetLogger(eLOGGER::SG_DEBUG_LOG).Info(_fmt, args...);
}
std::shared_ptr<spdlog::logger> UTILITYDLL GetLogger(const std::string& strName);
// on demand flush to file
@ -89,6 +107,7 @@ void UTILITYDLL FlushDebugLogTiming();
void UTILITYDLL FlushGuiEventLog();
void UTILITYDLL FlushSGDebugLog();
//
void UTILITYDLL ShutdownLogging();
@ -104,3 +123,6 @@ bool UTILITYDLL IsDebugLogTimingStarted();
// All GUI Activities Events Log
void UTILITYDLL StartGUIEventLog();
void UTILITYDLL StopGUIEventLog();
void UTILITYDLL StartSGDebugLog();
void UTILITYDLL StopSGDebugLog();

@ -15,6 +15,7 @@ namespace mitech::utils::logging
DEBUG_LOG,
DEBUG_TIMING_LOG,
GUI_EVENT_LOG,
SG_DEBUG_LOG,
MAX_LOGGER
};
@ -33,7 +34,8 @@ namespace mitech::utils::logging
const std::map<eLOGGER, std::string> m_mapLoggerSettingFile{
{ eLOGGER::DEBUG_LOG, R"(d:\machine\config\debugLogSetting.json)" },
{ eLOGGER::DEBUG_TIMING_LOG, R"(d:\machine\config\debugLogTimingSetting.json)" },
{ eLOGGER::GUI_EVENT_LOG, R"(d:\machine\config\guiEventLogSetting.json)" }
{ eLOGGER::GUI_EVENT_LOG, R"(d:\machine\config\guiEventLogSetting.json)" },
{ eLOGGER::SG_DEBUG_LOG, R"(d:\machine\config\SGDebugLogSetting.json)" }
};
const std::string m_LoggerGlobalSettingFile{ R"(d:\machine\config\GlobalLogSetting.json)" };

@ -0,0 +1,33 @@
#pragma once
#include <memory>
#include <string>
#include "spdlog/spdlog.h"
#include "Logger.h"
#include "LogSettings.h"
namespace mitech::utils::logging
{
class CMitechSGDebugLog : public CLogger
{
public:
explicit CMitechSGDebugLog(const std::string& strName, const stLogOption& mySetting);
~CMitechSGDebugLog() final;
private:
void InitLogger(const stLogOption& mySetting);
// Inherited via CLogger
void DoStart() override;
void DoFlush() override;
void DoLogging(const std::string& strMsg) override;
void DoTrace(const std::string& strMsg) override;
void DoInfo(const std::string& strMsg) override;
void DoError(const std::string& strMsg) override;
std::shared_ptr<spdlog::logger> m_logger;
std::string m_strPathFilename{ R"(d:\machine\log\SGDebugLog.log)" };
};
}

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save