Skip to content

Commit

Permalink
fixed issues with cause not being propagated / implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronontheweb authored and Danthar committed Jul 5, 2018
1 parent 913fc75 commit f91bc8b
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 7 deletions.
15 changes: 15 additions & 0 deletions src/core/Akka/Event/BusLogging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ protected override void NotifyWarning(object message)
_bus.Publish(new Warning(_logSource, _logClass, message));
}

protected override void NotifyWarning(Exception cause, object message)
{
_bus.Publish(new Warning(cause, _logSource, _logClass, message));
}

/// <summary>
/// Publishes the info message onto the LoggingBus.
/// </summary>
Expand All @@ -99,6 +104,11 @@ protected override void NotifyInfo(object message)
_bus.Publish(new Info(_logSource, _logClass, message));
}

protected override void NotifyInfo(Exception cause, object message)
{
_bus.Publish(new Info(cause, _logSource, _logClass, message));
}

/// <summary>
/// Publishes the debug message onto the LoggingBus.
/// </summary>
Expand All @@ -107,5 +117,10 @@ protected override void NotifyDebug(object message)
{
_bus.Publish(new Debug(_logSource, _logClass, message));
}

protected override void NotifyDebug(Exception cause, object message)
{
_bus.Publish(new Debug(cause, _logSource, _logClass, message));
}
}
}
80 changes: 73 additions & 7 deletions src/core/Akka/Event/LoggingAdapterBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,47 @@ public abstract class LoggingAdapterBase : ILoggingAdapter
/// <param name="message">The message related to the log event.</param>
protected abstract void NotifyWarning(object message);

/// <summary>
/// Notifies all subscribers that an <see cref="LogLevel.WarningLevel" /> log event occurred.
/// </summary>
/// <param name="cause">The exception that caused the log event.</param>
/// <param name="message">The message related to the log event.</param>
protected abstract void NotifyWarning(Exception cause, object message);

/// <summary>
/// Notifies all subscribers that an <see cref="LogLevel.InfoLevel" /> log event occurred.
/// </summary>
/// <param name="message">The message related to the log event.</param>
protected abstract void NotifyInfo(object message);

/// <summary>
/// Notifies all subscribers that an <see cref="LogLevel.InfoLevel" /> log event occurred.
/// </summary>
/// <param name="cause">The exception that caused the log event.</param>
/// <param name="message">The message related to the log event.</param>
protected abstract void NotifyInfo(Exception cause, object message);

/// <summary>
/// Notifies all subscribers that an <see cref="LogLevel.DebugLevel" /> log event occurred.
/// </summary>
/// <param name="message">The message related to the log event.</param>
protected abstract void NotifyDebug(object message);

/// <summary>
/// Notifies all subscribers that an <see cref="LogLevel.DebugLevel" /> log event occurred.
/// </summary>
/// <param name="cause">The exception that caused the log event.</param>
/// <param name="message">The message related to the log event.</param>
protected abstract void NotifyDebug(Exception cause, object message);

/// <summary>
/// Creates an instance of the LoggingAdapterBase.
/// </summary>
/// <param name="logMessageFormatter">The log message formatter used by this logging adapter.</param>
/// <exception cref="ArgumentNullException">This exception is thrown when the given <paramref name="logMessageFormatter"/> is undefined.</exception>
protected LoggingAdapterBase(ILogMessageFormatter logMessageFormatter)
{
if(logMessageFormatter == null)
throw new ArgumentNullException(nameof(logMessageFormatter), "The message formatter must not be null.");

_logMessageFormatter = logMessageFormatter;
_logMessageFormatter = logMessageFormatter ?? throw new ArgumentNullException(nameof(logMessageFormatter), "The message formatter must not be null.");
}

/// <summary>
Expand Down Expand Up @@ -150,9 +168,25 @@ public virtual void Debug(string format, params object[] args)
}
}

/// <summary>
/// Logs a <see cref="LogLevel.DebugLevel" /> message.
/// </summary>
/// <param name="cause">The exception associated with this message.</param>
/// <param name="format">The message that is being logged.</param>
/// <param name="args">An optional list of items used to format the message.</param>
public virtual void Debug(Exception cause, string format, params object[] args)
{
throw new NotImplementedException();
if (!IsDebugEnabled)
return;

if (args == null || args.Length == 0)
{
NotifyDebug(cause, format);
}
else
{
NotifyDebug(cause, new LogMessage(_logMessageFormatter, format, args));
}
}

/// <summary>
Expand All @@ -165,9 +199,25 @@ public virtual void Warn(string format, params object[] args)
Warning(format, args);
}

/// <summary>
/// Logs a <see cref="LogLevel.InfoLevel" /> message.
/// </summary>
/// <param name="cause">The exception associated with this message.</param>
/// <param name="format">The message that is being logged.</param>
/// <param name="args">An optional list of items used to format the message.</param>
public virtual void Info(Exception cause, string format, params object[] args)
{
throw new NotImplementedException();
if (!IsInfoEnabled)
return;

if (args == null || args.Length == 0)
{
NotifyInfo(cause, format);
}
else
{
NotifyInfo(cause, new LogMessage(_logMessageFormatter, format, args));
}
}

/// <summary>
Expand All @@ -190,9 +240,25 @@ public virtual void Warning(string format, params object[] args)
}
}

/// <summary>
/// Logs a <see cref="LogLevel.WarningLevel" /> message.
/// </summary>
/// <param name="cause">The exception associated with this message.</param>
/// <param name="format">The message that is being logged.</param>
/// <param name="args">An optional list of items used to format the message.</param>
public virtual void Warning(Exception cause, string format, params object[] args)
{
throw new NotImplementedException();
if (!IsWarningEnabled)
return;

if (args == null || args.Length == 0)
{
NotifyWarning(cause, format);
}
else
{
NotifyWarning(cause, new LogMessage(_logMessageFormatter, format, args));
}
}

/// <summary>
Expand Down

0 comments on commit f91bc8b

Please sign in to comment.