Fixed: Generic SignalR messages no longer treated as errors

This commit is contained in:
Mark McDowall 2015-04-28 07:28:05 -07:00
parent 4b7ee3cb9e
commit 918fcac2aa
2 changed files with 29 additions and 9 deletions

View File

@ -31,7 +31,7 @@ namespace NzbDrone.Common.Instrumentation
if (exception is NullReferenceException &&
exception.ToString().Contains("Microsoft.AspNet.SignalR.Transports.TransportHeartbeat.ProcessServerCommand"))
{
Logger.Warn("SignalR Heartbeat error.");
Logger.Warn("SignalR Heartbeat interupted");
return;
}

View File

@ -32,19 +32,39 @@ namespace NzbDrone.Host.Owin
public override void Write(string value)
{
if (value.ToLower().Contains("error") && !(value.ToLower().Contains("sqlite") || value.ToLower().Contains("\"errors\":null")))
{
_logger.Error(value);
}
else
{
_logger.Trace(value);
}
_logger.Log(GetLogLevel(value), value);
}
public override void Write(char value)
{
_logger.Trace(value);
}
private LogLevel GetLogLevel(string value)
{
var lower = value;
if (!lower.Contains("error"))
{
return LogLevel.Trace;
}
if (lower.Contains("sqlite"))
{
return LogLevel.Trace;
}
if (lower.Contains("\"errors\":null"))
{
return LogLevel.Trace;
}
if (lower.Contains("signalr") && lower.Contains("an operation was attempted on a nonexistent network connection"))
{
return LogLevel.Trace;
}
return LogLevel.Error;
}
}
}