Logging/Download notification tweaks.

This commit is contained in:
kay.one 2012-02-21 20:43:19 -08:00
parent e0f901dbe7
commit 7e38afc838
9 changed files with 159 additions and 18 deletions

View File

@ -51,7 +51,7 @@ namespace NzbDrone.Common
}
e.Data.Add("title", title);
logger.ErrorException("Unable to report parse error", e);
logger.InfoException("Unable to report parse error", e);
}
}
@ -77,8 +77,8 @@ namespace NzbDrone.Common
throw;
}
//this shouldn't log an exception since it might cause a recursive loop.
logger.Error("Unable to report exception. " + e);
//this shouldn't log an exception since it will cause a recursive loop.
logger.Info("Unable to report exception. " + e);
}
}
}

View File

@ -0,0 +1,134 @@
using System;
using System.Collections.Generic;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class EpisodeParseResultTest : CoreTest
{
[Test]
public void tostring_single_season_episode()
{
var parseResult = new EpisodeParseResult();
parseResult.SeriesTitle = "My Series";
parseResult.SeasonNumber = 12;
parseResult.EpisodeNumbers = new List<int> { 3 };
parseResult.FullSeason = false;
parseResult.AirDate = null;
parseResult.Quality = new Quality(QualityTypes.HDTV, false);
parseResult.ToString().Should().Be("My Series - S12E03 HDTV");
}
[Test]
public void tostring_single_season_episode_proper()
{
var parseResult = new EpisodeParseResult();
parseResult.SeriesTitle = "My Series";
parseResult.SeasonNumber = 12;
parseResult.EpisodeNumbers = new List<int> { 3 };
parseResult.FullSeason = false;
parseResult.AirDate = null;
parseResult.Quality = new Quality(QualityTypes.HDTV, true);
parseResult.ToString().Should().Be("My Series - S12E03 HDTV [proper]");
}
[Test]
public void tostring_multi_season_episode()
{
var parseResult = new EpisodeParseResult();
parseResult.SeriesTitle = "My Series";
parseResult.SeasonNumber = 12;
parseResult.EpisodeNumbers = new List<int> { 3, 4, 5 };
parseResult.FullSeason = false;
parseResult.AirDate = null;
parseResult.Quality = new Quality(QualityTypes.HDTV, false);
parseResult.ToString().Should().Be("My Series - S12E03-04-05 HDTV");
}
[Test]
public void tostring_multi_season_episode_proper()
{
var parseResult = new EpisodeParseResult();
parseResult.SeriesTitle = "My Series";
parseResult.SeasonNumber = 12;
parseResult.EpisodeNumbers = new List<int> { 3, 4, 5 };
parseResult.FullSeason = false;
parseResult.AirDate = null;
parseResult.Quality = new Quality(QualityTypes.HDTV, true);
parseResult.ToString().Should().Be("My Series - S12E03-04-05 HDTV [proper]");
}
[Test]
public void tostring_full_season()
{
var parseResult = new EpisodeParseResult();
parseResult.SeriesTitle = "My Series";
parseResult.SeasonNumber = 12;
parseResult.FullSeason = true;
parseResult.AirDate = null;
parseResult.Quality = new Quality(QualityTypes.HDTV, false);
parseResult.ToString().Should().Be("My Series - Season 12 HDTV");
}
[Test]
public void tostring_full_season_proper()
{
var parseResult = new EpisodeParseResult();
parseResult.SeriesTitle = "My Series";
parseResult.SeasonNumber = 12;
parseResult.FullSeason = true;
parseResult.AirDate = null;
parseResult.Quality = new Quality(QualityTypes.HDTV, true);
parseResult.ToString().Should().Be("My Series - Season 12 HDTV [proper]");
}
[Test]
public void tostring_daily_show()
{
var parseResult = new EpisodeParseResult();
parseResult.SeriesTitle = "My Series";
parseResult.SeasonNumber = 12;
parseResult.FullSeason = true;
parseResult.AirDate = new DateTime(2010, 12, 30);
parseResult.Quality = new Quality(QualityTypes.HDTV, false);
parseResult.ToString().Should().Be("My Series - 2010-12-30 HDTV");
}
[Test]
public void tostring_daily_show_proper()
{
var parseResult = new EpisodeParseResult();
parseResult.SeriesTitle = "My Series";
parseResult.SeasonNumber = 12;
parseResult.FullSeason = true;
parseResult.AirDate = new DateTime(2010, 12, 30);
parseResult.Quality = new Quality(QualityTypes.HDTV, true);
parseResult.ToString().Should().Be("My Series - 2010-12-30 HDTV [proper]");
}
}
}

View File

@ -109,6 +109,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="EpisodeParseResultTest.cs" />
<Compile Include="Integeration\ServiceIntegerationFixture.cs" />
<Compile Include="JobTests\BacklogSearchJobTest.cs" />
<Compile Include="JobTests\BannerDownloadJobTest.cs" />

View File

@ -84,6 +84,8 @@ namespace NzbDrone.Core.Jobs
notification.CurrentMessage = "RSS Sync Completed";
Logger.Info("RSS Sync completed");
}
}
}

View File

@ -44,17 +44,23 @@ namespace NzbDrone.Core.Model
public override string ToString()
{
string episodeString = "[Unknown Episode]";
if (AirDate != null && EpisodeNumbers == null)
return string.Format("{0} - {1} {2}", SeriesTitle, AirDate.Value.ToShortDateString(), Quality);
{
episodeString = string.Format("{0}", AirDate.Value.ToString("yyyy-MM-dd"));
}
else if (FullSeason)
{
episodeString = string.Format("Season {0:00}", SeasonNumber);
}
else if (EpisodeNumbers != null && EpisodeNumbers.Any())
{
episodeString = string.Format("S{0:00}E{1}",SeasonNumber, String.Join("-", EpisodeNumbers.Select(c => c.ToString("00"))));
}
if (FullSeason)
return string.Format("{0} - Season {1:00}", SeriesTitle, SeasonNumber);
if (EpisodeNumbers != null && EpisodeNumbers.Any())
return string.Format("{0} - S{1:00}E{2} {3}", SeriesTitle, SeasonNumber,
String.Join("-", EpisodeNumbers.Select(c => c.ToString("00"))), Quality);
return "[Invalid format]";
return string.Format("{0} - {1} {2}", SeriesTitle, episodeString, Quality);
}
}

View File

@ -231,7 +231,7 @@ namespace NzbDrone.Core.Providers
}
else
{
logger.Debug("Unable to find {0}-S{1:00}E{2:00}", parseResult.Series.Title, parseResult.SeasonNumber, episodeNumber);
logger.Debug("Unable to find {0}", parseResult);
}
}

View File

@ -93,7 +93,7 @@ namespace NzbDrone.Core.Providers.Indexer
result = Fetch(Urls);
_logger.Info("Finished processing feeds from " + Name);
_logger.Debug("Finished processing feeds from " + Name);
return result;
}

View File

@ -275,10 +275,7 @@ namespace NzbDrone.Core.Providers
{
if (_downloadProvider.DownloadReport(episodeParseResult))
{
notification.CurrentMessage =
String.Format("{0} - S{1:00}E{2:00} {3} Added to download queue",
episodeParseResult.Series.Title, episodeParseResult.SeasonNumber,
episodeParseResult.EpisodeNumbers[0], episodeParseResult.Quality);
notification.CurrentMessage = String.Format("{0} Added to download queue", episodeParseResult);
//Add the list of episode numbers from this release
successes.AddRange(episodeParseResult.EpisodeNumbers);

View File

@ -117,6 +117,7 @@ hr
font-weight: 100;
height: 135px;
background: url(images/header.jpg) no-repeat left top;
background-color: #065EFE;
font-size: 90px;
color: #FFFFFF;
text-transform: lowercase;