trim logging

This commit is contained in:
Luke Pulverenti 2016-01-21 14:45:52 -05:00
parent 1c8b97866b
commit 9842749643
3 changed files with 34 additions and 30 deletions

View File

@ -53,7 +53,7 @@ namespace MediaBrowser.Providers.TV
}
catch (DirectoryNotFoundException)
{
_logger.Warn("Series files missing for series id {0}", seriesGroup.Key);
//_logger.Warn("Series files missing for series id {0}", seriesGroup.Key);
}
catch (Exception ex)
{

View File

@ -154,10 +154,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
return this;
}
private void OnRequestReceived(string localEndPoint)
{
}
/// <summary>
/// Starts the Web Service
/// </summary>
@ -177,7 +173,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
private IHttpListener GetListener()
{
return new WebSocketSharpListener(_logger, OnRequestReceived, CertificatePath);
return new WebSocketSharpListener(_logger, CertificatePath);
}
private void OnWebSocketConnecting(WebSocketConnectingEventArgs args)

View File

@ -7,6 +7,7 @@ using ServiceStack.Web;
using SocketHttpListener.Net;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -18,14 +19,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
private HttpListener _listener;
private readonly ILogger _logger;
private readonly Action<string> _endpointListener;
private readonly string _certificatePath;
public WebSocketSharpListener(ILogger logger, Action<string> endpointListener,
string certificatePath)
public WebSocketSharpListener(ILogger logger, string certificatePath)
{
_logger = logger;
_endpointListener = endpointListener;
_certificatePath = certificatePath;
}
@ -80,7 +78,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
{
var request = context.Request;
LogHttpRequest(request);
LogRequest(_logger, request);
if (request.IsWebSocketRequest)
{
@ -96,24 +94,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
return RequestHandler(httpReq, request.Url);
}
/// <summary>
/// Logs the HTTP request.
/// </summary>
/// <param name="request">The request.</param>
private void LogHttpRequest(HttpListenerRequest request)
{
var endpoint = request.LocalEndPoint;
if (endpoint != null)
{
var address = endpoint.ToString();
_endpointListener(address);
}
LogRequest(_logger, request);
}
private void ProcessWebSocketRequest(HttpListenerContext ctx)
{
try
@ -183,7 +163,35 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
/// <param name="request">The request.</param>
private static void LogRequest(ILogger logger, HttpListenerRequest request)
{
logger.Info("{0} {1}. UserAgent: {2}", (request.IsWebSocketRequest ? "WS" : "HTTP " + request.HttpMethod), request.Url, request.UserAgent ?? string.Empty);
var url = request.Url.ToString();
var extension = Path.GetExtension(url);
if (string.Equals(extension, ".js", StringComparison.OrdinalIgnoreCase))
{
return;
}
if (string.Equals(extension, ".css", StringComparison.OrdinalIgnoreCase))
{
return;
}
if (string.Equals(extension, ".woff", StringComparison.OrdinalIgnoreCase))
{
return;
}
if (string.Equals(extension, ".woff2", StringComparison.OrdinalIgnoreCase))
{
return;
}
if (string.Equals(extension, ".ttf", StringComparison.OrdinalIgnoreCase))
{
return;
}
if (string.Equals(extension, ".html", StringComparison.OrdinalIgnoreCase))
{
return;
}
logger.Info("{0} {1}. UserAgent: {2}", (request.IsWebSocketRequest ? "WS" : "HTTP " + request.HttpMethod), url, request.UserAgent ?? string.Empty);
}
private void HandleError(Exception ex, HttpListenerContext context)