forked from scriptcs/scriptcs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScriptCsLogger.cs
More file actions
81 lines (68 loc) · 2.27 KB
/
ScriptCsLogger.cs
File metadata and controls
81 lines (68 loc) · 2.27 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System;
using ScriptCs.Contracts;
namespace ScriptCs
{
[Obsolete("Support for Common.Logging types was deprecated in version 0.15.0 and will soon be removed.")]
public class ScriptCsLogger : Common.Logging.Factory.AbstractLogger
{
private readonly ILog _log;
public ScriptCsLogger(ILog log)
{
Guard.AgainstNullArgument("log", log);
_log = log;
}
protected override void WriteInternal(Common.Logging.LogLevel level, object message, Exception exception)
{
if (level == Common.Logging.LogLevel.Off)
{
return;
}
_log.Log(Map(level), () => message == null ? null : message.ToString(), exception);
}
public override bool IsTraceEnabled
{
get { return _log.IsTraceEnabled(); }
}
public override bool IsDebugEnabled
{
get { return _log.IsDebugEnabled(); }
}
public override bool IsErrorEnabled
{
get { return _log.IsErrorEnabled(); }
}
public override bool IsFatalEnabled
{
get { return _log.IsFatalEnabled(); }
}
public override bool IsInfoEnabled
{
get { return _log.IsInfoEnabled(); }
}
public override bool IsWarnEnabled
{
get { return _log.IsWarnEnabled(); }
}
private static LogLevel Map(Common.Logging.LogLevel level)
{
switch (level)
{
case Common.Logging.LogLevel.All:
return LogLevel.Trace;
case Common.Logging.LogLevel.Debug:
return LogLevel.Debug;
case Common.Logging.LogLevel.Error:
return LogLevel.Error;
case Common.Logging.LogLevel.Fatal:
return LogLevel.Fatal;
case Common.Logging.LogLevel.Info:
return LogLevel.Info;
case Common.Logging.LogLevel.Trace:
return LogLevel.Trace;
case Common.Logging.LogLevel.Warn:
return LogLevel.Warn;
}
throw new NotSupportedException("Unknown log level.");
}
}
}