From c9bc063a9c7c13b70632d5308d3503136595cd97 Mon Sep 17 00:00:00 2001 From: Keivan Date: Sun, 24 Oct 2010 10:35:58 -0700 Subject: [PATCH] Updated log appearance. --- NzbDrone.Core.Test/RepoTest.cs | 34 +++++++++++++++++++ NzbDrone.Core/CentralDispatch.cs | 4 +-- .../Instrumentation/SubsonicTarget.cs | 3 ++ .../Notification/ProgressNotification.cs | 2 +- NzbDrone.Core/Providers/SyncProvider.cs | 6 ++-- NzbDrone.Web/Content/style.css | 6 ++++ NzbDrone.Web/Global.asax.cs | 4 +-- NzbDrone.Web/NzbDrone.Web.csproj | 1 - NzbDrone.Web/Views/Log/Index.aspx | 31 +++++++++++++++-- NzbDrone.Web/Views/Log/LogDetail.ascx | 15 -------- NzbDrone.Web/Views/Shared/Site.Master | 8 +---- 11 files changed, 81 insertions(+), 33 deletions(-) delete mode 100644 NzbDrone.Web/Views/Log/LogDetail.ascx diff --git a/NzbDrone.Core.Test/RepoTest.cs b/NzbDrone.Core.Test/RepoTest.cs index f4229acbe..42f165b83 100644 --- a/NzbDrone.Core.Test/RepoTest.cs +++ b/NzbDrone.Core.Test/RepoTest.cs @@ -131,5 +131,39 @@ namespace NzbDrone.Core.Test Assert.AreEqual(ex.ToString(), logItem.ExceptionString); Assert.AreEqual(ex.Message, logItem.ExceptionMessage); } + + [Test] + public void write_log_exception_no_message_should_use_exception_message() + { + //setup + var message = String.Empty; + + var sonicRepo = MockLib.GetEmptyRepository(); + + var sonicTarget = new SubsonicTarget(sonicRepo); + LogManager.Configuration.AddTarget("DbLogger", sonicTarget); + LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", NLog.LogLevel.Info, sonicTarget)); + LogManager.Configuration.Reload(); + + Logger Logger = LogManager.GetCurrentClassLogger(); + + var ex = new InvalidOperationException("Fake Exception"); + //Act + + Logger.ErrorException(message, ex); + + //Assert + Assert.IsNotEmpty(sonicRepo.All()); + Assert.Count(1, sonicRepo.All()); + + var logItem = sonicRepo.All().First(); + Assert.AreNotEqual(new DateTime(), logItem.Time); + Assert.AreEqual(ex.Message, logItem.Message); + Assert.AreEqual(Logger.Name, logItem.Logger); + Assert.AreEqual(LogLevel.Error, logItem.Level); + Assert.AreEqual(ex.GetType().ToString(), logItem.ExceptionType); + Assert.AreEqual(ex.ToString(), logItem.ExceptionString); + Assert.AreEqual(ex.Message, logItem.ExceptionMessage); + } } } diff --git a/NzbDrone.Core/CentralDispatch.cs b/NzbDrone.Core/CentralDispatch.cs index c78e78771..6e02ea2e8 100644 --- a/NzbDrone.Core/CentralDispatch.cs +++ b/NzbDrone.Core/CentralDispatch.cs @@ -97,7 +97,7 @@ namespace NzbDrone.Core { try { - Logger.Info("Attaching to parent process for automatic termination."); + Logger.Debug("Attaching to parent process for automatic termination."); var pc = new PerformanceCounter("Process", "Creating Process ID", Process.GetCurrentProcess().ProcessName); var pid = (int)pc.NextValue(); var hostProcess = Process.GetProcessById(pid); @@ -109,7 +109,7 @@ namespace NzbDrone.Core ShutDown(); }); - Logger.Info("Successfully Attached to host. Process ID: {0}", pid); + Logger.Debug("Successfully Attached to host. Process ID: {0}", pid); } catch (Exception e) { diff --git a/NzbDrone.Core/Instrumentation/SubsonicTarget.cs b/NzbDrone.Core/Instrumentation/SubsonicTarget.cs index 5992666bf..b744de9fa 100644 --- a/NzbDrone.Core/Instrumentation/SubsonicTarget.cs +++ b/NzbDrone.Core/Instrumentation/SubsonicTarget.cs @@ -33,6 +33,9 @@ namespace NzbDrone.Core.Instrumentation if (logEvent.Exception != null) { + if (String.IsNullOrWhiteSpace(log.Message)) + log.Message = logEvent.Exception.Message; + log.ExceptionMessage = logEvent.Exception.Message; log.ExceptionString = logEvent.Exception.ToString(); log.ExceptionType = logEvent.Exception.GetType().ToString(); diff --git a/NzbDrone.Core/Model/Notification/ProgressNotification.cs b/NzbDrone.Core/Model/Notification/ProgressNotification.cs index a25ce3946..ef4539e30 100644 --- a/NzbDrone.Core/Model/Notification/ProgressNotification.cs +++ b/NzbDrone.Core/Model/Notification/ProgressNotification.cs @@ -69,7 +69,7 @@ namespace NzbDrone.Core.Model.Notification { if (Status == ProgressNotificationStatus.InProgress) { - Logger.Warn("Progress notification '{0}' was unexpectedly abandoned. ID:{1} Status:{2} CurrentStatus:{3} PercentComplete:{4}", Title, Id, Status, CurrentStatus, PercentComplete); + Logger.Warn("Background task '{0}' was unexpectedly abandoned.", Title); Status = ProgressNotificationStatus.Failed; } } diff --git a/NzbDrone.Core/Providers/SyncProvider.cs b/NzbDrone.Core/Providers/SyncProvider.cs index 3db2c4ded..8c8644598 100644 --- a/NzbDrone.Core/Providers/SyncProvider.cs +++ b/NzbDrone.Core/Providers/SyncProvider.cs @@ -67,7 +67,7 @@ namespace NzbDrone.Core.Providers { _seriesSyncNotification.CurrentStatus = String.Format("Analysing Folder: {0}", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(new DirectoryInfo(seriesFolder).Name)); - Logger.Info("Folder '{0}' isn't mapped in the database. Trying to map it.'", seriesFolder); + Logger.Debug("Folder '{0}' isn't mapped in the database. Trying to map it.'", seriesFolder); var mappedSeries = _seriesProvider.MapPathToSeries(seriesFolder); if (mappedSeries == null) @@ -91,7 +91,7 @@ namespace NzbDrone.Core.Providers } catch (Exception e) { - Logger.ErrorException("", e); + Logger.ErrorException(e.Message, e); } _seriesSyncNotification.ProgressValue++; } @@ -104,7 +104,7 @@ namespace NzbDrone.Core.Providers } catch (Exception e) { - Logger.ErrorException("", e); + Logger.ErrorException(e.Message, e); } } } diff --git a/NzbDrone.Web/Content/style.css b/NzbDrone.Web/Content/style.css index 1937b1135..6a2accce0 100644 --- a/NzbDrone.Web/Content/style.css +++ b/NzbDrone.Web/Content/style.css @@ -392,3 +392,9 @@ hr #footer a { } + + +.t-grid .t-last { +border-bottom:1px solid #EEEEEE; +border-color:#EEEEEE; +} \ No newline at end of file diff --git a/NzbDrone.Web/Global.asax.cs b/NzbDrone.Web/Global.asax.cs index e6d45f04d..82f105d98 100644 --- a/NzbDrone.Web/Global.asax.cs +++ b/NzbDrone.Web/Global.asax.cs @@ -54,11 +54,11 @@ namespace NzbDrone.Web var lastError = Server.GetLastError(); if (lastError is HttpException) { - Logger.WarnException("", lastError); + Logger.WarnException(lastError.Message, lastError); } else { - Logger.FatalException("", lastError); + Logger.FatalException(lastError.Message, lastError); } } diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index b7fed5ad0..1a5742c00 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -213,7 +213,6 @@ - diff --git a/NzbDrone.Web/Views/Log/Index.aspx b/NzbDrone.Web/Views/Log/Index.aspx index c99aeb467..f56e389ee 100644 --- a/NzbDrone.Web/Views/Log/Index.aspx +++ b/NzbDrone.Web/Views/Log/Index.aspx @@ -1,6 +1,26 @@ <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage>" %> <%@ Import Namespace="Telerik.Web.Mvc.UI" %> + + + Logs @@ -19,13 +39,20 @@ columns.Bound(c => c.Message); }) .DataBinding(dataBinding => dataBinding.Ajax().Select("_AjaxBinding", "Log")) - //.DetailView(detailView => detailView.Template(e => Html.RenderPartial("LogDetail", e))) + .DetailView(detailView => detailView.ClientTemplate( + + "
<#= Logger #>
" + + "
<#= ExceptionType #>
" + + "
<#= ExceptionMessage #>
" + + "
<#= ExceptionString #>
" + + )) .Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.Time).Descending()).Enabled(true)) .Pageable(c => c.PageSize(50).Position(GridPagerPosition.Both).Style(GridPagerStyles.PageInput | GridPagerStyles.NextPreviousAndNumeric)) //.Groupable() .Filterable() + .ClientEvents(c => c.OnRowDataBound("onRowDataBound")) //.Groupable(grouping => grouping.Groups(groups => groups.Add(c => c.Time.Date)).Enabled(true)) .Render(); %> - diff --git a/NzbDrone.Web/Views/Log/LogDetail.ascx b/NzbDrone.Web/Views/Log/LogDetail.ascx deleted file mode 100644 index 0bc673c40..000000000 --- a/NzbDrone.Web/Views/Log/LogDetail.ascx +++ /dev/null @@ -1,15 +0,0 @@ -<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> -
    -
  • - <%: Model.Logger %> -
  • -
  • - <%: Model.ExceptionType%> -
  • -
  • - <%: Model.ExceptionMessage%> -
  • -
  • - <%: Model.ExceptionString%> -
  • -
diff --git a/NzbDrone.Web/Views/Shared/Site.Master b/NzbDrone.Web/Views/Shared/Site.Master index 28969c07a..7e1ed0b1d 100644 --- a/NzbDrone.Web/Views/Shared/Site.Master +++ b/NzbDrone.Web/Views/Shared/Site.Master @@ -16,13 +16,8 @@ Released : 20100727 - + NZBDrone <% Html.Telerik().StyleSheetRegistrar().DefaultGroup(group => group.Add("telerik.common.css") @@ -67,7 +62,6 @@ Released : 20100727 - <% Html.Telerik().ScriptRegistrar().Scripts( c => c.Add("jquery-ui-1.8.5.custom.min.js") .Add("jquery.jgrowl.js")