Skip to content

Commit

Permalink
ALTV-330 Add runtime prefix for logs
Browse files Browse the repository at this point in the history
  • Loading branch information
vadzz-dev committed Aug 24, 2024
1 parent 5b7f478 commit 2c9fea5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
12 changes: 6 additions & 6 deletions c-api/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
CAPI_START()

void Core_LogInfo(alt::ICore* core, const char* str) {
core->LogInfo(str);
core->LogInfo(cs::Log::LOG_PREFIX, str);
}

void Core_LogDebug(alt::ICore* core, const char* str) {
core->LogDebug(str);
core->LogDebug(cs::Log::LOG_PREFIX, str);
}

void Core_LogWarning(alt::ICore* core, const char* str) {
core->LogWarning(str);
core->LogWarning(cs::Log::LOG_PREFIX, str);
}

void Core_LogError(alt::ICore* core, const char* str) {
core->LogError(str);
core->LogError(cs::Log::LOG_PREFIX, str);
}

void Core_LogColored(alt::ICore* core, const char* str) {
core->LogColored(str);
core->LogColored(cs::Log::LOG_PREFIX, str);
}

alt::MValueConst* Core_CreateMValueNil(alt::ICore* core) {
Expand Down Expand Up @@ -1218,7 +1218,7 @@ void Core_TriggerServerEventUnreliable(alt::ICore* core, const char* event, alt:
void Core_ShowCursor(alt::ICore* core, alt::IResource* resource, uint8_t state) {
if(!resource->ToggleCursor(state))
{
core->LogWarning("Cursor state can't go < 0");
core->LogWarning(cs::Log::LOG_PREFIX, "Cursor state can't go < 0");
}
}

Expand Down
12 changes: 7 additions & 5 deletions client/thirdparty/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class Log
Log() = default;

public:
static constexpr const char* LOG_PREFIX = "[C#]";

Log(const Log&) = delete;
Log(Log&&) = delete;
Log& operator=(const Log&) = delete;
Expand Down Expand Up @@ -104,11 +106,11 @@ class Log
{
switch(log.type)
{
case INFO: alt::ICore::Instance().LogInfo(log.buf.str()); break;
case DEBUG: alt::ICore::Instance().LogDebug(log.buf.str().c_str()); break;
case WARNING: alt::ICore::Instance().LogWarning(log.buf.str().c_str()); break;
case ERR: alt::ICore::Instance().LogError(log.buf.str().c_str()); break;
case COLORED: alt::ICore::Instance().LogColored(log.buf.str().c_str()); break;
case INFO: alt::ICore::Instance().LogInfo(LOG_PREFIX, log.buf.str()); break;
case DEBUG: alt::ICore::Instance().LogDebug(LOG_PREFIX, log.buf.str().c_str()); break;
case WARNING: alt::ICore::Instance().LogWarning(LOG_PREFIX, log.buf.str().c_str()); break;
case ERR: alt::ICore::Instance().LogError(LOG_PREFIX, log.buf.str().c_str()); break;
case COLORED: alt::ICore::Instance().LogColored(LOG_PREFIX, log.buf.str().c_str()); break;
}

log.buf.str("");
Expand Down

0 comments on commit 2c9fea5

Please sign in to comment.