-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLog.cs
44 lines (37 loc) · 1.01 KB
/
Log.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
using System.Runtime.InteropServices;
namespace ScriptingCore;
public static unsafe class Log
{
enum LogLevel
{
Info,
Warning,
Error,
Fatal
}
internal static delegate* unmanaged<int, IntPtr, void> LogUnmanaged;
public static void Info(string msg)
{
var ptr = Marshal.StringToHGlobalAnsi(msg);
LogUnmanaged((int)LogLevel.Info, ptr);
Marshal.FreeHGlobal(ptr);
}
public static void Warning(string msg)
{
var ptr = Marshal.StringToHGlobalAnsi(msg);
LogUnmanaged((int)LogLevel.Warning, ptr);
Marshal.FreeHGlobal(ptr);
}
public static void Error(string msg)
{
var ptr = Marshal.StringToHGlobalAnsi(msg);
LogUnmanaged((int)LogLevel.Error, ptr);
Marshal.FreeHGlobal(ptr);
}
public static void Fatal(string msg)
{
var ptr = Marshal.StringToHGlobalAnsi(msg);
LogUnmanaged((int)LogLevel.Fatal, ptr);
Marshal.FreeHGlobal(ptr);
}
}