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
60
|
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
namespace ElmSharp.Test
{
internal static class Log
{
const string Library = "libdlog.so.0";
const string TAG = "ElmSharp.Test";
public static void Debug(string message,
[CallerFilePath] string file = "",
[CallerMemberName] string func = "",
[CallerLineNumber] int line = 0)
{
Print(LogPriority.DLOG_DEBUG, TAG, message, file, func, line);
}
public static void Info(string message,
[CallerFilePath] string file = "",
[CallerMemberName] string func = "",
[CallerLineNumber] int line = 0)
{
Print(LogPriority.DLOG_DEBUG, TAG, message, file, func, line);
}
public static void Error(string message,
[CallerFilePath] string file = "",
[CallerMemberName] string func = "",
[CallerLineNumber] int line = 0)
{
Print(LogPriority.DLOG_DEBUG, TAG, message, file, func, line);
}
internal enum LogPriority
{
DLOG_UNKNOWN = 0,
DLOG_DEFAULT,
DLOG_VERBOSE,
DLOG_DEBUG,
DLOG_INFO,
DLOG_WARN,
DLOG_ERROR,
DLOG_FATAL,
DLOG_SILENT,
DLOG_PRIO_MAX,
}
private static void Print(LogPriority priority, string tag, string message, string file, string func, int line)
{
FileInfo finfo = new FileInfo(file);
Print(priority, tag, "%s: %s(%d) > %s", finfo.Name, func, line, message);
}
[DllImportAttribute(Library, EntryPoint = "dlog_print")]
internal static extern int Print(LogPriority prio, string tag, string fmt, string file, string func, int line, string msg);
}
}
|