From 277e05b2b873232f9bc3ba0d74b656866ad3355a Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 25 Nov 2022 23:03:56 +0100 Subject: [PATCH] Improve logging throughout SDK Used proper enum for context. The low level tier1 stuff should print in COMMON. Also added newlines where missing, the logging system will undergo a change where a newline will only be appended if we are logging in the same context without a newline. --- r5dev/engine/net_chan.cpp | 4 ++-- r5dev/networksystem/bansystem.cpp | 6 +++--- r5dev/tier1/utlfixedmemory.h | 2 +- r5dev/tier1/utllinkedlist.h | 4 ++-- r5dev/tier1/utlrbtree.h | 2 +- r5dev/vstdlib/callback.cpp | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/r5dev/engine/net_chan.cpp b/r5dev/engine/net_chan.cpp index 5d284ca7..a498aa32 100644 --- a/r5dev/engine/net_chan.cpp +++ b/r5dev/engine/net_chan.cpp @@ -39,7 +39,7 @@ const char* CNetChan::GetAddress(void) const if (!inet_ntop(AF_INET6, &this->remote_address.adr, s[useSlot], sizeof(s[0]))) { - Warning(eDLL_T::ENGINE, "%s - Address conversion failed: %s", __FUNCTION__, NET_ErrorString(WSAGetLastError())); + Warning(eDLL_T::ENGINE, "%s - Address conversion failed: %s\n", __FUNCTION__, NET_ErrorString(WSAGetLastError())); } // Pray the caller uses it before it gets clobbered @@ -240,7 +240,7 @@ bool CNetChan::ProcessMessages(CNetChan* pChan, bf_read* pMsg) if (pSlot->m_flCurrentNetProcessTime > net_processTimeBudget->GetDouble()) { - Warning(eDLL_T::ENGINE, "Removing netchannel '%s' ('%s' exceeded frame budget by '%3.1f'ms!)\n", + Warning(eDLL_T::SERVER, "Removing netchannel '%s' ('%s' exceeded frame budget by '%3.1f'ms!)\n", pChan->GetName(), pChan->GetAddress(), (pSlot->m_flCurrentNetProcessTime - net_processTimeBudget->GetDouble())); pClient->Disconnect(Reputation_t::REP_MARK_BAD, "#DISCONNECT_NETCHAN_OVERFLOW"); diff --git a/r5dev/networksystem/bansystem.cpp b/r5dev/networksystem/bansystem.cpp index 794f75f8..aa0f9f7d 100644 --- a/r5dev/networksystem/bansystem.cpp +++ b/r5dev/networksystem/bansystem.cpp @@ -357,7 +357,7 @@ void CBanSystem::KickPlayerById(const string& svHandle) } catch (const std::exception& e) { - Error(eDLL_T::SERVER, NO_ERROR, "%s - %s", __FUNCTION__, e.what()); + Error(eDLL_T::SERVER, NO_ERROR, "%s - %s\n", __FUNCTION__, e.what()); return; } } @@ -461,7 +461,7 @@ void CBanSystem::BanPlayerById(const string& svHandle) } catch (const std::exception& e) { - Error(eDLL_T::SERVER, NO_ERROR, "%s - %s", __FUNCTION__, e.what()); + Error(eDLL_T::SERVER, NO_ERROR, "%s - %s\n", __FUNCTION__, e.what()); return; } } @@ -491,7 +491,7 @@ void CBanSystem::UnbanPlayer(const string& svCriteria) } catch (const std::exception& e) { - Error(eDLL_T::SERVER, NO_ERROR, "%s - %s", __FUNCTION__, e.what()); + Error(eDLL_T::SERVER, NO_ERROR, "%s - %s\n", __FUNCTION__, e.what()); return; } } diff --git a/r5dev/tier1/utlfixedmemory.h b/r5dev/tier1/utlfixedmemory.h index 9a0b92c7..caea9c73 100644 --- a/r5dev/tier1/utlfixedmemory.h +++ b/r5dev/tier1/utlfixedmemory.h @@ -296,7 +296,7 @@ void CUtlFixedMemory::Grow(ssize_t num) BlockHeader_t* RESTRICT pBlockHeader = (BlockHeader_t*)malloc(sizeof(BlockHeader_t) + nBlockSize * sizeof(T)); if (!pBlockHeader) { - Error(eDLL_T::ENGINE, EXIT_FAILURE, "CUtlFixedMemory overflow!\n"); + Error(eDLL_T::COMMON, EXIT_FAILURE, "CUtlFixedMemory overflow!\n"); } pBlockHeader->m_pNext = NULL; pBlockHeader->m_nBlockSize = nBlockSize; diff --git a/r5dev/tier1/utllinkedlist.h b/r5dev/tier1/utllinkedlist.h index c5b0d6ca..ef4bcc67 100644 --- a/r5dev/tier1/utllinkedlist.h +++ b/r5dev/tier1/utllinkedlist.h @@ -481,7 +481,7 @@ I CUtlLinkedList::AllocInternal(bool multilist) Assert(m_Memory.IsValidIterator(it)); if (!m_Memory.IsValidIterator(it)) { - ExecuteNTimes(10, Warning(eDLL_T::ENGINE, "CUtlLinkedList overflow! (exhausted memory allocator)\n")); + ExecuteNTimes(10, Warning(eDLL_T::COMMON, "CUtlLinkedList overflow! (exhausted memory allocator)\n")); return InvalidIndex(); } } @@ -489,7 +489,7 @@ I CUtlLinkedList::AllocInternal(bool multilist) // We can overflow before the utlmemory overflows, since S != I if (!IndexInRange(m_Memory.GetIndex(it))) { - ExecuteNTimes(10, Warning(eDLL_T::ENGINE, "CUtlLinkedList overflow! (exhausted index range)\n")); + ExecuteNTimes(10, Warning(eDLL_T::COMMON, "CUtlLinkedList overflow! (exhausted index range)\n")); return InvalidIndex(); } diff --git a/r5dev/tier1/utlrbtree.h b/r5dev/tier1/utlrbtree.h index bcabf6da..c0e5f436 100644 --- a/r5dev/tier1/utlrbtree.h +++ b/r5dev/tier1/utlrbtree.h @@ -683,7 +683,7 @@ I CUtlRBTree::NewNode() Assert(m_Elements.IsValidIterator(it)); if (!m_Elements.IsValidIterator(it)) { - Error(eDLL_T::ENGINE, EXIT_FAILURE, "CUtlRBTree overflow!\n"); + Error(eDLL_T::COMMON, EXIT_FAILURE, "CUtlRBTree overflow!\n"); } } m_LastAlloc = it; diff --git a/r5dev/vstdlib/callback.cpp b/r5dev/vstdlib/callback.cpp index 00f09ee7..15f67b8c 100644 --- a/r5dev/vstdlib/callback.cpp +++ b/r5dev/vstdlib/callback.cpp @@ -316,7 +316,7 @@ void Pak_RequestUnload_f(const CCommand& args) } catch (const std::exception& e) { - Error(eDLL_T::RTECH, NO_ERROR, "%s - %s", __FUNCTION__, e.what()); + Error(eDLL_T::RTECH, NO_ERROR, "%s - %s\n", __FUNCTION__, e.what()); return; } } @@ -379,7 +379,7 @@ void Pak_Swap_f(const CCommand& args) } catch (const std::exception& e) { - Error(eDLL_T::RTECH, NO_ERROR, "%s - %s", __FUNCTION__, e.what()); + Error(eDLL_T::RTECH, NO_ERROR, "%s - %s\n", __FUNCTION__, e.what()); return; } }