Skip to content

Commit

Permalink
Fix outputDebugString level 4 not being logged (#3553)
Browse files Browse the repository at this point in the history
  • Loading branch information
MegadreamsBE authored Jul 15, 2024
1 parent a68c2c4 commit 1951a5e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 40 deletions.
4 changes: 3 additions & 1 deletion Client/mods/deathmatch/logic/CScriptDebugging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ void CScriptDebugging::UpdateLogOutput()
while (m_DuplicateLineFilter.PopOutputLine(line))
{
// Log it to the file if enough level
if (m_uiLogFileLevel >= line.uiMinimumDebugLevel)
bool sufficientDebugLevel = CheckForSufficientDebugLevel(m_uiLogFileLevel, line.uiMinimumDebugLevel);

if (sufficientDebugLevel)
{
PrintLog(line.strText);
}
Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/CScriptDebugging.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class CScriptDebugging
SString ComposeErrorMessage(const char* szPrePend, const SLuaDebugInfo& luaDebugInfo, const char* szMessage);
void LogString(const char* szPrePend, const SLuaDebugInfo& luaDebugInfo, const char* szMessage, unsigned int uiMinimumDebugLevel, unsigned char ucRed = 255,
unsigned char ucGreen = 255, unsigned char ucBlue = 255);
bool CheckForSufficientDebugLevel(std::uint8_t playerDebugLevel, std::uint8_t messageDebugLevel) const noexcept;
void PrintLog(const char* szText);

public:
Expand Down
39 changes: 0 additions & 39 deletions Server/mods/deathmatch/logic/CScriptDebugging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,6 @@

extern CGame* g_pGame;

enum DebugScriptLevels : std::uint8_t
{
NONE,
ERRORS_ONLY,
ERRORS_AND_WARNINGS,
ALL,
};

enum DebugMessageLevels : std::uint8_t
{
MESSAGE_TYPE_DEBUG,
MESSAGE_TYPE_ERROR,
MESSAGE_TYPE_WARNING,
MESSAGE_TYPE_INFO,
MESSAGE_TYPE_CUSTOM,
};

CScriptDebugging::CScriptDebugging()
{
m_uiLogFileLevel = 0;
Expand Down Expand Up @@ -160,28 +143,6 @@ void CScriptDebugging::PrintLog(const char* szText)
}
}

bool CScriptDebugging::CheckForSufficientDebugLevel(std::uint8_t playerDebugLevel, std::uint8_t messageDebugLevel) const noexcept
{
bool sufficientDebugLevel = false;

switch (messageDebugLevel)
{
case MESSAGE_TYPE_ERROR:
sufficientDebugLevel = (playerDebugLevel >= ERRORS_ONLY);
break;
case MESSAGE_TYPE_WARNING:
sufficientDebugLevel = (playerDebugLevel >= ERRORS_AND_WARNINGS);
break;
case MESSAGE_TYPE_INFO:
case MESSAGE_TYPE_CUSTOM:
case MESSAGE_TYPE_DEBUG:
sufficientDebugLevel = (playerDebugLevel == ALL);
break;
}

return sufficientDebugLevel;
}

void CScriptDebugging::Broadcast(const CPacket& Packet, unsigned int uiMinimumDebugLevel)
{
// Tell everyone we log to about it
Expand Down
39 changes: 39 additions & 0 deletions Shared/mods/deathmatch/logic/CScriptDebugging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@

#define MAX_STRING_LENGTH 2048

enum DebugScriptLevels : std::uint8_t
{
NONE,
ERRORS_ONLY,
ERRORS_AND_WARNINGS,
ALL,
};

enum DebugMessageLevels : std::uint8_t
{
MESSAGE_TYPE_DEBUG,
MESSAGE_TYPE_ERROR,
MESSAGE_TYPE_WARNING,
MESSAGE_TYPE_INFO,
MESSAGE_TYPE_CUSTOM,
};

// Handle filename/line number in string
void CScriptDebugging::LogPCallError(lua_State* luaVM, const SString& strRes, bool bInitialCall)
{
Expand Down Expand Up @@ -51,6 +68,28 @@ void CScriptDebugging::LogPCallError(lua_State* luaVM, const SString& strRes, bo
}
}

bool CScriptDebugging::CheckForSufficientDebugLevel(std::uint8_t playerDebugLevel, std::uint8_t messageDebugLevel) const noexcept
{
bool sufficientDebugLevel = false;

switch (messageDebugLevel)
{
case MESSAGE_TYPE_ERROR:
sufficientDebugLevel = (playerDebugLevel >= ERRORS_ONLY);
break;
case MESSAGE_TYPE_WARNING:
sufficientDebugLevel = (playerDebugLevel >= ERRORS_AND_WARNINGS);
break;
case MESSAGE_TYPE_INFO:
case MESSAGE_TYPE_CUSTOM:
case MESSAGE_TYPE_DEBUG:
sufficientDebugLevel = (playerDebugLevel == ALL);
break;
}

return sufficientDebugLevel;
}

void CScriptDebugging::LogCustom(lua_State* luaVM, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue, const char* szFormat, ...)
{
assert(szFormat);
Expand Down

0 comments on commit 1951a5e

Please sign in to comment.