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
82
83
84
85
86
87
88
89
|
using MediaBrowser.Model.Logging;
using System;
namespace MediaBrowser.Common.Logging
{
/// <summary>
/// Class Logger
/// </summary>
public static class Logger
{
/// <summary>
/// Gets or sets the logger instance.
/// </summary>
/// <value>The logger instance.</value>
internal static ILogger LoggerInstance { get; set; }
/// <summary>
/// Logs the info.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="paramList">The param list.</param>
public static void LogInfo(string message, params object[] paramList)
{
LogEntry(message, LogSeverity.Info, null, paramList);
}
/// <summary>
/// Logs the debug info.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="paramList">The param list.</param>
public static void LogDebugInfo(string message, params object[] paramList)
{
LogEntry(message, LogSeverity.Debug, null, paramList);
}
/// <summary>
/// Logs the exception.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="ex">The ex.</param>
/// <param name="paramList">The param list.</param>
public static void LogException(string message, Exception ex, params object[] paramList)
{
LogEntry(message, LogSeverity.Error, ex, paramList);
}
/// <summary>
/// Logs the warning.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="paramList">The param list.</param>
public static void LogWarning(string message, params object[] paramList)
{
LogEntry(message, LogSeverity.Warn, null, paramList);
}
/// <summary>
/// Logs the entry.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="level">The level.</param>
/// <param name="exception">The exception.</param>
/// <param name="paramList">The param list.</param>
private static void LogEntry(string message, LogSeverity level, Exception exception, params object[] paramList)
{
if (LoggerInstance == null)
{
return;
}
if (exception == null)
{
LoggerInstance.Log(level, message, paramList);
}
else
{
if (level == LogSeverity.Fatal)
{
LoggerInstance.FatalException(message, exception, paramList);
}
else
{
LoggerInstance.ErrorException(message, exception, paramList);
}
}
}
}
}
|