Skip to content

Commit ade82d1

Browse files
authored
add Logger.LogWrite event (#745)
1 parent 7d2ced1 commit ade82d1

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/ExchangeSharp/Utility/Logger.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
MIT LICENSE
33
44
Copyright 2017 Digital Ruby, LLC - http://www.digitalruby.com
@@ -94,13 +94,21 @@ public enum LogLevel
9494
None = Off
9595
}
9696

97+
public class LoggerEvent
98+
{
99+
public LogLevel level;
100+
public string text;
101+
public object[] args;
102+
}
103+
97104
/// <summary>
98105
/// ExchangeSharp logger. Will never throw exceptions.
99106
/// Currently the ExchangeSharp logger uses NLog internally, so make sure it is setup in your app.config file or nlog.config file.
100107
/// </summary>
101108
public static class Logger
102109
{
103110
private static readonly NLog.Logger logger;
111+
public static event Action<LoggerEvent> LogWrite;
104112

105113
static Logger()
106114
{
@@ -253,6 +261,7 @@ public static void Write(LogLevel level, string text, params object[] args)
253261
text = string.Format(text, args);
254262
}
255263
logger?.Log(GetNLogLevel(level), text);
264+
LogWrite?.Invoke(new LoggerEvent() { level = level, text = text, args = args });
256265
}
257266
catch
258267
{

0 commit comments

Comments
 (0)