aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-01-22 22:10:21 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-01-22 22:10:21 -0500
commit3b0b607836ad1ecd89579c72b019668bd4675a73 (patch)
treebd63b54865c5f76b3fc5b327204041b4e8d675fb /MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs
parent8570789373e954224188aa88f66695891bdc2e69 (diff)
trim logging
Diffstat (limited to 'MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs')
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs34
1 files changed, 31 insertions, 3 deletions
diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs
index 6a23a8497..8d8d7f6f7 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs
@@ -256,6 +256,25 @@ namespace MediaBrowser.Server.Implementations.HttpServer
}
}
+ private readonly Dictionary<string, int> _skipLogExtensions = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
+ {
+ {".js", 0},
+ {".css", 0},
+ {".woff", 0},
+ {".woff2", 0},
+ {".ttf", 0},
+ {".html", 0}
+ };
+
+ private bool EnableLogging(string url)
+ {
+ var parts = url.Split(new[] { '?' }, 2);
+
+ var extension = Path.GetExtension(parts[0]);
+
+ return string.IsNullOrWhiteSpace(extension) || !_skipLogExtensions.ContainsKey(extension);
+ }
+
/// <summary>
/// Overridable method that can be used to implement a custom hnandler
/// </summary>
@@ -271,6 +290,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer
var operationName = httpReq.OperationName;
var localPath = url.LocalPath;
+ var urlString = url.ToString();
+ var enableLog = EnableLogging(urlString);
+
+ if (enableLog)
+ {
+ LoggerUtils.LogRequest(_logger, urlString, httpReq.HttpMethod, httpReq.UserAgent);
+ }
+
if (string.Equals(localPath, "/mediabrowser/", StringComparison.OrdinalIgnoreCase) ||
string.Equals(localPath, "/emby/", StringComparison.OrdinalIgnoreCase))
{
@@ -333,15 +360,16 @@ namespace MediaBrowser.Server.Implementations.HttpServer
task.ContinueWith(x => httpRes.Close(), TaskContinuationOptions.OnlyOnRanToCompletion | TaskContinuationOptions.AttachedToParent);
//Matches Exceptions handled in HttpListenerBase.InitTask()
- var urlString = url.ToString();
-
task.ContinueWith(x =>
{
var statusCode = httpRes.StatusCode;
var duration = DateTime.Now - date;
- LoggerUtils.LogResponse(_logger, statusCode, urlString, remoteIp, duration);
+ if (enableLog)
+ {
+ LoggerUtils.LogResponse(_logger, statusCode, urlString, remoteIp, duration);
+ }
}, TaskContinuationOptions.None);
return task;