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.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
{
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)
{

View File

@ -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();

View File

@ -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;
}
}

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));
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);
}
}
}

View File

@ -392,3 +392,9 @@ hr
#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();
if (lastError is HttpException)
{
Logger.WarnException("", lastError);
Logger.WarnException(lastError.Message, lastError);
}
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.jgrowl.js" />
<Content Include="Scripts\Notification.js" />
<Content Include="Views\Log\LogDetail.ascx" />
<Content Include="Views\Log\Index.aspx" />
<Content Include="Views\Series\Details.aspx" />
<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>>" %>
<%@ 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">
Logs
</asp:Content>
@ -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(
"<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))
.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();
%>
</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">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<style type="text/css">
div.jGrowl-notification
{
margin-left: 6px;
}
</style>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<asp:ContentPlaceHolder runat="server" ID="Scripts" />
<title>NZBDrone</title>
<%
Html.Telerik().StyleSheetRegistrar().DefaultGroup(group => group.Add("telerik.common.css")
@ -67,7 +62,6 @@ Released : 20100727
</div>
</div>
</div>
<!-- end #footer -->
<% Html.Telerik().ScriptRegistrar().Scripts(
c => c.Add("jquery-ui-1.8.5.custom.min.js")
.Add("jquery.jgrowl.js")