1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-01-31 09:57:14 +01:00

Respect logging time-stamp config.

This commit is contained in:
Sandu Liviu Catalin 2021-02-03 22:08:32 +02:00
parent 70a5eaa5d1
commit c8e5012642
2 changed files with 7 additions and 9 deletions

View File

@ -167,7 +167,7 @@ static inline void OutputConsoleMessage(const Logger::MsgPtr & msg)
CONSOLE_SCREEN_BUFFER_INFO csb_state; CONSOLE_SCREEN_BUFFER_INFO csb_state;
GetConsoleScreenBufferInfo(hstdout, &csb_state); GetConsoleScreenBufferInfo(hstdout, &csb_state);
SetConsoleTextAttribute(hstdout, GetLevelColor(msg->mLvl)); SetConsoleTextAttribute(hstdout, GetLevelColor(msg->mLvl));
if (msg->mTms) if (Logger::Get().ConsoleHasTime())
{ {
std::printf("%s %s ", GetLevelTag(msg->mLvl), msg->mBuf); std::printf("%s %s ", GetLevelTag(msg->mLvl), msg->mBuf);
} }
@ -179,7 +179,7 @@ static inline void OutputConsoleMessage(const Logger::MsgPtr & msg)
std::printf("%s\n", msg->mStr.c_str()); std::printf("%s\n", msg->mStr.c_str());
SetConsoleTextAttribute(hstdout, csb_state.wAttributes); SetConsoleTextAttribute(hstdout, csb_state.wAttributes);
#else #else
if (msg->mTms) if (Logger::Get().ConsoleHasTime())
{ {
std::printf("%s %s %s\033[0m\n", std::printf("%s %s %s\033[0m\n",
msg->mSub ? GetColoredLevelTagDim(msg->mLvl) : GetColoredLevelTag(msg->mLvl), msg->mBuf, msg->mStr.c_str()); msg->mSub ? GetColoredLevelTagDim(msg->mLvl) : GetColoredLevelTag(msg->mLvl), msg->mBuf, msg->mStr.c_str());
@ -532,8 +532,6 @@ void Logger::ProcessMessage()
return; return;
} }
} }
// Override time-stamp requirements
m_Message->mTms = (m_ConsoleTime || m_LogFileTime);
// Are we allowed to send this message level to console? // Are we allowed to send this message level to console?
if (m_ConsoleLevels & m_Message->mLvl) if (m_ConsoleLevels & m_Message->mLvl)
{ {
@ -546,7 +544,7 @@ void Logger::ProcessMessage()
std::fputs(GetLevelTag(m_Message->mLvl), m_File); std::fputs(GetLevelTag(m_Message->mLvl), m_File);
std::fputc(' ', m_File); std::fputc(' ', m_File);
// Should we include the time-stamp? // Should we include the time-stamp?
if (m_Message->mTms) if (m_LogFileTime)
{ {
std::fputs(m_Message->mBuf, m_File); std::fputs(m_Message->mBuf, m_File);
std::fputc(' ', m_File); std::fputc(' ', m_File);

View File

@ -52,7 +52,7 @@ protected:
uint8_t mLvl; // Message level. uint8_t mLvl; // Message level.
uint8_t mInc; // Message increments. uint8_t mInc; // Message increments.
bool mSub; // Message hierarchy. bool mSub; // Message hierarchy.
bool mTms; // Message hierarchy. bool mTms; // Message time-stamp.
char mBuf[TMS_LEN]; // Message time-stamp. char mBuf[TMS_LEN]; // Message time-stamp.
/* ---------------------------------------------------------------------------------------- /* ----------------------------------------------------------------------------------------
* Default constructor. * Default constructor.