Use Microsoft.Extensions.Logging abstraction

This commit is contained in:
Bond_009
2018-12-13 14:18:25 +01:00
parent b0fd432126
commit 0f8b3c6347
310 changed files with 1421 additions and 2058 deletions

View File

@@ -15,7 +15,7 @@ using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Library;
using MediaBrowser.Model.Logging;
using Microsoft.Extensions.Logging;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Session;
using MediaBrowser.Model.Users;
@@ -248,7 +248,7 @@ namespace Emby.Server.Implementations.Session
}
catch (Exception ex)
{
_logger.ErrorException("Error updating user", ex);
_logger.LogError("Error updating user", ex);
}
}
}
@@ -528,7 +528,7 @@ namespace Emby.Server.Implementations.Session
foreach (var session in idle)
{
_logger.Debug("Session {0} has gone idle while playing", session.Id);
_logger.LogDebug("Session {0} has gone idle while playing", session.Id);
try
{
@@ -543,7 +543,7 @@ namespace Emby.Server.Implementations.Session
}
catch (Exception ex)
{
_logger.Debug("Error calling OnPlaybackStopped", ex);
_logger.LogDebug("Error calling OnPlaybackStopped", ex);
}
}
@@ -847,7 +847,7 @@ namespace Emby.Server.Implementations.Session
{
var msString = info.PositionTicks.HasValue ? (info.PositionTicks.Value / 10000).ToString(CultureInfo.InvariantCulture) : "unknown";
_logger.Info("Playback stopped reported by app {0} {1} playing {2}. Stopped at {3} ms",
_logger.LogInformation("Playback stopped reported by app {0} {1} playing {2}. Stopped at {3} ms",
session.Client,
session.ApplicationVersion,
info.Item.Name,
@@ -882,7 +882,7 @@ namespace Emby.Server.Implementations.Session
}
catch (Exception ex)
{
_logger.ErrorException("Error closing live stream", ex);
_logger.LogError("Error closing live stream", ex);
}
}
@@ -1095,7 +1095,7 @@ namespace Emby.Server.Implementations.Session
if (item == null)
{
_logger.Error("A non-existant item Id {0} was passed into TranslateItemForPlayback", id);
_logger.LogError("A non-existant item Id {0} was passed into TranslateItemForPlayback", id);
return new List<BaseItem>();
}
@@ -1151,7 +1151,7 @@ namespace Emby.Server.Implementations.Session
if (item == null)
{
_logger.Error("A non-existant item Id {0} was passed into TranslateItemForInstantMix", id);
_logger.LogError("A non-existant item Id {0} was passed into TranslateItemForInstantMix", id);
return new List<BaseItem>();
}
@@ -1222,7 +1222,7 @@ namespace Emby.Server.Implementations.Session
}
catch (Exception ex)
{
_logger.ErrorException("Error in SendRestartRequiredNotification.", ex);
_logger.LogError("Error in SendRestartRequiredNotification.", ex);
}
}, cancellationToken)).ToArray();
@@ -1249,7 +1249,7 @@ namespace Emby.Server.Implementations.Session
}
catch (Exception ex)
{
_logger.ErrorException("Error in SendServerShutdownNotification.", ex);
_logger.LogError("Error in SendServerShutdownNotification.", ex);
}
}, cancellationToken)).ToArray();
@@ -1266,7 +1266,7 @@ namespace Emby.Server.Implementations.Session
{
CheckDisposed();
_logger.Debug("Beginning SendServerRestartNotification");
_logger.LogDebug("Beginning SendServerRestartNotification");
var sessions = Sessions.ToList();
@@ -1278,7 +1278,7 @@ namespace Emby.Server.Implementations.Session
}
catch (Exception ex)
{
_logger.ErrorException("Error in SendServerRestartNotification.", ex);
_logger.LogError("Error in SendServerRestartNotification.", ex);
}
}, cancellationToken)).ToArray();
@@ -1462,7 +1462,7 @@ namespace Emby.Server.Implementations.Session
if (existing != null)
{
_logger.Info("Reissuing access token: " + existing.AccessToken);
_logger.LogInformation("Reissuing access token: " + existing.AccessToken);
return existing.AccessToken;
}
@@ -1481,7 +1481,7 @@ namespace Emby.Server.Implementations.Session
UserName = user.Name
};
_logger.Info("Creating new access token for user {0}", user.Id);
_logger.LogInformation("Creating new access token for user {0}", user.Id);
_authRepo.Create(newToken);
return newToken.AccessToken;
@@ -1513,7 +1513,7 @@ namespace Emby.Server.Implementations.Session
{
CheckDisposed();
_logger.Info("Logging out access token {0}", existing.AccessToken);
_logger.LogInformation("Logging out access token {0}", existing.AccessToken);
_authRepo.Delete(existing);
@@ -1529,7 +1529,7 @@ namespace Emby.Server.Implementations.Session
}
catch (Exception ex)
{
_logger.ErrorException("Error reporting session ended", ex);
_logger.LogError("Error reporting session ended", ex);
}
}
}
@@ -1599,7 +1599,7 @@ namespace Emby.Server.Implementations.Session
}
catch (Exception ex)
{
_logger.ErrorException("Error saving device capabilities", ex);
_logger.LogError("Error saving device capabilities", ex);
}
}
}
@@ -1692,7 +1692,7 @@ namespace Emby.Server.Implementations.Session
}
catch (Exception ex)
{
_logger.ErrorException("Error getting {0} image info", ex, type);
_logger.LogError("Error getting {0} image info", ex, type);
return null;
}
}
@@ -1818,7 +1818,7 @@ namespace Emby.Server.Implementations.Session
}
catch (Exception ex)
{
_logger.ErrorException("Error sending message", ex);
_logger.LogError("Error sending message", ex);
}
}, cancellationToken)).ToArray();
@@ -1840,7 +1840,7 @@ namespace Emby.Server.Implementations.Session
}
catch (Exception ex)
{
_logger.ErrorException("Error sending message", ex);
_logger.LogError("Error sending message", ex);
}
}, cancellationToken)).ToArray();
@@ -1862,7 +1862,7 @@ namespace Emby.Server.Implementations.Session
}
catch (Exception ex)
{
_logger.ErrorException("Error sending message", ex);
_logger.LogError("Error sending message", ex);
}
}, cancellationToken)).ToArray();
@@ -1886,7 +1886,7 @@ namespace Emby.Server.Implementations.Session
}
catch (Exception ex)
{
_logger.ErrorException("Error sending message", ex);
_logger.LogError("Error sending message", ex);
}
}, cancellationToken)).ToArray();

View File

@@ -1,7 +1,7 @@
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Logging;
using Microsoft.Extensions.Logging;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Session;
using System;
@@ -40,14 +40,14 @@ namespace Emby.Server.Implementations.Session
/// Initializes a new instance of the <see cref="SessionWebSocketListener" /> class.
/// </summary>
/// <param name="sessionManager">The session manager.</param>
/// <param name="logManager">The log manager.</param>
/// <param name="loggerFactory">The logger factory.</param>
/// <param name="json">The json.</param>
/// <param name="httpServer">The HTTP server.</param>
/// <param name="serverManager">The server manager.</param>
public SessionWebSocketListener(ISessionManager sessionManager, ILogManager logManager, IJsonSerializer json, IHttpServer httpServer)
public SessionWebSocketListener(ISessionManager sessionManager, ILoggerFactory loggerFactory, IJsonSerializer json, IHttpServer httpServer)
{
_sessionManager = sessionManager;
_logger = logManager.GetLogger(GetType().Name);
_logger = loggerFactory.CreateLogger(GetType().Name);
_json = json;
_httpServer = httpServer;
httpServer.WebSocketConnected += _serverManager_WebSocketConnected;
@@ -63,7 +63,7 @@ namespace Emby.Server.Implementations.Session
}
else
{
_logger.Warn("Unable to determine session based on url: {0}", e.Argument.Url);
_logger.LogWarning("Unable to determine session based on url: {0}", e.Argument.Url);
}
}

View File

@@ -1,7 +1,7 @@
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using Microsoft.Extensions.Logging;
using MediaBrowser.Model.Net;
using MediaBrowser.Model.Session;
using MediaBrowser.Model.System;