forked from kipusoep/UrlTracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UrlTrackerErrorLogging.cs
61 lines (59 loc) · 1.49 KB
/
UrlTrackerErrorLogging.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace InfoCaster.Umbraco.UrlTracker
{
/// <summary>
/// The Error Logger interface
/// </summary>
public interface IUrlTrackerLogger
{
/// <summary>
/// The Log method
/// </summary>
/// <param name="message">The error message</param>
void Log(string message);
/// <summary>
/// The Log method
/// </summary>
/// <param name="exception">The exception</param>
void Log(Exception exception);
}
/// <summary>
/// The Error Logging class
/// </summary>
public static class UrlTrackerLogging
{
/// <summary>
/// The active Error Logger instance
/// </summary>
internal static IUrlTrackerLogger ErrorLogger { get; set; }
/// <summary>
/// Registers the provided implemented <see cref="IUrlTrackerLogger"/> as active ErrorLogger
/// </summary>
/// <param name="logger">The implemented <see cref="IUrlTrackerLogger"/></param>
public static void RegisterLogger(IUrlTrackerLogger logger)
{
ErrorLogger = logger;
}
/// <summary>
/// Log a message
/// </summary>
/// <param name="message">The message</param>
internal static void Log(string message)
{
if (ErrorLogger != null)
ErrorLogger.Log(message);
}
/// <summary>
/// Log an <see cref="Exception"/>
/// </summary>
/// <param name="exception">The <see cref="Exception"/></param>
internal static void Log(Exception exception)
{
if (ErrorLogger != null)
ErrorLogger.Log(exception);
}
}
}