Make Logger and LoggerFactory both protected in ApplicationHost

This commit is contained in:
Mark Monteiro 2020-03-03 23:53:48 +01:00
parent c49a12dd73
commit 6b06a9a919

View File

@ -118,9 +118,6 @@ namespace Emby.Server.Implementations
/// </summary> /// </summary>
public abstract class ApplicationHost : IServerApplicationHost, IDisposable public abstract class ApplicationHost : IServerApplicationHost, IDisposable
{ {
private readonly ILoggerFactory _loggerFactory;
private readonly ILogger _logger;
private SqliteUserRepository _userRepository; private SqliteUserRepository _userRepository;
private SqliteDisplayPreferencesRepository _displayPreferencesRepository; private SqliteDisplayPreferencesRepository _displayPreferencesRepository;
@ -168,6 +165,16 @@ namespace Emby.Server.Implementations
/// <inheritdoc /> /// <inheritdoc />
public bool IsShuttingDown { get; private set; } public bool IsShuttingDown { get; private set; }
/// <summary>
/// Gets the logger factory.
/// </summary>
protected ILoggerFactory LoggerFactory { get; }
/// <summary>
/// Gets the logger.
/// </summary>
protected ILogger Logger { get; }
private IPlugin[] _plugins; private IPlugin[] _plugins;
/// <summary> /// <summary>
@ -360,8 +367,6 @@ namespace Emby.Server.Implementations
INetworkManager networkManager, INetworkManager networkManager,
IConfiguration configuration) IConfiguration configuration)
{ {
_loggerFactory = loggerFactory;
_logger = _loggerFactory.CreateLogger("App");
_configuration = configuration; _configuration = configuration;
XmlSerializer = new MyXmlSerializer(); XmlSerializer = new MyXmlSerializer();
@ -370,9 +375,11 @@ namespace Emby.Server.Implementations
networkManager.LocalSubnetsFn = GetConfiguredLocalSubnets; networkManager.LocalSubnetsFn = GetConfiguredLocalSubnets;
ApplicationPaths = applicationPaths; ApplicationPaths = applicationPaths;
LoggerFactory = loggerFactory;
FileSystemManager = fileSystem; FileSystemManager = fileSystem;
ConfigurationManager = new ServerConfigurationManager(ApplicationPaths, _loggerFactory, XmlSerializer, FileSystemManager); Logger = LoggerFactory.CreateLogger("App");
ConfigurationManager = new ServerConfigurationManager(ApplicationPaths, LoggerFactory, XmlSerializer, FileSystemManager);
StartupOptions = options; StartupOptions = options;
@ -441,7 +448,7 @@ namespace Emby.Server.Implementations
{ {
if (_deviceId == null) if (_deviceId == null)
{ {
_deviceId = new DeviceId(ApplicationPaths, _loggerFactory); _deviceId = new DeviceId(ApplicationPaths, LoggerFactory);
} }
return _deviceId.Value; return _deviceId.Value;
@ -479,12 +486,12 @@ namespace Emby.Server.Implementations
{ {
try try
{ {
_logger.LogDebug("Creating instance of {Type}", type); Logger.LogDebug("Creating instance of {Type}", type);
return ActivatorUtilities.CreateInstance(ServiceProvider, type); return ActivatorUtilities.CreateInstance(ServiceProvider, type);
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Error creating {Type}", type); Logger.LogError(ex, "Error creating {Type}", type);
return null; return null;
} }
} }
@ -535,7 +542,7 @@ namespace Emby.Server.Implementations
/// <returns><see cref="Task" />.</returns> /// <returns><see cref="Task" />.</returns>
public async Task RunStartupTasksAsync() public async Task RunStartupTasksAsync()
{ {
_logger.LogInformation("Running startup tasks"); Logger.LogInformation("Running startup tasks");
Resolve<ITaskManager>().AddTasks(GetExports<IScheduledTask>(false)); Resolve<ITaskManager>().AddTasks(GetExports<IScheduledTask>(false));
@ -543,21 +550,21 @@ namespace Emby.Server.Implementations
MediaEncoder.SetFFmpegPath(); MediaEncoder.SetFFmpegPath();
_logger.LogInformation("ServerId: {0}", SystemId); Logger.LogInformation("ServerId: {0}", SystemId);
var entryPoints = GetExports<IServerEntryPoint>(); var entryPoints = GetExports<IServerEntryPoint>();
var stopWatch = new Stopwatch(); var stopWatch = new Stopwatch();
stopWatch.Start(); stopWatch.Start();
await Task.WhenAll(StartEntryPoints(entryPoints, true)).ConfigureAwait(false); await Task.WhenAll(StartEntryPoints(entryPoints, true)).ConfigureAwait(false);
_logger.LogInformation("Executed all pre-startup entry points in {Elapsed:g}", stopWatch.Elapsed); Logger.LogInformation("Executed all pre-startup entry points in {Elapsed:g}", stopWatch.Elapsed);
_logger.LogInformation("Core startup complete"); Logger.LogInformation("Core startup complete");
HttpServer.GlobalResponse = null; HttpServer.GlobalResponse = null;
stopWatch.Restart(); stopWatch.Restart();
await Task.WhenAll(StartEntryPoints(entryPoints, false)).ConfigureAwait(false); await Task.WhenAll(StartEntryPoints(entryPoints, false)).ConfigureAwait(false);
_logger.LogInformation("Executed all post-startup entry points in {Elapsed:g}", stopWatch.Elapsed); Logger.LogInformation("Executed all post-startup entry points in {Elapsed:g}", stopWatch.Elapsed);
stopWatch.Stop(); stopWatch.Stop();
} }
@ -570,7 +577,7 @@ namespace Emby.Server.Implementations
continue; continue;
} }
_logger.LogDebug("Starting entry point {Type}", entryPoint.GetType()); Logger.LogDebug("Starting entry point {Type}", entryPoint.GetType());
yield return entryPoint.RunAsync(); yield return entryPoint.RunAsync();
} }
@ -604,7 +611,7 @@ namespace Emby.Server.Implementations
plugin.Version)); plugin.Version));
} }
_logger.LogInformation("Plugins: {Plugins}", pluginBuilder.ToString()); Logger.LogInformation("Plugins: {Plugins}", pluginBuilder.ToString());
} }
DiscoverTypes(); DiscoverTypes();
@ -641,7 +648,7 @@ namespace Emby.Server.Implementations
var response = context.Response; var response = context.Response;
var localPath = context.Request.Path.ToString(); var localPath = context.Request.Path.ToString();
var req = new WebSocketSharpRequest(request, response, request.Path, _loggerFactory.CreateLogger<WebSocketSharpRequest>()); var req = new WebSocketSharpRequest(request, response, request.Path, LoggerFactory.CreateLogger<WebSocketSharpRequest>());
await HttpServer.RequestHandler(req, request.GetDisplayUrl(), request.Host.ToString(), localPath, context.RequestAborted).ConfigureAwait(false); await HttpServer.RequestHandler(req, request.GetDisplayUrl(), request.Host.ToString(), localPath, context.RequestAborted).ConfigureAwait(false);
} }
@ -662,14 +669,14 @@ namespace Emby.Server.Implementations
serviceCollection.AddSingleton(JsonSerializer); serviceCollection.AddSingleton(JsonSerializer);
// TODO: Support for injecting ILogger should be deprecated in favour of ILogger<T> and this removed // TODO: Support for injecting ILogger should be deprecated in favour of ILogger<T> and this removed
serviceCollection.AddSingleton<ILogger>(_logger); serviceCollection.AddSingleton<ILogger>(Logger);
serviceCollection.AddSingleton(FileSystemManager); serviceCollection.AddSingleton(FileSystemManager);
serviceCollection.AddSingleton<TvDbClientManager>(); serviceCollection.AddSingleton<TvDbClientManager>();
HttpClient = new HttpClientManager.HttpClientManager( HttpClient = new HttpClientManager.HttpClientManager(
ApplicationPaths, ApplicationPaths,
_loggerFactory.CreateLogger<HttpClientManager.HttpClientManager>(), LoggerFactory.CreateLogger<HttpClientManager.HttpClientManager>(),
FileSystemManager, FileSystemManager,
() => ApplicationUserAgent); () => ApplicationUserAgent);
serviceCollection.AddSingleton(HttpClient); serviceCollection.AddSingleton(HttpClient);
@ -679,7 +686,7 @@ namespace Emby.Server.Implementations
IsoManager = new IsoManager(); IsoManager = new IsoManager();
serviceCollection.AddSingleton(IsoManager); serviceCollection.AddSingleton(IsoManager);
TaskManager = new TaskManager(ApplicationPaths, JsonSerializer, _loggerFactory, FileSystemManager); TaskManager = new TaskManager(ApplicationPaths, JsonSerializer, LoggerFactory, FileSystemManager);
serviceCollection.AddSingleton(TaskManager); serviceCollection.AddSingleton(TaskManager);
serviceCollection.AddSingleton(XmlSerializer); serviceCollection.AddSingleton(XmlSerializer);
@ -706,22 +713,22 @@ namespace Emby.Server.Implementations
serviceCollection.AddSingleton(ServerConfigurationManager); serviceCollection.AddSingleton(ServerConfigurationManager);
LocalizationManager = new LocalizationManager(ServerConfigurationManager, JsonSerializer, _loggerFactory.CreateLogger<LocalizationManager>()); LocalizationManager = new LocalizationManager(ServerConfigurationManager, JsonSerializer, LoggerFactory.CreateLogger<LocalizationManager>());
await LocalizationManager.LoadAll().ConfigureAwait(false); await LocalizationManager.LoadAll().ConfigureAwait(false);
serviceCollection.AddSingleton<ILocalizationManager>(LocalizationManager); serviceCollection.AddSingleton<ILocalizationManager>(LocalizationManager);
serviceCollection.AddSingleton<IBlurayExaminer>(new BdInfoExaminer(FileSystemManager)); serviceCollection.AddSingleton<IBlurayExaminer>(new BdInfoExaminer(FileSystemManager));
UserDataManager = new UserDataManager(_loggerFactory, ServerConfigurationManager, () => UserManager); UserDataManager = new UserDataManager(LoggerFactory, ServerConfigurationManager, () => UserManager);
serviceCollection.AddSingleton(UserDataManager); serviceCollection.AddSingleton(UserDataManager);
_displayPreferencesRepository = new SqliteDisplayPreferencesRepository( _displayPreferencesRepository = new SqliteDisplayPreferencesRepository(
_loggerFactory.CreateLogger<SqliteDisplayPreferencesRepository>(), LoggerFactory.CreateLogger<SqliteDisplayPreferencesRepository>(),
ApplicationPaths, ApplicationPaths,
FileSystemManager); FileSystemManager);
serviceCollection.AddSingleton<IDisplayPreferencesRepository>(_displayPreferencesRepository); serviceCollection.AddSingleton<IDisplayPreferencesRepository>(_displayPreferencesRepository);
ItemRepository = new SqliteItemRepository(ServerConfigurationManager, this, _loggerFactory.CreateLogger<SqliteItemRepository>(), LocalizationManager); ItemRepository = new SqliteItemRepository(ServerConfigurationManager, this, LoggerFactory.CreateLogger<SqliteItemRepository>(), LocalizationManager);
serviceCollection.AddSingleton<IItemRepository>(ItemRepository); serviceCollection.AddSingleton<IItemRepository>(ItemRepository);
AuthenticationRepository = GetAuthenticationRepository(); AuthenticationRepository = GetAuthenticationRepository();
@ -730,7 +737,7 @@ namespace Emby.Server.Implementations
_userRepository = GetUserRepository(); _userRepository = GetUserRepository();
UserManager = new UserManager( UserManager = new UserManager(
_loggerFactory.CreateLogger<UserManager>(), LoggerFactory.CreateLogger<UserManager>(),
_userRepository, _userRepository,
XmlSerializer, XmlSerializer,
NetworkManager, NetworkManager,
@ -744,7 +751,7 @@ namespace Emby.Server.Implementations
serviceCollection.AddSingleton(UserManager); serviceCollection.AddSingleton(UserManager);
MediaEncoder = new MediaBrowser.MediaEncoding.Encoder.MediaEncoder( MediaEncoder = new MediaBrowser.MediaEncoding.Encoder.MediaEncoder(
_loggerFactory.CreateLogger<MediaBrowser.MediaEncoding.Encoder.MediaEncoder>(), LoggerFactory.CreateLogger<MediaBrowser.MediaEncoding.Encoder.MediaEncoder>(),
ServerConfigurationManager, ServerConfigurationManager,
FileSystemManager, FileSystemManager,
ProcessFactory, ProcessFactory,
@ -754,23 +761,23 @@ namespace Emby.Server.Implementations
StartupOptions.FFmpegPath); StartupOptions.FFmpegPath);
serviceCollection.AddSingleton(MediaEncoder); serviceCollection.AddSingleton(MediaEncoder);
LibraryManager = new LibraryManager(this, _loggerFactory, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager, () => UserViewManager, MediaEncoder); LibraryManager = new LibraryManager(this, LoggerFactory, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager, () => UserViewManager, MediaEncoder);
serviceCollection.AddSingleton(LibraryManager); serviceCollection.AddSingleton(LibraryManager);
var musicManager = new MusicManager(LibraryManager); var musicManager = new MusicManager(LibraryManager);
serviceCollection.AddSingleton<IMusicManager>(musicManager); serviceCollection.AddSingleton<IMusicManager>(musicManager);
LibraryMonitor = new LibraryMonitor(_loggerFactory, LibraryManager, ServerConfigurationManager, FileSystemManager); LibraryMonitor = new LibraryMonitor(LoggerFactory, LibraryManager, ServerConfigurationManager, FileSystemManager);
serviceCollection.AddSingleton(LibraryMonitor); serviceCollection.AddSingleton(LibraryMonitor);
serviceCollection.AddSingleton<ISearchEngine>(new SearchEngine(_loggerFactory, LibraryManager, UserManager)); serviceCollection.AddSingleton<ISearchEngine>(new SearchEngine(LoggerFactory, LibraryManager, UserManager));
CertificateInfo = GetCertificateInfo(true); CertificateInfo = GetCertificateInfo(true);
Certificate = GetCertificate(CertificateInfo); Certificate = GetCertificate(CertificateInfo);
HttpServer = new HttpListenerHost( HttpServer = new HttpListenerHost(
this, this,
_loggerFactory.CreateLogger<HttpListenerHost>(), LoggerFactory.CreateLogger<HttpListenerHost>(),
ServerConfigurationManager, ServerConfigurationManager,
_configuration, _configuration,
NetworkManager, NetworkManager,
@ -783,7 +790,7 @@ namespace Emby.Server.Implementations
serviceCollection.AddSingleton(HttpServer); serviceCollection.AddSingleton(HttpServer);
ImageProcessor = new ImageProcessor(_loggerFactory.CreateLogger<ImageProcessor>(), ServerConfigurationManager.ApplicationPaths, FileSystemManager, ImageEncoder, () => LibraryManager, () => MediaEncoder); ImageProcessor = new ImageProcessor(LoggerFactory.CreateLogger<ImageProcessor>(), ServerConfigurationManager.ApplicationPaths, FileSystemManager, ImageEncoder, () => LibraryManager, () => MediaEncoder);
serviceCollection.AddSingleton(ImageProcessor); serviceCollection.AddSingleton(ImageProcessor);
TVSeriesManager = new TVSeriesManager(UserManager, UserDataManager, LibraryManager, ServerConfigurationManager); TVSeriesManager = new TVSeriesManager(UserManager, UserDataManager, LibraryManager, ServerConfigurationManager);
@ -792,23 +799,23 @@ namespace Emby.Server.Implementations
DeviceManager = new DeviceManager(AuthenticationRepository, JsonSerializer, LibraryManager, LocalizationManager, UserManager, FileSystemManager, LibraryMonitor, ServerConfigurationManager); DeviceManager = new DeviceManager(AuthenticationRepository, JsonSerializer, LibraryManager, LocalizationManager, UserManager, FileSystemManager, LibraryMonitor, ServerConfigurationManager);
serviceCollection.AddSingleton(DeviceManager); serviceCollection.AddSingleton(DeviceManager);
MediaSourceManager = new MediaSourceManager(ItemRepository, ApplicationPaths, LocalizationManager, UserManager, LibraryManager, _loggerFactory, JsonSerializer, FileSystemManager, UserDataManager, () => MediaEncoder); MediaSourceManager = new MediaSourceManager(ItemRepository, ApplicationPaths, LocalizationManager, UserManager, LibraryManager, LoggerFactory, JsonSerializer, FileSystemManager, UserDataManager, () => MediaEncoder);
serviceCollection.AddSingleton(MediaSourceManager); serviceCollection.AddSingleton(MediaSourceManager);
SubtitleManager = new SubtitleManager(_loggerFactory, FileSystemManager, LibraryMonitor, MediaSourceManager, LocalizationManager); SubtitleManager = new SubtitleManager(LoggerFactory, FileSystemManager, LibraryMonitor, MediaSourceManager, LocalizationManager);
serviceCollection.AddSingleton(SubtitleManager); serviceCollection.AddSingleton(SubtitleManager);
ProviderManager = new ProviderManager(HttpClient, SubtitleManager, ServerConfigurationManager, LibraryMonitor, _loggerFactory, FileSystemManager, ApplicationPaths, () => LibraryManager, JsonSerializer); ProviderManager = new ProviderManager(HttpClient, SubtitleManager, ServerConfigurationManager, LibraryMonitor, LoggerFactory, FileSystemManager, ApplicationPaths, () => LibraryManager, JsonSerializer);
serviceCollection.AddSingleton(ProviderManager); serviceCollection.AddSingleton(ProviderManager);
DtoService = new DtoService(_loggerFactory, LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ProviderManager, this, () => MediaSourceManager, () => LiveTvManager); DtoService = new DtoService(LoggerFactory, LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ProviderManager, this, () => MediaSourceManager, () => LiveTvManager);
serviceCollection.AddSingleton(DtoService); serviceCollection.AddSingleton(DtoService);
ChannelManager = new ChannelManager(UserManager, DtoService, LibraryManager, _loggerFactory, ServerConfigurationManager, FileSystemManager, UserDataManager, JsonSerializer, ProviderManager); ChannelManager = new ChannelManager(UserManager, DtoService, LibraryManager, LoggerFactory, ServerConfigurationManager, FileSystemManager, UserDataManager, JsonSerializer, ProviderManager);
serviceCollection.AddSingleton(ChannelManager); serviceCollection.AddSingleton(ChannelManager);
SessionManager = new SessionManager( SessionManager = new SessionManager(
_loggerFactory.CreateLogger<SessionManager>(), LoggerFactory.CreateLogger<SessionManager>(),
UserDataManager, UserDataManager,
LibraryManager, LibraryManager,
UserManager, UserManager,
@ -822,47 +829,47 @@ namespace Emby.Server.Implementations
serviceCollection.AddSingleton(SessionManager); serviceCollection.AddSingleton(SessionManager);
serviceCollection.AddSingleton<IDlnaManager>( serviceCollection.AddSingleton<IDlnaManager>(
new DlnaManager(XmlSerializer, FileSystemManager, ApplicationPaths, _loggerFactory, JsonSerializer, this)); new DlnaManager(XmlSerializer, FileSystemManager, ApplicationPaths, LoggerFactory, JsonSerializer, this));
CollectionManager = new CollectionManager(LibraryManager, ApplicationPaths, LocalizationManager, FileSystemManager, LibraryMonitor, _loggerFactory, ProviderManager); CollectionManager = new CollectionManager(LibraryManager, ApplicationPaths, LocalizationManager, FileSystemManager, LibraryMonitor, LoggerFactory, ProviderManager);
serviceCollection.AddSingleton(CollectionManager); serviceCollection.AddSingleton(CollectionManager);
serviceCollection.AddSingleton(typeof(IPlaylistManager), typeof(PlaylistManager)); serviceCollection.AddSingleton(typeof(IPlaylistManager), typeof(PlaylistManager));
LiveTvManager = new LiveTvManager(this, ServerConfigurationManager, _loggerFactory, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, LocalizationManager, JsonSerializer, FileSystemManager, () => ChannelManager); LiveTvManager = new LiveTvManager(this, ServerConfigurationManager, LoggerFactory, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, LocalizationManager, JsonSerializer, FileSystemManager, () => ChannelManager);
serviceCollection.AddSingleton(LiveTvManager); serviceCollection.AddSingleton(LiveTvManager);
UserViewManager = new UserViewManager(LibraryManager, LocalizationManager, UserManager, ChannelManager, LiveTvManager, ServerConfigurationManager); UserViewManager = new UserViewManager(LibraryManager, LocalizationManager, UserManager, ChannelManager, LiveTvManager, ServerConfigurationManager);
serviceCollection.AddSingleton(UserViewManager); serviceCollection.AddSingleton(UserViewManager);
NotificationManager = new NotificationManager( NotificationManager = new NotificationManager(
_loggerFactory.CreateLogger<NotificationManager>(), LoggerFactory.CreateLogger<NotificationManager>(),
UserManager, UserManager,
ServerConfigurationManager); ServerConfigurationManager);
serviceCollection.AddSingleton(NotificationManager); serviceCollection.AddSingleton(NotificationManager);
serviceCollection.AddSingleton<IDeviceDiscovery>(new DeviceDiscovery(ServerConfigurationManager)); serviceCollection.AddSingleton<IDeviceDiscovery>(new DeviceDiscovery(ServerConfigurationManager));
ChapterManager = new ChapterManager(LibraryManager, _loggerFactory, ServerConfigurationManager, ItemRepository); ChapterManager = new ChapterManager(LibraryManager, LoggerFactory, ServerConfigurationManager, ItemRepository);
serviceCollection.AddSingleton(ChapterManager); serviceCollection.AddSingleton(ChapterManager);
EncodingManager = new MediaEncoder.EncodingManager(FileSystemManager, _loggerFactory, MediaEncoder, ChapterManager, LibraryManager); EncodingManager = new MediaEncoder.EncodingManager(FileSystemManager, LoggerFactory, MediaEncoder, ChapterManager, LibraryManager);
serviceCollection.AddSingleton(EncodingManager); serviceCollection.AddSingleton(EncodingManager);
var activityLogRepo = GetActivityLogRepository(); var activityLogRepo = GetActivityLogRepository();
serviceCollection.AddSingleton(activityLogRepo); serviceCollection.AddSingleton(activityLogRepo);
serviceCollection.AddSingleton<IActivityManager>(new ActivityManager(_loggerFactory, activityLogRepo, UserManager)); serviceCollection.AddSingleton<IActivityManager>(new ActivityManager(LoggerFactory, activityLogRepo, UserManager));
var authContext = new AuthorizationContext(AuthenticationRepository, UserManager); var authContext = new AuthorizationContext(AuthenticationRepository, UserManager);
serviceCollection.AddSingleton<IAuthorizationContext>(authContext); serviceCollection.AddSingleton<IAuthorizationContext>(authContext);
serviceCollection.AddSingleton<ISessionContext>(new SessionContext(UserManager, authContext, SessionManager)); serviceCollection.AddSingleton<ISessionContext>(new SessionContext(UserManager, authContext, SessionManager));
AuthService = new AuthService(_loggerFactory.CreateLogger<AuthService>(), authContext, ServerConfigurationManager, SessionManager, NetworkManager); AuthService = new AuthService(LoggerFactory.CreateLogger<AuthService>(), authContext, ServerConfigurationManager, SessionManager, NetworkManager);
serviceCollection.AddSingleton(AuthService); serviceCollection.AddSingleton(AuthService);
SubtitleEncoder = new MediaBrowser.MediaEncoding.Subtitles.SubtitleEncoder( SubtitleEncoder = new MediaBrowser.MediaEncoding.Subtitles.SubtitleEncoder(
LibraryManager, LibraryManager,
_loggerFactory.CreateLogger<MediaBrowser.MediaEncoding.Subtitles.SubtitleEncoder>(), LoggerFactory.CreateLogger<MediaBrowser.MediaEncoding.Subtitles.SubtitleEncoder>(),
ApplicationPaths, ApplicationPaths,
FileSystemManager, FileSystemManager,
MediaEncoder, MediaEncoder,
@ -878,7 +885,7 @@ namespace Emby.Server.Implementations
_displayPreferencesRepository.Initialize(); _displayPreferencesRepository.Initialize();
var userDataRepo = new SqliteUserDataRepository(_loggerFactory.CreateLogger<SqliteUserDataRepository>(), ApplicationPaths); var userDataRepo = new SqliteUserDataRepository(LoggerFactory.CreateLogger<SqliteUserDataRepository>(), ApplicationPaths);
SetStaticProperties(); SetStaticProperties();
@ -930,7 +937,7 @@ namespace Emby.Server.Implementations
// localCert.PrivateKey = PrivateKey.CreateFromFile(pvk_file).RSA; // localCert.PrivateKey = PrivateKey.CreateFromFile(pvk_file).RSA;
if (!localCert.HasPrivateKey) if (!localCert.HasPrivateKey)
{ {
_logger.LogError("No private key included in SSL cert {CertificateLocation}.", certificateLocation); Logger.LogError("No private key included in SSL cert {CertificateLocation}.", certificateLocation);
return null; return null;
} }
@ -938,7 +945,7 @@ namespace Emby.Server.Implementations
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Error loading cert from {CertificateLocation}", certificateLocation); Logger.LogError(ex, "Error loading cert from {CertificateLocation}", certificateLocation);
return null; return null;
} }
} }
@ -950,7 +957,7 @@ namespace Emby.Server.Implementations
private SqliteUserRepository GetUserRepository() private SqliteUserRepository GetUserRepository()
{ {
var repo = new SqliteUserRepository( var repo = new SqliteUserRepository(
_loggerFactory.CreateLogger<SqliteUserRepository>(), LoggerFactory.CreateLogger<SqliteUserRepository>(),
ApplicationPaths); ApplicationPaths);
repo.Initialize(); repo.Initialize();
@ -960,7 +967,7 @@ namespace Emby.Server.Implementations
private IAuthenticationRepository GetAuthenticationRepository() private IAuthenticationRepository GetAuthenticationRepository()
{ {
var repo = new AuthenticationRepository(_loggerFactory, ServerConfigurationManager); var repo = new AuthenticationRepository(LoggerFactory, ServerConfigurationManager);
repo.Initialize(); repo.Initialize();
@ -969,7 +976,7 @@ namespace Emby.Server.Implementations
private IActivityRepository GetActivityLogRepository() private IActivityRepository GetActivityLogRepository()
{ {
var repo = new ActivityRepository(_loggerFactory, ServerConfigurationManager.ApplicationPaths, FileSystemManager); var repo = new ActivityRepository(LoggerFactory, ServerConfigurationManager.ApplicationPaths, FileSystemManager);
repo.Initialize(); repo.Initialize();
@ -984,7 +991,7 @@ namespace Emby.Server.Implementations
ItemRepository.ImageProcessor = ImageProcessor; ItemRepository.ImageProcessor = ImageProcessor;
// For now there's no real way to inject these properly // For now there's no real way to inject these properly
BaseItem.Logger = _loggerFactory.CreateLogger("BaseItem"); BaseItem.Logger = LoggerFactory.CreateLogger("BaseItem");
BaseItem.ConfigurationManager = ServerConfigurationManager; BaseItem.ConfigurationManager = ServerConfigurationManager;
BaseItem.LibraryManager = LibraryManager; BaseItem.LibraryManager = LibraryManager;
BaseItem.ProviderManager = ProviderManager; BaseItem.ProviderManager = ProviderManager;
@ -1117,7 +1124,7 @@ namespace Emby.Server.Implementations
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Error getting plugin Id from {PluginName}.", plugin.GetType().FullName); Logger.LogError(ex, "Error getting plugin Id from {PluginName}.", plugin.GetType().FullName);
} }
} }
@ -1128,7 +1135,7 @@ namespace Emby.Server.Implementations
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Error loading plugin {PluginName}", plugin.GetType().FullName); Logger.LogError(ex, "Error loading plugin {PluginName}", plugin.GetType().FullName);
return null; return null;
} }
@ -1140,7 +1147,7 @@ namespace Emby.Server.Implementations
/// </summary> /// </summary>
protected void DiscoverTypes() protected void DiscoverTypes()
{ {
_logger.LogInformation("Loading assemblies"); Logger.LogInformation("Loading assemblies");
_allConcreteTypes = GetTypes(GetComposablePartAssemblies()).ToArray(); _allConcreteTypes = GetTypes(GetComposablePartAssemblies()).ToArray();
} }
@ -1156,7 +1163,7 @@ namespace Emby.Server.Implementations
} }
catch (TypeLoadException ex) catch (TypeLoadException ex)
{ {
_logger.LogError(ex, "Error getting exported types from {Assembly}", ass.FullName); Logger.LogError(ex, "Error getting exported types from {Assembly}", ass.FullName);
continue; continue;
} }
@ -1194,7 +1201,7 @@ namespace Emby.Server.Implementations
}); });
} }
protected IHttpListener CreateHttpListener() => new WebSocketSharpListener(_loggerFactory.CreateLogger<WebSocketSharpListener>()); protected IHttpListener CreateHttpListener() => new WebSocketSharpListener(LoggerFactory.CreateLogger<WebSocketSharpListener>());
private CertificateInfo GetCertificateInfo(bool generateCertificate) private CertificateInfo GetCertificateInfo(bool generateCertificate)
{ {
@ -1248,7 +1255,7 @@ namespace Emby.Server.Implementations
if (requiresRestart) if (requiresRestart)
{ {
_logger.LogInformation("App needs to be restarted due to configuration change."); Logger.LogInformation("App needs to be restarted due to configuration change.");
NotifyPendingRestart(); NotifyPendingRestart();
} }
@ -1259,7 +1266,7 @@ namespace Emby.Server.Implementations
/// </summary> /// </summary>
public void NotifyPendingRestart() public void NotifyPendingRestart()
{ {
_logger.LogInformation("App needs to be restarted."); Logger.LogInformation("App needs to be restarted.");
var changed = !HasPendingRestart; var changed = !HasPendingRestart;
@ -1267,7 +1274,7 @@ namespace Emby.Server.Implementations
if (changed) if (changed)
{ {
EventHelper.QueueEventIfNotNull(HasPendingRestartChanged, this, EventArgs.Empty, _logger); EventHelper.QueueEventIfNotNull(HasPendingRestartChanged, this, EventArgs.Empty, Logger);
} }
} }
@ -1296,10 +1303,10 @@ namespace Emby.Server.Implementations
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Error sending server restart notification"); Logger.LogError(ex, "Error sending server restart notification");
} }
_logger.LogInformation("Calling RestartInternal"); Logger.LogInformation("Calling RestartInternal");
RestartInternal(); RestartInternal();
}); });
@ -1324,11 +1331,11 @@ namespace Emby.Server.Implementations
} }
catch (FileLoadException ex) catch (FileLoadException ex)
{ {
_logger.LogError(ex, "Failed to load assembly {Path}", file); Logger.LogError(ex, "Failed to load assembly {Path}", file);
continue; continue;
} }
_logger.LogInformation("Loaded assembly {Assembly} from {Path}", plugAss.FullName, file); Logger.LogInformation("Loaded assembly {Assembly} from {Path}", plugAss.FullName, file);
yield return plugAss; yield return plugAss;
} }
} }
@ -1463,7 +1470,7 @@ namespace Emby.Server.Implementations
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Error getting local Ip address information"); Logger.LogError(ex, "Error getting local Ip address information");
} }
return null; return null;
@ -1626,19 +1633,19 @@ namespace Emby.Server.Implementations
var valid = string.Equals(Name, result, StringComparison.OrdinalIgnoreCase); var valid = string.Equals(Name, result, StringComparison.OrdinalIgnoreCase);
_validAddressResults.AddOrUpdate(apiUrl, valid, (k, v) => valid); _validAddressResults.AddOrUpdate(apiUrl, valid, (k, v) => valid);
_logger.LogDebug("Ping test result to {0}. Success: {1}", apiUrl, valid); Logger.LogDebug("Ping test result to {0}. Success: {1}", apiUrl, valid);
return valid; return valid;
} }
} }
} }
catch (OperationCanceledException) catch (OperationCanceledException)
{ {
_logger.LogDebug("Ping test result to {0}. Success: {1}", apiUrl, "Cancelled"); Logger.LogDebug("Ping test result to {0}. Success: {1}", apiUrl, "Cancelled");
throw; throw;
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogDebug(ex, "Ping test result to {0}. Success: {1}", apiUrl, false); Logger.LogDebug(ex, "Ping test result to {0}. Success: {1}", apiUrl, false);
_validAddressResults.AddOrUpdate(apiUrl, false, (k, v) => false); _validAddressResults.AddOrUpdate(apiUrl, false, (k, v) => false);
return false; return false;
@ -1668,7 +1675,7 @@ namespace Emby.Server.Implementations
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Error sending server shutdown notification"); Logger.LogError(ex, "Error sending server shutdown notification");
} }
ShutdownInternal(); ShutdownInternal();
@ -1730,7 +1737,7 @@ namespace Emby.Server.Implementations
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Error launching url: {url}", url); Logger.LogError(ex, "Error launching url: {url}", url);
throw; throw;
} }
} }
@ -1770,14 +1777,14 @@ namespace Emby.Server.Implementations
{ {
var type = GetType(); var type = GetType();
_logger.LogInformation("Disposing {Type}", type.Name); Logger.LogInformation("Disposing {Type}", type.Name);
var parts = _disposableParts.Distinct().Where(i => i.GetType() != type).ToList(); var parts = _disposableParts.Distinct().Where(i => i.GetType() != type).ToList();
_disposableParts.Clear(); _disposableParts.Clear();
foreach (var part in parts) foreach (var part in parts)
{ {
_logger.LogInformation("Disposing {Type}", part.GetType().Name); Logger.LogInformation("Disposing {Type}", part.GetType().Name);
try try
{ {
@ -1785,7 +1792,7 @@ namespace Emby.Server.Implementations
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Error disposing {Type}", part.GetType().Name); Logger.LogError(ex, "Error disposing {Type}", part.GetType().Name);
} }
} }