mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 05:47:14 -04:00
reduce size of logging messages
This commit is contained in:
parent
ac80f22686
commit
d4adc9799c
@ -1060,6 +1060,7 @@ namespace MediaBrowser.Api.Playback
|
||||
|
||||
//state.RunTimeTicks = recording.RunTimeTicks;
|
||||
state.ReadInputAtNativeFramerate = recording.RecordingInfo.Status == RecordingStatus.InProgress;
|
||||
state.SendInputOverStandardInput = recording.RecordingInfo.Status == RecordingStatus.InProgress;
|
||||
state.AudioSync = 1000;
|
||||
state.DeInterlace = true;
|
||||
}
|
||||
|
@ -111,9 +111,9 @@ namespace MediaBrowser.Api.WebSocket
|
||||
{
|
||||
var line = await reader.ReadLineAsync().ConfigureAwait(false);
|
||||
|
||||
if (line.IndexOf(", Info,", StringComparison.OrdinalIgnoreCase) != -1 ||
|
||||
line.IndexOf(", Warn,", StringComparison.OrdinalIgnoreCase) != -1 ||
|
||||
line.IndexOf(", Error,", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
if (line.IndexOf("Info", StringComparison.OrdinalIgnoreCase) != -1 ||
|
||||
line.IndexOf("Warn", StringComparison.OrdinalIgnoreCase) != -1 ||
|
||||
line.IndexOf("Error", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
{
|
||||
lines.Add(line);
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ namespace MediaBrowser.Common.Implementations.Logging
|
||||
var logFile = new FileTarget
|
||||
{
|
||||
FileName = path,
|
||||
Layout = "${longdate}, ${level}, ${logger}, ${message}"
|
||||
Layout = "${longdate} ${level} - ${logger}: ${message}"
|
||||
};
|
||||
|
||||
RemoveTarget("ApplicationLogFile");
|
||||
|
@ -253,13 +253,13 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
{
|
||||
try
|
||||
{
|
||||
LogHttpRequest(context, index);
|
||||
|
||||
var request = context.Request;
|
||||
|
||||
LogHttpRequest(request, index);
|
||||
|
||||
if (request.IsWebSocketRequest)
|
||||
{
|
||||
ProcessWebSocketRequest(context);
|
||||
await ProcessWebSocketRequest(context).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -299,7 +299,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
|
||||
if (EnableHttpRequestLogging)
|
||||
{
|
||||
LoggerUtils.LogResponse(_logger, context, url, endPoint, duration);
|
||||
LoggerUtils.LogResponse(_logger, context.Response, url, endPoint, duration);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -315,10 +315,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
/// <summary>
|
||||
/// Logs the HTTP request.
|
||||
/// </summary>
|
||||
/// <param name="ctx">The CTX.</param>
|
||||
private void LogHttpRequest(HttpListenerContext ctx, int index)
|
||||
/// <param name="request">The request.</param>
|
||||
/// <param name="index">The index.</param>
|
||||
private void LogHttpRequest(HttpListenerRequest request, int index)
|
||||
{
|
||||
var endpoint = ctx.Request.LocalEndPoint;
|
||||
var endpoint = request.LocalEndPoint;
|
||||
|
||||
if (endpoint != null)
|
||||
{
|
||||
@ -329,7 +330,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
|
||||
if (EnableHttpRequestLogging)
|
||||
{
|
||||
LoggerUtils.LogRequest(_logger, ctx, index);
|
||||
LoggerUtils.LogRequest(_logger, request, index);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,39 +8,44 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
{
|
||||
public static class LoggerUtils
|
||||
{
|
||||
public static void LogRequest(ILogger logger, HttpListenerContext ctx, int workerIndex)
|
||||
/// <summary>
|
||||
/// Logs the request.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <param name="workerIndex">Index of the worker.</param>
|
||||
public static void LogRequest(ILogger logger, HttpListenerRequest request, int workerIndex)
|
||||
{
|
||||
var log = new StringBuilder();
|
||||
|
||||
log.AppendLine("Url: " + ctx.Request.Url);
|
||||
log.AppendLine("Headers: " + string.Join(",", ctx.Request.Headers.AllKeys.Select(k => k + "=" + ctx.Request.Headers[k])));
|
||||
log.AppendLine("Ip: " + request.RemoteEndPoint + ". Headers: " + string.Join(",", request.Headers.AllKeys.Select(k => k + "=" + request.Headers[k])));
|
||||
|
||||
var type = ctx.Request.IsWebSocketRequest ? "Web Socket" : "HTTP " + ctx.Request.HttpMethod;
|
||||
var type = request.IsWebSocketRequest ? "Web Socket" : "HTTP " + request.HttpMethod;
|
||||
|
||||
logger.LogMultiline(type + " request received on worker " + workerIndex + " from " + ctx.Request.RemoteEndPoint, LogSeverity.Debug, log);
|
||||
logger.LogMultiline(type + " " + request.Url, LogSeverity.Debug, log);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs the response.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="ctx">The CTX.</param>
|
||||
/// <param name="response">The response.</param>
|
||||
/// <param name="url">The URL.</param>
|
||||
/// <param name="endPoint">The end point.</param>
|
||||
/// <param name="duration">The duration.</param>
|
||||
public static void LogResponse(ILogger logger, HttpListenerContext ctx, string url, IPEndPoint endPoint, TimeSpan duration)
|
||||
public static void LogResponse(ILogger logger, HttpListenerResponse response, string url, IPEndPoint endPoint, TimeSpan duration)
|
||||
{
|
||||
var statusCode = ctx.Response.StatusCode;
|
||||
var statusCode = response.StatusCode;
|
||||
|
||||
var log = new StringBuilder();
|
||||
|
||||
log.AppendLine(string.Format("Url: {0}", url));
|
||||
|
||||
log.AppendLine("Headers: " + string.Join(",", ctx.Response.Headers.AllKeys.Select(k => k + "=" + ctx.Response.Headers[k])));
|
||||
log.AppendLine("Headers: " + string.Join(",", response.Headers.AllKeys.Select(k => k + "=" + response.Headers[k])));
|
||||
|
||||
var responseTime = string.Format(". Response time: {0} ms", duration.TotalMilliseconds);
|
||||
|
||||
var msg = "Response code " + statusCode + " sent to " + endPoint + responseTime;
|
||||
var msg = "HTTP Response " + statusCode + " to " + endPoint + responseTime;
|
||||
|
||||
logger.LogMultiline(msg, LogSeverity.Debug, log);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user