1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-10-30 07:22:35 +01:00

Updated log appearance.

This commit is contained in:
Keivan 2010-10-24 10:35:58 -07:00
parent fa0af257ff
commit c9bc063a9c
11 changed files with 81 additions and 33 deletions

View File

@ -131,5 +131,39 @@ namespace NzbDrone.Core.Test
Assert.AreEqual(ex.ToString(), logItem.ExceptionString); Assert.AreEqual(ex.ToString(), logItem.ExceptionString);
Assert.AreEqual(ex.Message, logItem.ExceptionMessage); 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<Log>());
Assert.Count(1, sonicRepo.All<Log>());
var logItem = sonicRepo.All<Log>().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);
}
} }
} }

View File

@ -97,7 +97,7 @@ namespace NzbDrone.Core
{ {
try 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 pc = new PerformanceCounter("Process", "Creating Process ID", Process.GetCurrentProcess().ProcessName);
var pid = (int)pc.NextValue(); var pid = (int)pc.NextValue();
var hostProcess = Process.GetProcessById(pid); var hostProcess = Process.GetProcessById(pid);
@ -109,7 +109,7 @@ namespace NzbDrone.Core
ShutDown(); ShutDown();
}); });
Logger.Info("Successfully Attached to host. Process ID: {0}", pid); Logger.Debug("Successfully Attached to host. Process ID: {0}", pid);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -33,6 +33,9 @@ namespace NzbDrone.Core.Instrumentation
if (logEvent.Exception != null) if (logEvent.Exception != null)
{ {
if (String.IsNullOrWhiteSpace(log.Message))
log.Message = logEvent.Exception.Message;
log.ExceptionMessage = logEvent.Exception.Message; log.ExceptionMessage = logEvent.Exception.Message;
log.ExceptionString = logEvent.Exception.ToString(); log.ExceptionString = logEvent.Exception.ToString();
log.ExceptionType = logEvent.Exception.GetType().ToString(); log.ExceptionType = logEvent.Exception.GetType().ToString();

View File

@ -69,7 +69,7 @@ namespace NzbDrone.Core.Model.Notification
{ {
if (Status == ProgressNotificationStatus.InProgress) 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; Status = ProgressNotificationStatus.Failed;
} }
} }

View File

@ -67,7 +67,7 @@ namespace NzbDrone.Core.Providers
{ {
_seriesSyncNotification.CurrentStatus = String.Format("Analysing Folder: {0}", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(new DirectoryInfo(seriesFolder).Name)); _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); var mappedSeries = _seriesProvider.MapPathToSeries(seriesFolder);
if (mappedSeries == null) if (mappedSeries == null)
@ -91,7 +91,7 @@ namespace NzbDrone.Core.Providers
} }
catch (Exception e) catch (Exception e)
{ {
Logger.ErrorException("", e); Logger.ErrorException(e.Message, e);
} }
_seriesSyncNotification.ProgressValue++; _seriesSyncNotification.ProgressValue++;
} }
@ -104,7 +104,7 @@ namespace NzbDrone.Core.Providers
} }
catch (Exception e) catch (Exception e)
{ {
Logger.ErrorException("", e); Logger.ErrorException(e.Message, e);
} }
} }
} }

View File

@ -392,3 +392,9 @@ hr
#footer a #footer a
{ {
} }
.t-grid .t-last {
border-bottom:1px solid #EEEEEE;
border-color:#EEEEEE;
}

View File

@ -54,11 +54,11 @@ namespace NzbDrone.Web
var lastError = Server.GetLastError(); var lastError = Server.GetLastError();
if (lastError is HttpException) if (lastError is HttpException)
{ {
Logger.WarnException("", lastError); Logger.WarnException(lastError.Message, lastError);
} }
else else
{ {
Logger.FatalException("", lastError); Logger.FatalException(lastError.Message, lastError);
} }
} }

View File

@ -213,7 +213,6 @@
<Content Include="Scripts\jquery-ui-1.8.5.custom.min.js" /> <Content Include="Scripts\jquery-ui-1.8.5.custom.min.js" />
<Content Include="Scripts\jquery.jgrowl.js" /> <Content Include="Scripts\jquery.jgrowl.js" />
<Content Include="Scripts\Notification.js" /> <Content Include="Scripts\Notification.js" />
<Content Include="Views\Log\LogDetail.ascx" />
<Content Include="Views\Log\Index.aspx" /> <Content Include="Views\Log\Index.aspx" />
<Content Include="Views\Series\Details.aspx" /> <Content Include="Views\Series\Details.aspx" />
<Content Include="Views\Series\EpisodeDetail.ascx" /> <Content Include="Views\Series\EpisodeDetail.ascx" />

View File

@ -1,6 +1,26 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<NzbDrone.Core.Instrumentation.Log>>" %> <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<NzbDrone.Core.Instrumentation.Log>>" %>
<%@ Import Namespace="Telerik.Web.Mvc.UI" %> <%@ Import Namespace="Telerik.Web.Mvc.UI" %>
<asp:Content ContentPlaceHolderID="Scripts" runat="server">
<script type="text/javascript">
function onRowDataBound(e) {
e.row.style.boarder = "";
if (e.dataItem.Level == 3) {
e.row.style.backgroundColor = "#FFD700";
}
else if (e.dataItem.Level == 4) {
e.row.style.backgroundColor = "#FF7500";
}
else if (e.dataItem.Level == 5) {
e.row.style.backgroundColor = "black";
e.row.style.Color = "white";
}
//e.row.style.color = 'blue';
}
</script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Logs Logs
</asp:Content> </asp:Content>
@ -19,13 +39,20 @@
columns.Bound(c => c.Message); columns.Bound(c => c.Message);
}) })
.DataBinding(dataBinding => dataBinding.Ajax().Select("_AjaxBinding", "Log")) .DataBinding(dataBinding => dataBinding.Ajax().Select("_AjaxBinding", "Log"))
//.DetailView(detailView => detailView.Template(e => Html.RenderPartial("LogDetail", e))) .DetailView(detailView => detailView.ClientTemplate(
"<div><#= Logger #></div>" +
"<div><#= ExceptionType #></div>" +
"<div><#= ExceptionMessage #></div>" +
"<div><#= ExceptionString #></div>"
))
.Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.Time).Descending()).Enabled(true)) .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)) .Pageable(c => c.PageSize(50).Position(GridPagerPosition.Both).Style(GridPagerStyles.PageInput | GridPagerStyles.NextPreviousAndNumeric))
//.Groupable() //.Groupable()
.Filterable() .Filterable()
.ClientEvents(c => c.OnRowDataBound("onRowDataBound"))
//.Groupable(grouping => grouping.Groups(groups => groups.Add(c => c.Time.Date)).Enabled(true)) //.Groupable(grouping => grouping.Groups(groups => groups.Add(c => c.Time.Date)).Enabled(true))
.Render(); .Render();
%> %>
</asp:Content> </asp:Content>

View File

@ -1,15 +0,0 @@
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<NzbDrone.Core.Instrumentation.Log>" %>
<ul>
<li>
<%: Model.Logger %>
</li>
<li>
<%: Model.ExceptionType%>
</li>
<li>
<%: Model.ExceptionMessage%>
</li>
<li>
<%: Model.ExceptionString%>
</li>
</ul>

View File

@ -16,13 +16,8 @@ Released : 20100727
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<style type="text/css">
div.jGrowl-notification
{
margin-left: 6px;
}
</style>
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" />
<asp:ContentPlaceHolder runat="server" ID="Scripts" />
<title>NZBDrone</title> <title>NZBDrone</title>
<% <%
Html.Telerik().StyleSheetRegistrar().DefaultGroup(group => group.Add("telerik.common.css") Html.Telerik().StyleSheetRegistrar().DefaultGroup(group => group.Add("telerik.common.css")
@ -67,7 +62,6 @@ Released : 20100727
</div> </div>
</div> </div>
</div> </div>
<!-- end #footer -->
<% Html.Telerik().ScriptRegistrar().Scripts( <% Html.Telerik().ScriptRegistrar().Scripts(
c => c.Add("jquery-ui-1.8.5.custom.min.js") c => c.Add("jquery-ui-1.8.5.custom.min.js")
.Add("jquery.jgrowl.js") .Add("jquery.jgrowl.js")