Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALTV-330 Add runtime log prefix #323

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions shared/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

Log& Log::Endl(Log& log)
{
auto& core = alt::ICore::Instance();

v8::Isolate* isolate = nullptr;
#ifdef ALT_CLIENT_API
isolate = CV8ScriptRuntime::Instance().GetIsolate();
Expand All @@ -22,11 +24,11 @@ Log& Log::Endl(Log& log)

switch(log.type)
{
case INFO: alt::ICore::Instance().LogInfo(log.buf.str(), resource); break;
case DEBUG: alt::ICore::Instance().LogDebug(log.buf.str().c_str(), resource); break;
case WARNING: alt::ICore::Instance().LogWarning(log.buf.str().c_str(), resource); break;
case ERR: alt::ICore::Instance().LogError(log.buf.str().c_str(), resource); break;
case COLORED: alt::ICore::Instance().LogColored(log.buf.str().c_str(), resource); break;
case INFO: core.LogInfo(LOG_PREFIX, log.buf.str(), resource); break;
case DEBUG: core.LogDebug(LOG_PREFIX, log.buf.str().c_str(), resource); break;
case WARNING: core.LogWarning(LOG_PREFIX, log.buf.str().c_str(), resource); break;
case ERR: core.LogError(LOG_PREFIX, log.buf.str().c_str(), resource); break;
case COLORED: core.LogColored(LOG_PREFIX, log.buf.str().c_str(), resource); break;
}

log.buf.str("");
Expand Down
2 changes: 2 additions & 0 deletions shared/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class Log
Log() = default;

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

Log(const Log&) = delete;
Log(Log&&) = delete;
Log& operator=(const Log&) = delete;
Expand Down
6 changes: 3 additions & 3 deletions shared/V8ResourceImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,17 +656,17 @@ static void PrintLog(const v8::FunctionCallbackInfo<v8::Value>& info)
{
case 0:
{
alt::ICore::Instance().LogColored(stream.str(), resource->GetResource());
alt::ICore::Instance().LogColored(Log::LOG_PREFIX, stream.str(), resource->GetResource());
break;
}
case 1:
{
alt::ICore::Instance().LogWarning(stream.str(), resource->GetResource());
alt::ICore::Instance().LogWarning(Log::LOG_PREFIX, stream.str(), resource->GetResource());
break;
}
case 2:
{
alt::ICore::Instance().LogError(stream.str(), resource->GetResource());
alt::ICore::Instance().LogError(Log::LOG_PREFIX, stream.str(), resource->GetResource());
break;
}
}
Expand Down
Loading