mirror of
https://github.com/Radarr/Radarr
synced 2024-12-26 17:59:14 +00:00
c928ccb201
Also extension methods for complete and failed (for coloured UI messaging)
39 lines
No EOL
1.1 KiB
C#
39 lines
No EOL
1.1 KiB
C#
using System;
|
|
using NLog;
|
|
using NzbDrone.Common.Serializer;
|
|
|
|
namespace NzbDrone.Common.Instrumentation
|
|
{
|
|
public static class LogEventExtensions
|
|
{
|
|
public static string GetHash(this LogEventInfo logEvent)
|
|
{
|
|
var stackString = logEvent.StackTrace.ToJson();
|
|
var hashSeed = String.Concat(logEvent.LoggerName, logEvent.Exception.GetType().ToString(), stackString, logEvent.Level);
|
|
return HashUtil.CalculateCrc(hashSeed);
|
|
}
|
|
|
|
public static string GetFormattedMessage(this LogEventInfo logEvent)
|
|
{
|
|
var message = logEvent.FormattedMessage;
|
|
|
|
if (logEvent.Exception != null)
|
|
{
|
|
if (logEvent.Exception != null)
|
|
{
|
|
if (String.IsNullOrWhiteSpace(message))
|
|
{
|
|
message = logEvent.Exception.Message;
|
|
}
|
|
else
|
|
{
|
|
message += ": " + logEvent.Exception.Message;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return message;
|
|
}
|
|
}
|
|
} |