2014-07-09 00:46:11 +00:00
|
|
|
|
using MediaBrowser.Model.Logging;
|
2013-12-07 15:52:38 +00:00
|
|
|
|
using System;
|
2015-07-08 16:10:34 +00:00
|
|
|
|
using System.Globalization;
|
2013-12-07 15:52:38 +00:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Server.Implementations.HttpServer
|
|
|
|
|
{
|
|
|
|
|
public static class LoggerUtils
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Logs the response.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="logger">The logger.</param>
|
2014-07-09 00:46:11 +00:00
|
|
|
|
/// <param name="statusCode">The status code.</param>
|
2013-12-07 15:52:38 +00:00
|
|
|
|
/// <param name="url">The URL.</param>
|
|
|
|
|
/// <param name="endPoint">The end point.</param>
|
|
|
|
|
/// <param name="duration">The duration.</param>
|
2014-07-09 00:46:11 +00:00
|
|
|
|
public static void LogResponse(ILogger logger, int statusCode, string url, string endPoint, TimeSpan duration)
|
2013-12-07 15:52:38 +00:00
|
|
|
|
{
|
2015-10-28 19:40:38 +00:00
|
|
|
|
var durationMs = duration.TotalMilliseconds;
|
|
|
|
|
var logSuffix = durationMs >= 1000 ? "ms (slow)" : "ms";
|
|
|
|
|
|
|
|
|
|
logger.Info("HTTP Response {0} to {1}. Time: {2}{3}. {4}", statusCode, endPoint, Convert.ToInt32(durationMs).ToString(CultureInfo.InvariantCulture), logSuffix, url);
|
2013-12-07 15:52:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|