adjust dlna logging

pull/702/head
Luke Pulverenti 10 years ago
parent f165811e5f
commit 8ae0822e13

@ -296,7 +296,7 @@ namespace MediaBrowser.Dlna.PlayTo
}
var post = AvCommands.BuildPost(command, service.ServiceType, url, dictionary);
await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, post, header)
await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, post, header: header)
.ConfigureAwait(false);
await Task.Delay(50).ConfigureAwait(false);
@ -466,7 +466,7 @@ namespace MediaBrowser.Dlna.PlayTo
throw new InvalidOperationException("Unable to find service");
}
var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType))
var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType), false)
.ConfigureAwait(false);
if (result == null || result.Document == null)
@ -499,7 +499,7 @@ namespace MediaBrowser.Dlna.PlayTo
throw new InvalidOperationException("Unable to find service");
}
var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType))
var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType), false)
.ConfigureAwait(false);
if (result == null || result.Document == null)
@ -521,7 +521,7 @@ namespace MediaBrowser.Dlna.PlayTo
if (service == null)
return null;
var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, AvCommands.BuildPost(command, service.ServiceType))
var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, AvCommands.BuildPost(command, service.ServiceType), false)
.ConfigureAwait(false);
if (result == null || result.Document == null)
@ -558,7 +558,7 @@ namespace MediaBrowser.Dlna.PlayTo
throw new InvalidOperationException("Unable to find service");
}
var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType))
var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType), false)
.ConfigureAwait(false);
if (result == null || result.Document == null)
@ -589,7 +589,7 @@ namespace MediaBrowser.Dlna.PlayTo
throw new InvalidOperationException("Unable to find service");
}
var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType))
var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType), false)
.ConfigureAwait(false);
if (result == null || result.Document == null)

@ -1,7 +1,7 @@
using System;
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Dlna.Common;
using System;
using System.Globalization;
using System.IO;
using System.Text;
@ -28,9 +28,10 @@ namespace MediaBrowser.Dlna.PlayTo
DeviceService service,
string command,
string postData,
bool logRequest = true,
string header = null)
{
var response = await PostSoapDataAsync(NormalizeServiceUrl(baseUrl, service.ControlUrl), "\"" + service.ServiceType + "#" + command + "\"", postData, header)
var response = await PostSoapDataAsync(NormalizeServiceUrl(baseUrl, service.ControlUrl), "\"" + service.ServiceType + "#" + command + "\"", postData, header, logRequest)
.ConfigureAwait(false);
using (var stream = response.Content)
@ -69,7 +70,6 @@ namespace MediaBrowser.Dlna.PlayTo
{
Url = url,
UserAgent = USERAGENT,
LogRequest = _config.GetDlnaConfiguration().EnableDebugLogging,
LogErrorResponseBody = true
};
@ -87,7 +87,6 @@ namespace MediaBrowser.Dlna.PlayTo
{
Url = url,
UserAgent = USERAGENT,
LogRequest = _config.GetDlnaConfiguration().EnableDebugLogging,
LogErrorResponseBody = true
};
@ -105,7 +104,8 @@ namespace MediaBrowser.Dlna.PlayTo
private Task<HttpResponseInfo> PostSoapDataAsync(string url,
string soapAction,
string postData,
string header = null)
string header,
bool logRequest)
{
if (!soapAction.StartsWith("\""))
soapAction = "\"" + soapAction + "\"";
@ -114,7 +114,7 @@ namespace MediaBrowser.Dlna.PlayTo
{
Url = url,
UserAgent = USERAGENT,
LogRequest = _config.GetDlnaConfiguration().EnableDebugLogging,
LogRequest = logRequest || _config.GetDlnaConfiguration().EnableDebugLogging,
LogErrorResponseBody = true
};

@ -27,14 +27,16 @@ namespace MediaBrowser.Dlna.Service
{
try
{
if (Config.GetDlnaConfiguration().EnableDebugLogging)
var enableDebugLogging = Config.GetDlnaConfiguration().EnableDebugLogging;
if (enableDebugLogging)
{
LogRequest(request);
}
var response = ProcessControlRequestInternal(request);
if (Config.GetDlnaConfiguration().EnableDebugLogging)
if (enableDebugLogging)
{
LogResponse(response);
}

@ -212,7 +212,9 @@ namespace MediaBrowser.Dlna.Ssdp
private void RespondToSearch(EndPoint endpoint, string deviceType)
{
if (_config.GetDlnaConfiguration().EnableDebugLogging)
var enableDebugLogging = _config.GetDlnaConfiguration().EnableDebugLogging;
if (enableDebugLogging)
{
_logger.Debug("RespondToSearch");
}
@ -238,7 +240,7 @@ namespace MediaBrowser.Dlna.Ssdp
SendDatagram(header, values, endpoint, new IPEndPoint(d.Address, 0), true, 1);
//SendDatagram(header, values, endpoint, null, true);
if (_config.GetDlnaConfiguration().EnableDebugLogging)
if (enableDebugLogging)
{
_logger.Debug("{1} - Responded to a {0} request to {2}", d.Type, endpoint, d.Address.ToString());
}
@ -316,7 +318,9 @@ namespace MediaBrowser.Dlna.Ssdp
var received = (byte[])result.AsyncState;
if (_config.GetDlnaConfiguration().EnableDebugLogging)
var enableDebugLogging = _config.GetDlnaConfiguration().EnableDebugLogging;
if (enableDebugLogging)
{
_logger.Debug(Encoding.ASCII.GetString(received));
}
@ -324,7 +328,7 @@ namespace MediaBrowser.Dlna.Ssdp
var args = SsdpHelper.ParseSsdpResponse(received);
args.EndPoint = endpoint;
if (_config.GetDlnaConfiguration().EnableDebugLogging)
if (enableDebugLogging)
{
var headerTexts = args.Headers.Select(i => string.Format("{0}={1}", i.Key, i.Value));
var headerText = string.Join(",", headerTexts.ToArray());
@ -399,17 +403,19 @@ namespace MediaBrowser.Dlna.Ssdp
private void NotifyAll()
{
if (_config.GetDlnaConfiguration().EnableDebugLogging)
var enableDebugLogging = _config.GetDlnaConfiguration().EnableDebugLogging;
if (enableDebugLogging)
{
_logger.Debug("Sending alive notifications");
}
foreach (var d in RegisteredDevices)
{
NotifyDevice(d, "alive", 1);
NotifyDevice(d, "alive", 1, enableDebugLogging);
}
}
private void NotifyDevice(UpnpDevice dev, string type, int sendCount)
private void NotifyDevice(UpnpDevice dev, string type, int sendCount, bool logMessage)
{
const string header = "NOTIFY * HTTP/1.1";
@ -424,7 +430,7 @@ namespace MediaBrowser.Dlna.Ssdp
values["NT"] = dev.Type;
values["USN"] = dev.USN;
if (_config.GetDlnaConfiguration().EnableDebugLogging)
if (logMessage)
{
_logger.Debug("{0} said {1}", dev.USN, type);
}
@ -457,7 +463,7 @@ namespace MediaBrowser.Dlna.Ssdp
foreach (var d in dl.ToList())
{
NotifyDevice(d, "byebye", 2);
NotifyDevice(d, "byebye", 2, true);
}
_logger.Debug("Unregistered mount {0}", uuid);
@ -468,13 +474,15 @@ namespace MediaBrowser.Dlna.Ssdp
private int _aliveNotifierIntervalMs;
private void ReloadAliveNotifier()
{
if (!_config.GetDlnaConfiguration().BlastAliveMessages)
var config = _config.GetDlnaConfiguration();
if (!config.BlastAliveMessages)
{
DisposeNotificationTimer();
return;
}
var intervalMs = _config.GetDlnaConfiguration().BlastAliveMessageIntervalSeconds * 1000;
var intervalMs = config.BlastAliveMessageIntervalSeconds * 1000;
if (_notificationTimer == null || _aliveNotifierIntervalMs != intervalMs)
{

Loading…
Cancel
Save