forked from altmp/altv-js-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLog.cpp
33 lines (29 loc) · 1.11 KB
/
Log.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "Log.h"
#ifdef ALT_CLIENT_API
#include "CV8ScriptRuntime.h"
#else
#include "CNodeScriptRuntime.h"
#endif
Log& Log::Endl(Log& log)
{
v8::Isolate* isolate = nullptr;
#ifdef ALT_CLIENT_API
isolate = CV8ScriptRuntime::Instance().GetIsolate();
#else
isolate = CNodeScriptRuntime::Instance().GetIsolate();
#endif
v8::Local<v8::Context> ctx;
if(isolate) ctx = isolate->GetEnteredOrMicrotaskContext();
V8ResourceImpl* v8Resource = !ctx.IsEmpty() ? V8ResourceImpl::Get(ctx) : nullptr;
alt::IResource* resource = v8Resource ? v8Resource->GetResource() : nullptr;
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;
}
log.buf.str("");
return log;
}