-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathLogger.cs
59 lines (53 loc) · 1.68 KB
/
Logger.cs
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
48
49
50
51
52
53
54
55
56
57
58
59
using System.Runtime.InteropServices;
using AltV.Net.CApi;
using AltV.Net.Client.Elements;
using AltV.Net.Shared.Utils;
namespace AltV.Net.Client
{
public class Logger : ILogger
{
private readonly ILibrary library;
private readonly IntPtr corePointer;
public Logger(ILibrary library, IntPtr corePointer)
{
this.library = library;
this.corePointer = corePointer;
}
public void LogInfo(string message)
{
unsafe
{
var messagePtr = MemoryUtils.StringToHGlobalUtf8(message ?? "null");
library.Shared.Core_LogInfo(corePointer, messagePtr);
Marshal.FreeHGlobal(messagePtr);
}
}
public void LogWarning(string message)
{
unsafe
{
var messagePtr = MemoryUtils.StringToHGlobalUtf8(message ?? "null");
library.Shared.Core_LogWarning(corePointer, messagePtr);
Marshal.FreeHGlobal(messagePtr);
}
}
public void LogError(string message)
{
unsafe
{
var messagePtr = MemoryUtils.StringToHGlobalUtf8(message ?? "null");
library.Shared.Core_LogError(corePointer, messagePtr);
Marshal.FreeHGlobal(messagePtr);
}
}
public void LogDebug(string message)
{
unsafe
{
var messagePtr = MemoryUtils.StringToHGlobalUtf8(message ?? "null");
library.Shared.Core_LogDebug(corePointer, messagePtr);
Marshal.FreeHGlobal(messagePtr);
}
}
}
}