Skip to content
Permalink
Browse files

Error and Fatal can now have Exceptions passed to them (only the Func…

…<string> versions though)
  • Loading branch information...
ferventcoder committed Apr 4, 2013
1 parent 7354ba6 commit 4a468d2836312184597981e5e91a98909e23f1f8
@@ -65,6 +65,13 @@ public interface ILog
/// <param name="message">The message.</param>
void Error(Func<string> message);

/// <summary>
/// Error level of the specified message.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="exception">The exception.</param>
void Error(Func<string> message,Exception exception);

/// <summary>
/// Fatal level of the specified message. The other method is preferred since the execution is deferred.
/// </summary>
@@ -77,6 +84,13 @@ public interface ILog
/// </summary>
/// <param name="message">The message.</param>
void Fatal(Func<string> message);

/// <summary>
/// Fatal level of the specified message.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="exception">The exception.</param>
void Fatal(Func<string> message, Exception exception);
}

/// <summary>
@@ -43,12 +43,22 @@ public void Error(Func<string> message)
{
}

public void Error(Func<string> message, Exception exception)
{

}

public void Fatal(string message, params object[] formatting)
{
}

public void Fatal(Func<string> message)
{
}

public void Fatal(Func<string> message, Exception exception)
{

}
}
}
@@ -85,6 +85,12 @@ public void Error(Func<string> message)
Object.Error(message);
}

public void Error(Func<string> message, Exception exception)
{
LogMessage(LogLevel.Error, message());
Object.Error(message,exception);
}

public void Fatal(string message, params object[] formatting)
{
LogMessage(LogLevel.Fatal, string.Format(message, formatting));
@@ -96,5 +102,11 @@ public void Fatal(Func<string> message)
LogMessage(LogLevel.Fatal, message());
Object.Fatal(message);
}

public void Fatal(Func<string> message, Exception exception)
{
LogMessage(LogLevel.Fatal, message());
Object.Fatal(message,exception);
}
}
}
@@ -59,6 +59,11 @@ public void Error(Func<string> message)
_logger.Error(message());
}

public void Error(Func<string> message, Exception exception)
{
_logger.ErrorException(message(),exception);
}

public void Fatal(string message, params object[] formatting)
{
// don't check for enabled at this level
@@ -70,5 +75,10 @@ public void Fatal(Func<string> message)
// don't check for enabled at this level
_logger.Fatal(message());
}

public void Fatal(Func<string> message, Exception exception)
{
_logger.FatalException(message(),exception);
}
}
}
@@ -92,6 +92,12 @@ public void Error(Func<string> message)
_logger.Error(message);
}

public void Error(Func<string> message, Exception exception)
{
LogMessage(LogLevel.Error, message());
_logger.Error(message,exception);
}

public void Fatal(string message, params object[] formatting)
{
LogMessage(LogLevel.Fatal, string.Format(message, formatting));
@@ -103,5 +109,11 @@ public void Fatal(Func<string> message)
LogMessage(LogLevel.Fatal, message());
_logger.Fatal(message);
}

public void Fatal(Func<string> message, Exception exception)
{
LogMessage(LogLevel.Fatal, message());
_logger.Fatal(message,exception);
}
}
}
@@ -42,7 +42,7 @@ public void Debug(Func<string> message)
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
public void Info(string message, params object[] formatting)
{
if (_logger.IsInfoEnabled) Log(Level.Info, message, formatting);
if (_logger.IsInfoEnabled) Log(Level.Info, message, formatting);
}

[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
@@ -54,7 +54,7 @@ public void Info(Func<string> message)
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
public void Warn(string message, params object[] formatting)
{
if (_logger.IsWarnEnabled) Log(Level.Warn, message, formatting);
if (_logger.IsWarnEnabled) Log(Level.Warn, message, formatting);
}

[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
@@ -77,6 +77,11 @@ public void Error(Func<string> message)
Log(Level.Error, message);
}

public void Error(Func<string> message, Exception exception)
{
Log(Level.Error, message, exception);
}

[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
public void Fatal(string message, params object[] formatting)
{
@@ -91,10 +96,21 @@ public void Fatal(Func<string> message)
Log(Level.Fatal, message);
}

public void Fatal(Func<string> message, Exception exception)
{
Log(Level.Fatal, message, exception);
}

[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
private void Log(Level level, Func<string> message)
{
_logger.Logger.Log(_declaringType, level, message(), null);
Log(level, message(), null);
}

[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
private void Log(Level level, Func<string> message, Exception exception)
{
_logger.Logger.Log(_declaringType, level, message(), exception);
}

[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]

0 comments on commit 4a468d2

Please sign in to comment.
You can’t perform that action at this time.