added more info to decision engine exception reporting.

pull/3113/head
Keivan Beigi 11 years ago
parent f162f164e7
commit 4e06cf0fa6

@ -1,39 +0,0 @@
using System.Text.RegularExpressions;
using System.Linq;
namespace NzbDrone.Common.EnsureThat
{
public static class StringExtensions
{
public static string Inject(this string format, params object[] formattingArgs)
{
return string.Format(format, formattingArgs);
}
public static string Inject(this string format, params string[] formattingArgs)
{
return string.Format(format, formattingArgs.Cast<object>());
}
private static readonly Regex InvalidCharRegex = new Regex(@"[^a-z0-9\s-]", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex CollapseSpace = new Regex(@"\s+", RegexOptions.Compiled | RegexOptions.IgnoreCase);
public static string ToSlug(this string phrase)
{
phrase = phrase.RemoveAccent().ToLower();
phrase = InvalidCharRegex.Replace(phrase, string.Empty);
phrase = CollapseSpace.Replace(phrase, " ").Trim();
phrase = phrase.Replace(" ", "-");
return phrase;
}
public static string RemoveAccent(this string txt)
{
var bytes = System.Text.Encoding.GetEncoding("Cyrillic").GetBytes(txt);
return System.Text.Encoding.ASCII.GetString(bytes);
}
}
}

@ -56,6 +56,11 @@ namespace NzbDrone.Common.Instrumentation
dictionary.Add("ex", logEvent.Exception.ToString());
dictionary.Add("extyp", logEvent.Exception.GetType().Name);
dictionary.Add("hash", logEvent.GetHash());
foreach (var key in logEvent.Exception.Data.Keys)
{
dictionary.Add(key.ToString(), logEvent.Exception.Data[key]);
}
}
dictionary.Add("logger", logEvent.LoggerName);

@ -110,6 +110,8 @@ namespace NzbDrone.Core.DecisionEngine
}
catch (Exception e)
{
e.Data.Add("report", remoteEpisode.Report);
e.Data.Add("parsed", remoteEpisode.ParsedEpisodeInfo);
_logger.ErrorException("Couldn't evaluate decision", e);
return string.Format("{0}: {1}", spec.GetType().Name, e.Message);
}

@ -1,7 +1,5 @@
using System.Linq;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using NzbDrone.Common;
using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource.Trakt;
using NzbDrone.Core.Tv;

Loading…
Cancel
Save