-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScriptLogger.cs
More file actions
54 lines (45 loc) · 1.21 KB
/
ScriptLogger.cs
File metadata and controls
54 lines (45 loc) · 1.21 KB
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
using Microsoft.Extensions.Logging;
using V8.Net;
#pragma warning disable IDE1006 // Naming Styles
namespace OpenMod.Scripting.JavaScript
{
[ScriptObject]
public class ScriptLogger
{
private readonly ILogger m_Logger;
public ScriptLogger(ILoggerFactory loggerFactory, string scriptId)
{
m_Logger = loggerFactory.CreateLogger($"JavaScript.{scriptId}");
}
[ScriptMember("info")]
public void Info(string message)
{
m_Logger.LogInformation(message);
}
[ScriptMember("warn")]
public void Warn(string message)
{
m_Logger.LogWarning(message);
}
[ScriptMember("trace")]
public void Trace(string message)
{
m_Logger.LogTrace(message);
}
[ScriptMember("critical")]
public void Critical(string message)
{
m_Logger.LogCritical(message);
}
[ScriptMember("err")]
public void Err(string message)
{
m_Logger.LogError(message);
}
[ScriptMember("dbg")]
public void Dbg(string message)
{
m_Logger.LogDebug(message);
}
}
}