forked from focus-creative-games/il2cpp_plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogging.cpp
More file actions
47 lines (36 loc) · 932 Bytes
/
Logging.cpp
File metadata and controls
47 lines (36 loc) · 932 Bytes
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <stdarg.h>
#include <cstdio>
#include <cassert>
#include "Logging.h"
#include "Output.h"
using namespace il2cpp::utils;
static void DefaultLogCallback(const char* message)
{
Output::WriteToStdout(message);
Output::WriteToStdout("\n");
}
Il2CppLogCallback Logging::s_Callback = DefaultLogCallback;
void Logging::Write(const char* format, ...)
{
IL2CPP_ASSERT(s_Callback != NULL);
if (format == NULL)
return;
va_list va;
va_start(va, format);
const char* prefix = "[libil2cpp] ";
const int bufferSize = 1024 * 5;
char buffer[bufferSize];
memcpy(buffer, prefix, 12);
vsnprintf(buffer + 12, bufferSize - 12, format, va);
s_Callback(buffer);
va_end(va);
}
void Logging::SetLogCallback(Il2CppLogCallback method)
{
IL2CPP_ASSERT(method != NULL);
s_Callback = method;
}
bool Logging::IsLogCallbackSet()
{
return s_Callback != DefaultLogCallback;
}