mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-12 13:16:19 +00:00
Use Microsoft.Extensions.Logging abstraction
This commit is contained in:
@@ -5,7 +5,7 @@ using System.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MediaBrowser.Model.Services;
|
||||
using System.Linq;
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
var rangeString = string.Format("bytes {0}-{1}/{2}", RangeStart, RangeEnd, TotalContentLength);
|
||||
Headers["Content-Range"] = rangeString;
|
||||
|
||||
Logger.Info("Setting range response values for {0}. RangeRequest: {1} Content-Length: {2}, Content-Range: {3}", Path, RangeHeader, lengthString, rangeString);
|
||||
Logger.LogInformation("Setting range response values for {0}. RangeRequest: {1} Content-Length: {2}, Content-Range: {3}", Path, RangeHeader, lengthString, rangeString);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -173,7 +173,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
|
||||
if (extension == null || !SkipLogExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
Logger.Debug("Transmit file {0}", path);
|
||||
Logger.LogDebug("Transmit file {0}", path);
|
||||
}
|
||||
|
||||
//var count = FileShare == FileShareMode.ReadWrite ? TotalContentLength : 0;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
@@ -252,11 +252,11 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
|
||||
if (logExceptionStackTrace)
|
||||
{
|
||||
_logger.ErrorException("Error processing request", ex);
|
||||
_logger.LogError("Error processing request", ex);
|
||||
}
|
||||
else if (logExceptionMessage)
|
||||
{
|
||||
_logger.Error(ex.Message);
|
||||
_logger.LogError(ex.Message);
|
||||
}
|
||||
|
||||
var httpRes = httpReq.Response;
|
||||
@@ -274,7 +274,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
}
|
||||
catch
|
||||
{
|
||||
//_logger.ErrorException("Error this.ProcessRequest(context)(Exception while writing error to the response)", errorEx);
|
||||
//_logger.LogError("Error this.ProcessRequest(context)(Exception while writing error to the response)", errorEx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,10 +320,10 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
|
||||
if (_listener != null)
|
||||
{
|
||||
_logger.Info("Stopping HttpListener...");
|
||||
_logger.LogInformation("Stopping HttpListener...");
|
||||
var task = _listener.Stop();
|
||||
Task.WaitAll(task);
|
||||
_logger.Info("HttpListener stopped");
|
||||
_logger.LogInformation("HttpListener stopped");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -713,7 +713,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
var pathParts = pathInfo.TrimStart('/').Split('/');
|
||||
if (pathParts.Length == 0)
|
||||
{
|
||||
_logger.Error("Path parts empty for PathInfo: {0}, Url: {1}", pathInfo, httpReq.RawUrl);
|
||||
_logger.LogError("Path parts empty for PathInfo: {0}, Url: {1}", pathInfo, httpReq.RawUrl);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -729,7 +729,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
};
|
||||
}
|
||||
|
||||
_logger.Error("Could not find handler for {0}", pathInfo);
|
||||
_logger.LogError("Could not find handler for {0}", pathInfo);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -783,7 +783,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
|
||||
ServiceController = new ServiceController();
|
||||
|
||||
_logger.Info("Calling ServiceStack AppHost.Init");
|
||||
_logger.LogInformation("Calling ServiceStack AppHost.Init");
|
||||
|
||||
var types = services.Select(r => r.GetType()).ToArray();
|
||||
|
||||
@@ -853,7 +853,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
//using (var reader = new StreamReader(stream))
|
||||
//{
|
||||
// var json = reader.ReadToEnd();
|
||||
// Logger.Info(json);
|
||||
// logger.LogInformation(json);
|
||||
// return _jsonSerializer.DeserializeFromString(json, type);
|
||||
//}
|
||||
return _jsonSerializer.DeserializeFromStreamAsync(stream, type);
|
||||
@@ -919,7 +919,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
//_logger.Debug("Websocket message received: {0}", result.MessageType);
|
||||
//_logger.LogDebug("Websocket message received: {0}", result.MessageType);
|
||||
|
||||
var tasks = _webSocketListeners.Select(i => Task.Run(async () =>
|
||||
{
|
||||
@@ -929,7 +929,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("{0} failed processing WebSocket message {1}", ex, i.GetType().Name, result.MessageType ?? string.Empty);
|
||||
_logger.LogError("{0} failed processing WebSocket message {1}", ex, i.GetType().Name, result.MessageType ?? string.Empty);
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -37,12 +37,12 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HttpResultFactory" /> class.
|
||||
/// </summary>
|
||||
public HttpResultFactory(ILogManager logManager, IFileSystem fileSystem, IJsonSerializer jsonSerializer, IBrotliCompressor brotliCompressor)
|
||||
public HttpResultFactory(ILoggerFactory loggerfactory, IFileSystem fileSystem, IJsonSerializer jsonSerializer, IBrotliCompressor brotliCompressor)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_jsonSerializer = jsonSerializer;
|
||||
_brotliCompressor = brotliCompressor;
|
||||
_logger = logManager.GetLogger("HttpResultFactory");
|
||||
_logger = loggerfactory.CreateLogger("HttpResultFactory");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using MediaBrowser.Model.Logging;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using MediaBrowser.Model.Services;
|
||||
@@ -11,7 +11,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
{
|
||||
if (headers == null)
|
||||
{
|
||||
logger.Info("{0} {1}. UserAgent: {2}", "HTTP " + method, url, userAgent ?? string.Empty);
|
||||
logger.LogInformation("{0} {1}. UserAgent: {2}", "HTTP " + method, url, userAgent ?? string.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -30,7 +30,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
index++;
|
||||
}
|
||||
|
||||
logger.Info("HTTP {0} {1}. {2}", method, url, headerText);
|
||||
logger.LogInformation("HTTP {0} {1}. {2}", method, url, headerText);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
|
||||
//var headerText = headers == null ? string.Empty : "Headers: " + string.Join(", ", headers.Where(i => i.Name.IndexOf("Access-", StringComparison.OrdinalIgnoreCase) == -1).Select(i => i.Name + "=" + i.Value).ToArray());
|
||||
var headerText = string.Empty;
|
||||
logger.Info("HTTP Response {0} to {1}. Time: {2}{3}. {4} {5}", statusCode, endPoint, Convert.ToInt32(durationMs).ToString(CultureInfo.InvariantCulture), logSuffix, url, headerText);
|
||||
logger.LogInformation("HTTP Response {0} to {1}. Time: {2}{3}. {4} {5}", statusCode, endPoint, Convert.ToInt32(durationMs).ToString(CultureInfo.InvariantCulture), logSuffix, url, headerText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using MediaBrowser.Model.Logging;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
@@ -226,4 +226,4 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
|
||||
public string StatusDescription { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using MediaBrowser.Model.Logging;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
@@ -34,7 +34,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
|
||||
if (exception != null)
|
||||
{
|
||||
_logger.ErrorException("Error processing request for {0}", exception, req.RawUrl);
|
||||
_logger.LogError("Error processing request for {0}", exception, req.RawUrl);
|
||||
|
||||
if (!string.IsNullOrEmpty(exception.Message))
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using MediaBrowser.Model.Logging;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Text;
|
||||
using MediaBrowser.Common.Events;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MediaBrowser.Model.Net;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using System;
|
||||
@@ -204,7 +204,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error processing web socket message", ex);
|
||||
_logger.LogError("Error processing web socket message", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user