From ec1f5dc317182582ebff843c9e8a4d5277405469 Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Sun, 6 Jan 2019 21:50:43 +0100 Subject: Mayor code cleanup Add Argument*Exceptions now use proper nameof operators. Added exception messages to quite a few Argument*Exceptions. Fixed rethorwing to be proper syntax. Added a ton of null checkes. (This is only a start, there are about 500 places that need proper null handling) Added some TODOs to log certain exceptions. Fix sln again. Fixed all AssemblyInfo's and added proper copyright (where I could find them) We live in *current year*. Fixed the use of braces. Fixed a ton of properties, and made a fair amount of functions static that should be and can be static. Made more Methods that should be static static. You can now use static to find bad functions! Removed unused variable. And added one more proper XML comment. --- .../Security/AuthenticationRepository.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'Emby.Server.Implementations/Security/AuthenticationRepository.cs') diff --git a/Emby.Server.Implementations/Security/AuthenticationRepository.cs b/Emby.Server.Implementations/Security/AuthenticationRepository.cs index 228d511ce..2a6406f25 100644 --- a/Emby.Server.Implementations/Security/AuthenticationRepository.cs +++ b/Emby.Server.Implementations/Security/AuthenticationRepository.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.IO; @@ -91,7 +91,7 @@ namespace Emby.Server.Implementations.Security { if (info == null) { - throw new ArgumentNullException("info"); + throw new ArgumentNullException(nameof(info)); } using (WriteLock.Write()) @@ -126,7 +126,7 @@ namespace Emby.Server.Implementations.Security { if (info == null) { - throw new ArgumentNullException("entry"); + throw new ArgumentNullException(nameof(info)); } using (WriteLock.Write()) @@ -161,7 +161,7 @@ namespace Emby.Server.Implementations.Security { if (info == null) { - throw new ArgumentNullException("entry"); + throw new ArgumentNullException(nameof(info)); } using (WriteLock.Write()) @@ -183,7 +183,7 @@ namespace Emby.Server.Implementations.Security private const string BaseSelectText = "select Tokens.Id, AccessToken, DeviceId, AppName, AppVersion, DeviceName, UserId, UserName, DateCreated, DateLastActivity, Devices.CustomName from Tokens left join Devices on Tokens.DeviceId=Devices.Id"; - private void BindAuthenticationQueryParams(AuthenticationInfoQuery query, IStatement statement) + private static void BindAuthenticationQueryParams(AuthenticationInfoQuery query, IStatement statement) { if (!string.IsNullOrEmpty(query.AccessToken)) { @@ -205,7 +205,7 @@ namespace Emby.Server.Implementations.Security { if (query == null) { - throw new ArgumentNullException("query"); + throw new ArgumentNullException(nameof(query)); } var commandText = BaseSelectText; @@ -306,7 +306,7 @@ namespace Emby.Server.Implementations.Security } } - private AuthenticationInfo Get(IReadOnlyList reader) + private static AuthenticationInfo Get(IReadOnlyList reader) { var info = new AuthenticationInfo { @@ -397,7 +397,7 @@ namespace Emby.Server.Implementations.Security { if (options == null) { - throw new ArgumentNullException("options"); + throw new ArgumentNullException(nameof(options)); } using (WriteLock.Write()) -- cgit v1.2.3 From 0efc699e3d4cef2cb5b36223873fa5ad98177d1c Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Sun, 13 Jan 2019 20:22:24 +0100 Subject: Visual Studio Reformat: Emby.Server.Implementations Part S-S --- .../ScheduledTasks/ChapterImagesTask.cs | 20 ++++++++--------- .../ScheduledTasks/DailyTrigger.cs | 3 +-- .../ScheduledTasks/IntervalTrigger.cs | 3 +-- .../ScheduledTasks/PeopleValidationTask.cs | 2 +- .../ScheduledTasks/RefreshMediaLibraryTask.cs | 6 +++--- .../ScheduledTasks/ScheduledTaskWorker.cs | 4 ++-- .../ScheduledTasks/StartupTrigger.cs | 3 +-- .../ScheduledTasks/SystemEventTrigger.cs | 3 +-- .../ScheduledTasks/TaskManager.cs | 4 ++-- .../ScheduledTasks/Tasks/DeleteCacheFileTask.cs | 2 +- .../ScheduledTasks/Tasks/DeleteLogFileTask.cs | 2 +- .../ScheduledTasks/WeeklyTrigger.cs | 3 +-- .../Security/AuthenticationRepository.cs | 9 +++----- .../Security/EncryptionManager.cs | 2 +- .../Security/PluginSecurityManager.cs | 5 +---- .../Serialization/JsonSerializer.cs | 4 ++-- .../Serialization/XmlSerializer.cs | 2 +- .../Services/RequestHelper.cs | 2 +- .../Services/ServiceController.cs | 1 - .../Services/ServiceExec.cs | 1 - .../Services/ServiceHandler.cs | 2 +- .../Services/ServicePath.cs | 2 -- .../Services/StringMapTypeDeserializer.cs | 4 ++-- .../Session/HttpSessionController.cs | 14 ++++++------ .../Session/SessionManager.cs | 25 +++++++++++----------- .../Session/SessionWebSocketListener.cs | 10 +++------ .../Session/WebSocketController.cs | 15 ++++++------- .../Sorting/AiredEpisodeOrderComparer.cs | 2 +- .../Sorting/AlbumArtistComparer.cs | 2 +- .../Sorting/AlbumComparer.cs | 4 ++-- .../Sorting/ArtistComparer.cs | 4 ++-- .../Sorting/CommunityRatingComparer.cs | 4 ++-- .../Sorting/DateCreatedComparer.cs | 4 ++-- .../Sorting/DateLastMediaAddedComparer.cs | 2 +- .../Sorting/DatePlayedComparer.cs | 4 ++-- .../Sorting/GameSystemComparer.cs | 4 ++-- .../Sorting/NameComparer.cs | 4 ++-- .../Sorting/OfficialRatingComparer.cs | 4 ++-- .../Sorting/PremiereDateComparer.cs | 4 ++-- .../Sorting/RandomComparer.cs | 4 ++-- .../Sorting/RuntimeComparer.cs | 4 ++-- .../Sorting/SeriesSortNameComparer.cs | 2 +- .../Sorting/SortNameComparer.cs | 4 ++-- .../Sorting/StartDateComparer.cs | 4 ++-- .../Sorting/StudioComparer.cs | 6 +++--- 45 files changed, 96 insertions(+), 123 deletions(-) (limited to 'Emby.Server.Implementations/Security/AuthenticationRepository.cs') diff --git a/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs b/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs index 904e93c56..fdc8ed9c4 100644 --- a/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/ChapterImagesTask.cs @@ -1,22 +1,20 @@ -using MediaBrowser.Common.Configuration; -using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Library; -using MediaBrowser.Controller.MediaEncoding; -using MediaBrowser.Controller.Persistence; -using Microsoft.Extensions.Logging; -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Common.Configuration; using MediaBrowser.Controller.Dto; -using MediaBrowser.Controller.IO; -using MediaBrowser.Model.IO; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.MediaEncoding; +using MediaBrowser.Controller.Persistence; +using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; +using MediaBrowser.Model.IO; using MediaBrowser.Model.Tasks; -using MediaBrowser.Model.Extensions; -using MediaBrowser.Controller.Providers; +using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.ScheduledTasks { diff --git a/Emby.Server.Implementations/ScheduledTasks/DailyTrigger.cs b/Emby.Server.Implementations/ScheduledTasks/DailyTrigger.cs index afcee02e5..c2a69ba48 100644 --- a/Emby.Server.Implementations/ScheduledTasks/DailyTrigger.cs +++ b/Emby.Server.Implementations/ScheduledTasks/DailyTrigger.cs @@ -1,9 +1,8 @@ using System; using System.Globalization; using System.Threading; -using MediaBrowser.Model.Events; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.Tasks; +using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.ScheduledTasks { diff --git a/Emby.Server.Implementations/ScheduledTasks/IntervalTrigger.cs b/Emby.Server.Implementations/ScheduledTasks/IntervalTrigger.cs index 5f6a0dfe6..edd3eb8c0 100644 --- a/Emby.Server.Implementations/ScheduledTasks/IntervalTrigger.cs +++ b/Emby.Server.Implementations/ScheduledTasks/IntervalTrigger.cs @@ -1,9 +1,8 @@ using System; using System.Linq; using System.Threading; -using MediaBrowser.Model.Events; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.Tasks; +using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.ScheduledTasks { diff --git a/Emby.Server.Implementations/ScheduledTasks/PeopleValidationTask.cs b/Emby.Server.Implementations/ScheduledTasks/PeopleValidationTask.cs index 366ad889c..68031170f 100644 --- a/Emby.Server.Implementations/ScheduledTasks/PeopleValidationTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/PeopleValidationTask.cs @@ -1,9 +1,9 @@ -using MediaBrowser.Controller.Library; using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Controller; +using MediaBrowser.Controller.Library; using MediaBrowser.Model.Tasks; namespace Emby.Server.Implementations.ScheduledTasks diff --git a/Emby.Server.Implementations/ScheduledTasks/RefreshMediaLibraryTask.cs b/Emby.Server.Implementations/ScheduledTasks/RefreshMediaLibraryTask.cs index bd49277ad..1ba7c853c 100644 --- a/Emby.Server.Implementations/ScheduledTasks/RefreshMediaLibraryTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/RefreshMediaLibraryTask.cs @@ -1,10 +1,10 @@ -using MediaBrowser.Controller.Configuration; -using MediaBrowser.Controller.Library; -using System; +using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Emby.Server.Implementations.Library; +using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Library; using MediaBrowser.Model.Tasks; namespace Emby.Server.Implementations.ScheduledTasks diff --git a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs index ec54ce71a..dc60b9990 100644 --- a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs +++ b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs @@ -9,10 +9,10 @@ using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Progress; using MediaBrowser.Model.Events; using MediaBrowser.Model.IO; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.System; using MediaBrowser.Model.Tasks; +using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.ScheduledTasks { @@ -718,7 +718,7 @@ namespace Emby.Server.Implementations.ScheduledTasks { if (!info.TimeOfDayTicks.HasValue) { - throw new ArgumentException("Info did not contain a TimeOfDayTicks.",nameof(info)); + throw new ArgumentException("Info did not contain a TimeOfDayTicks.", nameof(info)); } return new DailyTrigger diff --git a/Emby.Server.Implementations/ScheduledTasks/StartupTrigger.cs b/Emby.Server.Implementations/ScheduledTasks/StartupTrigger.cs index 35366a044..bcddb2b2a 100644 --- a/Emby.Server.Implementations/ScheduledTasks/StartupTrigger.cs +++ b/Emby.Server.Implementations/ScheduledTasks/StartupTrigger.cs @@ -1,8 +1,7 @@ using System; using System.Threading.Tasks; -using MediaBrowser.Model.Events; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.Tasks; +using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.ScheduledTasks { diff --git a/Emby.Server.Implementations/ScheduledTasks/SystemEventTrigger.cs b/Emby.Server.Implementations/ScheduledTasks/SystemEventTrigger.cs index def142f88..0d629786f 100644 --- a/Emby.Server.Implementations/ScheduledTasks/SystemEventTrigger.cs +++ b/Emby.Server.Implementations/ScheduledTasks/SystemEventTrigger.cs @@ -1,9 +1,8 @@ using System; using System.Threading.Tasks; -using MediaBrowser.Model.Events; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.System; using MediaBrowser.Model.Tasks; +using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.ScheduledTasks { diff --git a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs index 361c31acb..c81025edd 100644 --- a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs +++ b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs @@ -7,10 +7,10 @@ using System.Threading.Tasks; using MediaBrowser.Common.Configuration; using MediaBrowser.Model.Events; using MediaBrowser.Model.IO; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.System; using MediaBrowser.Model.Tasks; +using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.ScheduledTasks { @@ -94,7 +94,7 @@ namespace Emby.Server.Implementations.ScheduledTasks try { - lines = _fileSystem.ReadAllLines(path).ToList() ; + lines = _fileSystem.ReadAllLines(path).ToList(); } catch { diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs index 0716f8d30..93d1f1a94 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs @@ -6,8 +6,8 @@ using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common.Configuration; using MediaBrowser.Model.IO; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.Tasks; +using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.ScheduledTasks.Tasks { diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs index fea18d9f0..67ecdd147 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs @@ -65,7 +65,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks foreach (var file in filesToDelete) { - double percent = index / (double) filesToDelete.Count; + double percent = index / (double)filesToDelete.Count; progress.Report(100 * percent); diff --git a/Emby.Server.Implementations/ScheduledTasks/WeeklyTrigger.cs b/Emby.Server.Implementations/ScheduledTasks/WeeklyTrigger.cs index e694e0855..11e92b771 100644 --- a/Emby.Server.Implementations/ScheduledTasks/WeeklyTrigger.cs +++ b/Emby.Server.Implementations/ScheduledTasks/WeeklyTrigger.cs @@ -1,8 +1,7 @@ using System; using System.Threading; -using MediaBrowser.Model.Events; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.Tasks; +using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.ScheduledTasks { diff --git a/Emby.Server.Implementations/Security/AuthenticationRepository.cs b/Emby.Server.Implementations/Security/AuthenticationRepository.cs index 2a6406f25..e0f174f9d 100644 --- a/Emby.Server.Implementations/Security/AuthenticationRepository.cs +++ b/Emby.Server.Implementations/Security/AuthenticationRepository.cs @@ -3,16 +3,13 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; -using System.Threading; using Emby.Server.Implementations.Data; -using MediaBrowser.Controller; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Security; -using Microsoft.Extensions.Logging; +using MediaBrowser.Model.Devices; using MediaBrowser.Model.Querying; +using Microsoft.Extensions.Logging; using SQLitePCL.pretty; -using MediaBrowser.Model.Extensions; -using MediaBrowser.Controller.Configuration; -using MediaBrowser.Model.Devices; namespace Emby.Server.Implementations.Security { diff --git a/Emby.Server.Implementations/Security/EncryptionManager.cs b/Emby.Server.Implementations/Security/EncryptionManager.cs index b99e00a67..c60872346 100644 --- a/Emby.Server.Implementations/Security/EncryptionManager.cs +++ b/Emby.Server.Implementations/Security/EncryptionManager.cs @@ -1,6 +1,6 @@ -using MediaBrowser.Controller.Security; using System; using System.Text; +using MediaBrowser.Controller.Security; namespace Emby.Server.Implementations.Security { diff --git a/Emby.Server.Implementations/Security/PluginSecurityManager.cs b/Emby.Server.Implementations/Security/PluginSecurityManager.cs index dc606f2b9..ddff00628 100644 --- a/Emby.Server.Implementations/Security/PluginSecurityManager.cs +++ b/Emby.Server.Implementations/Security/PluginSecurityManager.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Net; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common.Configuration; @@ -12,9 +9,9 @@ using MediaBrowser.Controller; using MediaBrowser.Model.Cryptography; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.Net; using MediaBrowser.Model.Serialization; +using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.Security { diff --git a/Emby.Server.Implementations/Serialization/JsonSerializer.cs b/Emby.Server.Implementations/Serialization/JsonSerializer.cs index d4b6b2f43..26c648d72 100644 --- a/Emby.Server.Implementations/Serialization/JsonSerializer.cs +++ b/Emby.Server.Implementations/Serialization/JsonSerializer.cs @@ -1,9 +1,9 @@ using System; using System.IO; +using System.Threading.Tasks; using MediaBrowser.Model.IO; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.Serialization; -using System.Threading.Tasks; +using Microsoft.Extensions.Logging; namespace Emby.Common.Implementations.Serialization { diff --git a/Emby.Server.Implementations/Serialization/XmlSerializer.cs b/Emby.Server.Implementations/Serialization/XmlSerializer.cs index dfc324919..5bacc754d 100644 --- a/Emby.Server.Implementations/Serialization/XmlSerializer.cs +++ b/Emby.Server.Implementations/Serialization/XmlSerializer.cs @@ -4,8 +4,8 @@ using System.IO; using System.Xml; using System.Xml.Serialization; using MediaBrowser.Model.IO; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.Serialization; +using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.Serialization { diff --git a/Emby.Server.Implementations/Services/RequestHelper.cs b/Emby.Server.Implementations/Services/RequestHelper.cs index 711ba8bbc..3a4c4b3c5 100644 --- a/Emby.Server.Implementations/Services/RequestHelper.cs +++ b/Emby.Server.Implementations/Services/RequestHelper.cs @@ -1,7 +1,7 @@ using System; using System.IO; -using Emby.Server.Implementations.HttpServer; using System.Threading.Tasks; +using Emby.Server.Implementations.HttpServer; namespace Emby.Server.Implementations.Services { diff --git a/Emby.Server.Implementations/Services/ServiceController.cs b/Emby.Server.Implementations/Services/ServiceController.cs index 46af83128..f82c64823 100644 --- a/Emby.Server.Implementations/Services/ServiceController.cs +++ b/Emby.Server.Implementations/Services/ServiceController.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Reflection; using System.Threading.Tasks; using Emby.Server.Implementations.HttpServer; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.Services; namespace Emby.Server.Implementations.Services diff --git a/Emby.Server.Implementations/Services/ServiceExec.cs b/Emby.Server.Implementations/Services/ServiceExec.cs index 9516c1e38..2791ee2ac 100644 --- a/Emby.Server.Implementations/Services/ServiceExec.cs +++ b/Emby.Server.Implementations/Services/ServiceExec.cs @@ -5,7 +5,6 @@ using System.Linq.Expressions; using System.Reflection; using System.Threading.Tasks; using MediaBrowser.Model.Services; -using MediaBrowser.Model.Extensions; namespace Emby.Server.Implementations.Services { diff --git a/Emby.Server.Implementations/Services/ServiceHandler.cs b/Emby.Server.Implementations/Services/ServiceHandler.cs index 5590c51b6..c1c42e3ec 100644 --- a/Emby.Server.Implementations/Services/ServiceHandler.cs +++ b/Emby.Server.Implementations/Services/ServiceHandler.cs @@ -4,8 +4,8 @@ using System.Reflection; using System.Threading; using System.Threading.Tasks; using Emby.Server.Implementations.HttpServer; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.Services { diff --git a/Emby.Server.Implementations/Services/ServicePath.cs b/Emby.Server.Implementations/Services/ServicePath.cs index 0222b3782..8ad31c160 100644 --- a/Emby.Server.Implementations/Services/ServicePath.cs +++ b/Emby.Server.Implementations/Services/ServicePath.cs @@ -4,8 +4,6 @@ using System.IO; using System.Linq; using System.Reflection; using System.Text; -using Microsoft.Extensions.Logging; -using MediaBrowser.Model.Extensions; namespace Emby.Server.Implementations.Services { diff --git a/Emby.Server.Implementations/Services/StringMapTypeDeserializer.cs b/Emby.Server.Implementations/Services/StringMapTypeDeserializer.cs index 2233bf918..d13935fba 100644 --- a/Emby.Server.Implementations/Services/StringMapTypeDeserializer.cs +++ b/Emby.Server.Implementations/Services/StringMapTypeDeserializer.cs @@ -11,14 +11,14 @@ namespace Emby.Server.Implementations.Services { internal class PropertySerializerEntry { - public PropertySerializerEntry(Action propertySetFn, Func propertyParseStringFn) + public PropertySerializerEntry(Action propertySetFn, Func propertyParseStringFn) { PropertySetFn = propertySetFn; PropertyParseStringFn = propertyParseStringFn; } public Action PropertySetFn; - public Func PropertyParseStringFn; + public Func PropertyParseStringFn; public Type PropertyType; } diff --git a/Emby.Server.Implementations/Session/HttpSessionController.cs b/Emby.Server.Implementations/Session/HttpSessionController.cs index c61e2aff4..56befdeca 100644 --- a/Emby.Server.Implementations/Session/HttpSessionController.cs +++ b/Emby.Server.Implementations/Session/HttpSessionController.cs @@ -1,16 +1,14 @@ -using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Session; -using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Serialization; -using MediaBrowser.Model.Session; -using MediaBrowser.Model.System; -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Net; using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Common.Net; +using MediaBrowser.Controller.Session; +using MediaBrowser.Model.Serialization; +using MediaBrowser.Model.Session; namespace Emby.Server.Implementations.Session { @@ -107,7 +105,7 @@ namespace Emby.Server.Implementations.Session return SendMessage(command.Command.ToString(), messageId, args, cancellationToken); } - private string[] _supportedMessages = new string[] { }; + private string[] _supportedMessages = new string[] { }; public Task SendMessage(string name, string messageId, T data, ISessionController[] allControllers, CancellationToken cancellationToken) { if (!IsSessionActive) diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index 4e444ac01..d99130228 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -1,13 +1,22 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; using MediaBrowser.Common.Events; using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Net; using MediaBrowser.Controller; +using MediaBrowser.Controller.Authentication; using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Security; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Devices; @@ -15,21 +24,11 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Events; using MediaBrowser.Model.Library; -using Microsoft.Extensions.Logging; +using MediaBrowser.Model.Querying; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Session; -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using MediaBrowser.Controller.Net; -using MediaBrowser.Model.Querying; using MediaBrowser.Model.Threading; -using MediaBrowser.Model.Extensions; -using MediaBrowser.Controller.Authentication; +using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.Session { @@ -798,7 +797,7 @@ namespace Emby.Server.Implementations.Session if (info.PositionTicks.HasValue && info.PositionTicks.Value < 0) { - throw new ArgumentOutOfRangeException(nameof(info),"The PlaybackStopInfo's PositionTicks was negative."); + throw new ArgumentOutOfRangeException(nameof(info), "The PlaybackStopInfo's PositionTicks was negative."); } var session = GetSession(info.SessionId); diff --git a/Emby.Server.Implementations/Session/SessionWebSocketListener.cs b/Emby.Server.Implementations/Session/SessionWebSocketListener.cs index 116e455cf..24903f5e8 100644 --- a/Emby.Server.Implementations/Session/SessionWebSocketListener.cs +++ b/Emby.Server.Implementations/Session/SessionWebSocketListener.cs @@ -1,15 +1,11 @@ +using System; +using System.Threading.Tasks; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Events; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.Serialization; -using MediaBrowser.Model.Session; -using System; -using System.Collections.Specialized; -using System.Globalization; -using System.Linq; -using System.Threading.Tasks; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.Session { diff --git a/Emby.Server.Implementations/Session/WebSocketController.cs b/Emby.Server.Implementations/Session/WebSocketController.cs index ed34f8721..3bfe57658 100644 --- a/Emby.Server.Implementations/Session/WebSocketController.cs +++ b/Emby.Server.Implementations/Session/WebSocketController.cs @@ -1,16 +1,13 @@ -using MediaBrowser.Controller.Net; -using MediaBrowser.Controller.Session; -using MediaBrowser.Model.Entities; -using Microsoft.Extensions.Logging; -using MediaBrowser.Model.Net; -using MediaBrowser.Model.Session; -using MediaBrowser.Model.System; -using System; +using System; using System.Collections.Generic; using System.Linq; +using System.Net.WebSockets; using System.Threading; using System.Threading.Tasks; -using System.Net.WebSockets; +using MediaBrowser.Controller.Net; +using MediaBrowser.Controller.Session; +using MediaBrowser.Model.Net; +using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.Session { diff --git a/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs b/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs index 1b2974c27..271188314 100644 --- a/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs +++ b/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs @@ -1,8 +1,8 @@ +using System; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Querying; -using System; namespace Emby.Server.Implementations.Sorting { diff --git a/Emby.Server.Implementations/Sorting/AlbumArtistComparer.cs b/Emby.Server.Implementations/Sorting/AlbumArtistComparer.cs index df64d816f..535f123f9 100644 --- a/Emby.Server.Implementations/Sorting/AlbumArtistComparer.cs +++ b/Emby.Server.Implementations/Sorting/AlbumArtistComparer.cs @@ -1,9 +1,9 @@ +using System; using System.Linq; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Querying; -using System; namespace Emby.Server.Implementations.Sorting { diff --git a/Emby.Server.Implementations/Sorting/AlbumComparer.cs b/Emby.Server.Implementations/Sorting/AlbumComparer.cs index dda1c5478..b64c60861 100644 --- a/Emby.Server.Implementations/Sorting/AlbumComparer.cs +++ b/Emby.Server.Implementations/Sorting/AlbumComparer.cs @@ -1,8 +1,8 @@ -using MediaBrowser.Controller.Entities; +using System; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Querying; -using System; namespace Emby.Server.Implementations.Sorting { diff --git a/Emby.Server.Implementations/Sorting/ArtistComparer.cs b/Emby.Server.Implementations/Sorting/ArtistComparer.cs index b0f0549e3..af0b332cc 100644 --- a/Emby.Server.Implementations/Sorting/ArtistComparer.cs +++ b/Emby.Server.Implementations/Sorting/ArtistComparer.cs @@ -1,8 +1,8 @@ -using MediaBrowser.Controller.Entities; +using System; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Querying; -using System; namespace Emby.Server.Implementations.Sorting { diff --git a/Emby.Server.Implementations/Sorting/CommunityRatingComparer.cs b/Emby.Server.Implementations/Sorting/CommunityRatingComparer.cs index 994759171..60aa68425 100644 --- a/Emby.Server.Implementations/Sorting/CommunityRatingComparer.cs +++ b/Emby.Server.Implementations/Sorting/CommunityRatingComparer.cs @@ -1,7 +1,7 @@ -using MediaBrowser.Controller.Entities; +using System; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Querying; -using System; namespace Emby.Server.Implementations.Sorting { diff --git a/Emby.Server.Implementations/Sorting/DateCreatedComparer.cs b/Emby.Server.Implementations/Sorting/DateCreatedComparer.cs index 1c5149517..8ff438aca 100644 --- a/Emby.Server.Implementations/Sorting/DateCreatedComparer.cs +++ b/Emby.Server.Implementations/Sorting/DateCreatedComparer.cs @@ -1,7 +1,7 @@ -using MediaBrowser.Controller.Entities; +using System; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Querying; -using System; namespace Emby.Server.Implementations.Sorting { diff --git a/Emby.Server.Implementations/Sorting/DateLastMediaAddedComparer.cs b/Emby.Server.Implementations/Sorting/DateLastMediaAddedComparer.cs index ffe7fbaec..623675157 100644 --- a/Emby.Server.Implementations/Sorting/DateLastMediaAddedComparer.cs +++ b/Emby.Server.Implementations/Sorting/DateLastMediaAddedComparer.cs @@ -1,8 +1,8 @@ +using System; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Querying; -using System; namespace Emby.Server.Implementations.Sorting { diff --git a/Emby.Server.Implementations/Sorting/DatePlayedComparer.cs b/Emby.Server.Implementations/Sorting/DatePlayedComparer.cs index c11c1986c..dd961c23e 100644 --- a/Emby.Server.Implementations/Sorting/DatePlayedComparer.cs +++ b/Emby.Server.Implementations/Sorting/DatePlayedComparer.cs @@ -1,8 +1,8 @@ -using MediaBrowser.Controller.Entities; +using System; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Querying; -using System; namespace Emby.Server.Implementations.Sorting { diff --git a/Emby.Server.Implementations/Sorting/GameSystemComparer.cs b/Emby.Server.Implementations/Sorting/GameSystemComparer.cs index 0b534b3cb..fcd66f97f 100644 --- a/Emby.Server.Implementations/Sorting/GameSystemComparer.cs +++ b/Emby.Server.Implementations/Sorting/GameSystemComparer.cs @@ -1,7 +1,7 @@ -using MediaBrowser.Controller.Entities; +using System; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Querying; -using System; namespace Emby.Server.Implementations.Sorting { diff --git a/Emby.Server.Implementations/Sorting/NameComparer.cs b/Emby.Server.Implementations/Sorting/NameComparer.cs index cfd810a6b..7ba25c6c2 100644 --- a/Emby.Server.Implementations/Sorting/NameComparer.cs +++ b/Emby.Server.Implementations/Sorting/NameComparer.cs @@ -1,7 +1,7 @@ -using MediaBrowser.Controller.Entities; +using System; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Querying; -using System; namespace Emby.Server.Implementations.Sorting { diff --git a/Emby.Server.Implementations/Sorting/OfficialRatingComparer.cs b/Emby.Server.Implementations/Sorting/OfficialRatingComparer.cs index cd48e3048..359ab607e 100644 --- a/Emby.Server.Implementations/Sorting/OfficialRatingComparer.cs +++ b/Emby.Server.Implementations/Sorting/OfficialRatingComparer.cs @@ -1,8 +1,8 @@ -using MediaBrowser.Controller.Entities; +using System; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Globalization; using MediaBrowser.Model.Querying; -using System; namespace Emby.Server.Implementations.Sorting { diff --git a/Emby.Server.Implementations/Sorting/PremiereDateComparer.cs b/Emby.Server.Implementations/Sorting/PremiereDateComparer.cs index 26c6badaa..e36d65056 100644 --- a/Emby.Server.Implementations/Sorting/PremiereDateComparer.cs +++ b/Emby.Server.Implementations/Sorting/PremiereDateComparer.cs @@ -1,7 +1,7 @@ -using MediaBrowser.Controller.Entities; +using System; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Querying; -using System; namespace Emby.Server.Implementations.Sorting { diff --git a/Emby.Server.Implementations/Sorting/RandomComparer.cs b/Emby.Server.Implementations/Sorting/RandomComparer.cs index c69ebe41a..de8e1d88f 100644 --- a/Emby.Server.Implementations/Sorting/RandomComparer.cs +++ b/Emby.Server.Implementations/Sorting/RandomComparer.cs @@ -1,7 +1,7 @@ -using MediaBrowser.Controller.Entities; +using System; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Querying; -using System; namespace Emby.Server.Implementations.Sorting { diff --git a/Emby.Server.Implementations/Sorting/RuntimeComparer.cs b/Emby.Server.Implementations/Sorting/RuntimeComparer.cs index 77851d702..08a25269a 100644 --- a/Emby.Server.Implementations/Sorting/RuntimeComparer.cs +++ b/Emby.Server.Implementations/Sorting/RuntimeComparer.cs @@ -1,7 +1,7 @@ -using MediaBrowser.Controller.Entities; +using System; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Querying; -using System; namespace Emby.Server.Implementations.Sorting { diff --git a/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs b/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs index 1bbe30b95..942e84704 100644 --- a/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs +++ b/Emby.Server.Implementations/Sorting/SeriesSortNameComparer.cs @@ -1,7 +1,7 @@ +using System; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Querying; -using System; namespace Emby.Server.Implementations.Sorting { diff --git a/Emby.Server.Implementations/Sorting/SortNameComparer.cs b/Emby.Server.Implementations/Sorting/SortNameComparer.cs index 6c42ed988..2b70d8b02 100644 --- a/Emby.Server.Implementations/Sorting/SortNameComparer.cs +++ b/Emby.Server.Implementations/Sorting/SortNameComparer.cs @@ -1,7 +1,7 @@ -using MediaBrowser.Controller.Entities; +using System; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Querying; -using System; namespace Emby.Server.Implementations.Sorting { diff --git a/Emby.Server.Implementations/Sorting/StartDateComparer.cs b/Emby.Server.Implementations/Sorting/StartDateComparer.cs index 7ae8037d9..9954daf19 100644 --- a/Emby.Server.Implementations/Sorting/StartDateComparer.cs +++ b/Emby.Server.Implementations/Sorting/StartDateComparer.cs @@ -1,8 +1,8 @@ -using MediaBrowser.Controller.Entities; +using System; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.LiveTv; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Querying; -using System; namespace Emby.Server.Implementations.Sorting { diff --git a/Emby.Server.Implementations/Sorting/StudioComparer.cs b/Emby.Server.Implementations/Sorting/StudioComparer.cs index 605d65154..9b6c15b2b 100644 --- a/Emby.Server.Implementations/Sorting/StudioComparer.cs +++ b/Emby.Server.Implementations/Sorting/StudioComparer.cs @@ -1,8 +1,8 @@ -using MediaBrowser.Controller.Entities; +using System; +using System.Linq; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Querying; -using System; -using System.Linq; namespace Emby.Server.Implementations.Sorting { -- cgit v1.2.3 From 65cd3ed597c60503a517c06ad16c933ebf2434a9 Mon Sep 17 00:00:00 2001 From: William Taylor Date: Thu, 17 Jan 2019 22:55:05 +0000 Subject: Replaced injections of ILogger with ILoggerFactory This makes resolving dependencies from the container much easier as you cannot resolve with primitives parameters in a way that is any more readable. The aim of this commit is to change as little as possible with the end result, loggers that were newed up for the parent object were given the same name. Objects that used the base or app loggers, were given a new logger with an appropriate name. Also removed some unused dependencies. --- Emby.Dlna/DlnaManager.cs | 7 +- Emby.Dlna/Ssdp/DeviceDiscovery.cs | 8 ++- Emby.Drawing/ImageProcessor.cs | 5 +- Emby.Drawing/SkiaEncoder.cs | 9 ++- .../Activity/ActivityManager.cs | 7 +- .../Activity/ActivityRepository.cs | 4 +- Emby.Server.Implementations/ApplicationHost.cs | 76 ++++++++++------------ .../Channels/ChannelManager.cs | 15 ++++- .../Collections/CollectionManager.cs | 11 +++- .../Data/SqliteDisplayPreferencesRepository.cs | 4 +- .../Data/SqliteItemRepository.cs | 12 +++- .../Data/SqliteUserDataRepository.cs | 9 ++- .../Data/SqliteUserRepository.cs | 7 +- Emby.Server.Implementations/Devices/DeviceId.cs | 7 +- .../Devices/DeviceManager.cs | 14 +++- Emby.Server.Implementations/Dto/DtoService.cs | 17 ++++- .../HttpClientManager/HttpClientManager.cs | 12 ++-- .../HttpServer/HttpListenerHost.cs | 4 +- .../IO/ManagedFileSystem.cs | 11 +++- .../Library/LibraryManager.cs | 16 ++++- .../Library/MediaSourceManager.cs | 15 ++++- Emby.Server.Implementations/Library/UserManager.cs | 15 ++++- .../LiveTv/LiveTvDtoService.cs | 9 ++- .../LiveTv/LiveTvManager.cs | 12 +--- .../Localization/LocalizationManager.cs | 10 ++- .../MediaEncoder/EncodingManager.cs | 7 +- Emby.Server.Implementations/Net/SocketFactory.cs | 12 ---- .../Networking/NetworkManager.cs | 6 +- .../Playlists/PlaylistManager.cs | 10 ++- Emby.Server.Implementations/ResourceFileManager.cs | 7 +- .../ScheduledTasks/TaskManager.cs | 11 +++- .../Security/AuthenticationRepository.cs | 4 +- .../Serialization/JsonSerializer.cs | 6 +- .../Serialization/XmlSerializer.cs | 6 +- .../Session/SessionManager.cs | 18 ++++- Emby.Server.Implementations/SystemEvents.cs | 8 --- .../Updates/InstallationManager.cs | 8 +-- Jellyfin.Server/Program.cs | 14 ++-- MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 5 +- .../Subtitles/SubtitleEncoder.cs | 7 +- MediaBrowser.Providers/Chapters/ChapterManager.cs | 8 ++- .../Subtitles/SubtitleManager.cs | 10 ++- 42 files changed, 298 insertions(+), 165 deletions(-) (limited to 'Emby.Server.Implementations/Security/AuthenticationRepository.cs') diff --git a/Emby.Dlna/DlnaManager.cs b/Emby.Dlna/DlnaManager.cs index 5e99416b3..f795b58cb 100644 --- a/Emby.Dlna/DlnaManager.cs +++ b/Emby.Dlna/DlnaManager.cs @@ -32,16 +32,17 @@ namespace Emby.Dlna private readonly Dictionary> _profiles = new Dictionary>(StringComparer.Ordinal); - public DlnaManager(IXmlSerializer xmlSerializer, + public DlnaManager( + IXmlSerializer xmlSerializer, IFileSystem fileSystem, IApplicationPaths appPaths, - ILogger logger, + ILoggerFactory loggerFactory, IJsonSerializer jsonSerializer, IServerApplicationHost appHost, IAssemblyInfo assemblyInfo) { _xmlSerializer = xmlSerializer; _fileSystem = fileSystem; _appPaths = appPaths; - _logger = logger; + _logger = loggerFactory.CreateLogger("Dlna"); _jsonSerializer = jsonSerializer; _appHost = appHost; _assemblyInfo = assemblyInfo; diff --git a/Emby.Dlna/Ssdp/DeviceDiscovery.cs b/Emby.Dlna/Ssdp/DeviceDiscovery.cs index 069d704b8..89a88705f 100644 --- a/Emby.Dlna/Ssdp/DeviceDiscovery.cs +++ b/Emby.Dlna/Ssdp/DeviceDiscovery.cs @@ -52,9 +52,13 @@ namespace Emby.Dlna.Ssdp private readonly ISocketFactory _socketFactory; private ISsdpCommunicationsServer _commsServer; - public DeviceDiscovery(ILogger logger, IServerConfigurationManager config, ISocketFactory socketFactory, ITimerFactory timerFactory) + public DeviceDiscovery( + ILoggerFactory loggerFactory, + IServerConfigurationManager config, + ISocketFactory socketFactory, + ITimerFactory timerFactory) { - _logger = logger; + _logger = loggerFactory.CreateLogger(nameof(DeviceDiscovery)); _config = config; _socketFactory = socketFactory; _timerFactory = timerFactory; diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index f91990442..e48e8207d 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -53,14 +53,15 @@ namespace Emby.Drawing private readonly Func _libraryManager; private readonly Func _mediaEncoder; - public ImageProcessor(ILogger logger, + public ImageProcessor( + ILoggerFactory loggerFactory, IServerApplicationPaths appPaths, IFileSystem fileSystem, IJsonSerializer jsonSerializer, IImageEncoder imageEncoder, Func libraryManager, ITimerFactory timerFactory, Func mediaEncoder) { - _logger = logger; + _logger = loggerFactory.CreateLogger(nameof(ImageProcessor)); _fileSystem = fileSystem; _jsonSerializer = jsonSerializer; _imageEncoder = imageEncoder; diff --git a/Emby.Drawing/SkiaEncoder.cs b/Emby.Drawing/SkiaEncoder.cs index dc571f4a0..309d72711 100644 --- a/Emby.Drawing/SkiaEncoder.cs +++ b/Emby.Drawing/SkiaEncoder.cs @@ -23,9 +23,14 @@ namespace Emby.Drawing private readonly IFileSystem _fileSystem; private static ILocalizationManager _localizationManager; - public SkiaEncoder(ILogger logger, IApplicationPaths appPaths, Func httpClientFactory, IFileSystem fileSystem, ILocalizationManager localizationManager) + public SkiaEncoder( + ILoggerFactory loggerFactory, + IApplicationPaths appPaths, + Func httpClientFactory, + IFileSystem fileSystem, + ILocalizationManager localizationManager) { - _logger = logger; + _logger = loggerFactory.CreateLogger("ImageEncoder"); _appPaths = appPaths; _httpClientFactory = httpClientFactory; _fileSystem = fileSystem; diff --git a/Emby.Server.Implementations/Activity/ActivityManager.cs b/Emby.Server.Implementations/Activity/ActivityManager.cs index e526acb0d..6febcc2f7 100644 --- a/Emby.Server.Implementations/Activity/ActivityManager.cs +++ b/Emby.Server.Implementations/Activity/ActivityManager.cs @@ -16,9 +16,12 @@ namespace Emby.Server.Implementations.Activity private readonly ILogger _logger; private readonly IUserManager _userManager; - public ActivityManager(ILogger logger, IActivityRepository repo, IUserManager userManager) + public ActivityManager( + ILoggerFactory loggerFactory, + IActivityRepository repo, + IUserManager userManager) { - _logger = logger; + _logger = loggerFactory.CreateLogger(nameof(ActivityManager)); _repo = repo; _userManager = userManager; } diff --git a/Emby.Server.Implementations/Activity/ActivityRepository.cs b/Emby.Server.Implementations/Activity/ActivityRepository.cs index 9e624cd02..aeed8b6f1 100644 --- a/Emby.Server.Implementations/Activity/ActivityRepository.cs +++ b/Emby.Server.Implementations/Activity/ActivityRepository.cs @@ -18,8 +18,8 @@ namespace Emby.Server.Implementations.Activity private readonly CultureInfo _usCulture = new CultureInfo("en-US"); protected IFileSystem FileSystem { get; private set; } - public ActivityRepository(ILogger logger, IServerApplicationPaths appPaths, IFileSystem fileSystem) - : base(logger) + public ActivityRepository(ILoggerFactory loggerFactory, IServerApplicationPaths appPaths, IFileSystem fileSystem) + : base(loggerFactory.CreateLogger(nameof(ActivityRepository))) { DbFilePath = Path.Combine(appPaths.DataPath, "activitylog.db"); FileSystem = fileSystem; diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 43a2928a8..a9b9a40fe 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -263,7 +263,7 @@ namespace Emby.Server.Implementations protected virtual IResourceFileManager CreateResourceFileManager() { - return new ResourceFileManager(HttpResultFactory, LoggerFactory.CreateLogger("ResourceManager"), FileSystemManager); + return new ResourceFileManager(HttpResultFactory, LoggerFactory, FileSystemManager); } /// @@ -378,7 +378,7 @@ namespace Emby.Server.Implementations // hack alert, until common can target .net core BaseExtensions.CryptographyProvider = CryptographyProvider; - XmlSerializer = new MyXmlSerializer(fileSystem, loggerFactory.CreateLogger("XmlSerializer")); + XmlSerializer = new MyXmlSerializer(fileSystem, loggerFactory); NetworkManager = networkManager; networkManager.LocalSubnetsFn = GetConfiguredLocalSubnets; @@ -450,7 +450,7 @@ namespace Emby.Server.Implementations { if (_deviceId == null) { - _deviceId = new DeviceId(ApplicationPaths, LoggerFactory.CreateLogger("SystemId"), FileSystemManager); + _deviceId = new DeviceId(ApplicationPaths, LoggerFactory, FileSystemManager); } return _deviceId.Value; @@ -709,11 +709,6 @@ namespace Emby.Server.Implementations } } - private IJsonSerializer CreateJsonSerializer() - { - return new JsonSerializer(FileSystemManager, LoggerFactory.CreateLogger("JsonSerializer")); - } - public void Init() { HttpPort = ServerConfigurationManager.Configuration.HttpServerPortNumber; @@ -726,7 +721,7 @@ namespace Emby.Server.Implementations HttpsPort = ServerConfiguration.DefaultHttpsPort; } - JsonSerializer = CreateJsonSerializer(); + JsonSerializer = new JsonSerializer(FileSystemManager); if (Plugins != null) { @@ -751,7 +746,7 @@ namespace Emby.Server.Implementations protected virtual IHttpClient CreateHttpClient() { - return new HttpClientManager.HttpClientManager(ApplicationPaths, LoggerFactory.CreateLogger("HttpClient"), FileSystemManager, () => ApplicationUserAgent); + return new HttpClientManager.HttpClientManager(ApplicationPaths, LoggerFactory, FileSystemManager, () => ApplicationUserAgent); } public static IStreamHelper StreamHelper { get; set; } @@ -784,7 +779,7 @@ namespace Emby.Server.Implementations IsoManager = new IsoManager(); RegisterSingleInstance(IsoManager); - TaskManager = new TaskManager(ApplicationPaths, JsonSerializer, LoggerFactory.CreateLogger("TaskManager"), FileSystemManager, SystemEvents); + TaskManager = new TaskManager(ApplicationPaths, JsonSerializer, LoggerFactory, FileSystemManager, SystemEvents); RegisterSingleInstance(TaskManager); RegisterSingleInstance(XmlSerializer); @@ -801,10 +796,10 @@ namespace Emby.Server.Implementations RegisterSingleInstance(CryptographyProvider); - SocketFactory = new SocketFactory(LoggerFactory.CreateLogger("SocketFactory")); + SocketFactory = new SocketFactory(); RegisterSingleInstance(SocketFactory); - InstallationManager = new InstallationManager(LoggerFactory.CreateLogger("InstallationManager"), this, ApplicationPaths, HttpClient, JsonSerializer, ServerConfigurationManager, FileSystemManager, CryptographyProvider, PackageRuntime); + InstallationManager = new InstallationManager(LoggerFactory, this, ApplicationPaths, HttpClient, JsonSerializer, ServerConfigurationManager, FileSystemManager, CryptographyProvider, PackageRuntime); RegisterSingleInstance(InstallationManager); ZipClient = new ZipClient(FileSystemManager); @@ -821,7 +816,7 @@ namespace Emby.Server.Implementations IAssemblyInfo assemblyInfo = new AssemblyInfo(); RegisterSingleInstance(assemblyInfo); - LocalizationManager = new LocalizationManager(ServerConfigurationManager, FileSystemManager, JsonSerializer, LoggerFactory.CreateLogger("LocalizationManager"), assemblyInfo, new TextLocalizer()); + LocalizationManager = new LocalizationManager(ServerConfigurationManager, FileSystemManager, JsonSerializer, LoggerFactory, assemblyInfo, new TextLocalizer()); StringExtensions.LocalizationManager = LocalizationManager; RegisterSingleInstance(LocalizationManager); @@ -837,23 +832,24 @@ namespace Emby.Server.Implementations // This is only needed for disposal purposes. If removing this, make sure to have the manager handle disposing it RegisterSingleInstance(UserRepository); - var displayPreferencesRepo = new SqliteDisplayPreferencesRepository(LoggerFactory.CreateLogger("SqliteDisplayPreferencesRepository"), JsonSerializer, ApplicationPaths, FileSystemManager); + var displayPreferencesRepo = new SqliteDisplayPreferencesRepository(LoggerFactory, JsonSerializer, ApplicationPaths, FileSystemManager); DisplayPreferencesRepository = displayPreferencesRepo; RegisterSingleInstance(DisplayPreferencesRepository); - var itemRepo = new SqliteItemRepository(ServerConfigurationManager, this, JsonSerializer, LoggerFactory.CreateLogger("SqliteItemRepository"), assemblyInfo, FileSystemManager, EnvironmentInfo, TimerFactory); + var itemRepo = new SqliteItemRepository(ServerConfigurationManager, this, JsonSerializer, LoggerFactory, assemblyInfo, FileSystemManager, EnvironmentInfo, TimerFactory); ItemRepository = itemRepo; RegisterSingleInstance(ItemRepository); AuthenticationRepository = GetAuthenticationRepository(); RegisterSingleInstance(AuthenticationRepository); - UserManager = new UserManager(LoggerFactory.CreateLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, this, JsonSerializer, FileSystemManager, CryptographyProvider); + UserManager = new UserManager(LoggerFactory, ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, this, JsonSerializer, FileSystemManager, CryptographyProvider); RegisterSingleInstance(UserManager); - LibraryManager = new LibraryManager(this, Logger, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager, () => UserViewManager); + LibraryManager = new LibraryManager(this, LoggerFactory, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager, () => UserViewManager); RegisterSingleInstance(LibraryManager); + // TODO wtaylor: investigate use of second music manager var musicManager = new MusicManager(LibraryManager); RegisterSingleInstance(new MusicManager(LibraryManager)); @@ -866,7 +862,7 @@ namespace Emby.Server.Implementations Certificate = GetCertificate(CertificateInfo); HttpServer = new HttpListenerHost(this, - LoggerFactory.CreateLogger("HttpServer"), + LoggerFactory, ServerConfigurationManager, "web/index.html", NetworkManager, @@ -886,37 +882,37 @@ namespace Emby.Server.Implementations var encryptionManager = new EncryptionManager(); RegisterSingleInstance(encryptionManager); - DeviceManager = new DeviceManager(AuthenticationRepository, JsonSerializer, LibraryManager, LocalizationManager, UserManager, FileSystemManager, LibraryMonitor, ServerConfigurationManager, LoggerFactory.CreateLogger("DeviceManager"), NetworkManager); + DeviceManager = new DeviceManager(AuthenticationRepository, JsonSerializer, LibraryManager, LocalizationManager, UserManager, FileSystemManager, LibraryMonitor, ServerConfigurationManager, LoggerFactory, NetworkManager); RegisterSingleInstance(DeviceManager); - MediaSourceManager = new MediaSourceManager(ItemRepository, ApplicationPaths, LocalizationManager, UserManager, LibraryManager, LoggerFactory.CreateLogger("MediaSourceManager"), JsonSerializer, FileSystemManager, UserDataManager, TimerFactory, () => MediaEncoder); + MediaSourceManager = new MediaSourceManager(ItemRepository, ApplicationPaths, LocalizationManager, UserManager, LibraryManager, LoggerFactory, JsonSerializer, FileSystemManager, UserDataManager, TimerFactory, () => MediaEncoder); RegisterSingleInstance(MediaSourceManager); - SubtitleManager = new SubtitleManager(LoggerFactory.CreateLogger("SubtitleManager"), FileSystemManager, LibraryMonitor, MediaSourceManager, ServerConfigurationManager, LocalizationManager); + SubtitleManager = new SubtitleManager(LoggerFactory, FileSystemManager, LibraryMonitor, MediaSourceManager, ServerConfigurationManager, LocalizationManager); RegisterSingleInstance(SubtitleManager); ProviderManager = new ProviderManager(HttpClient, SubtitleManager, ServerConfigurationManager, LibraryMonitor, LoggerFactory, FileSystemManager, ApplicationPaths, () => LibraryManager, JsonSerializer); RegisterSingleInstance(ProviderManager); - DtoService = new DtoService(LoggerFactory.CreateLogger("DtoService"), LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager, () => ChannelManager, this, () => DeviceManager, () => MediaSourceManager, () => LiveTvManager); + DtoService = new DtoService(LoggerFactory, LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager, () => ChannelManager, this, () => DeviceManager, () => MediaSourceManager, () => LiveTvManager); RegisterSingleInstance(DtoService); - ChannelManager = new ChannelManager(UserManager, DtoService, LibraryManager, LoggerFactory.CreateLogger("ChannelManager"), ServerConfigurationManager, FileSystemManager, UserDataManager, JsonSerializer, LocalizationManager, HttpClient, ProviderManager); + ChannelManager = new ChannelManager(UserManager, DtoService, LibraryManager, LoggerFactory, ServerConfigurationManager, FileSystemManager, UserDataManager, JsonSerializer, LocalizationManager, HttpClient, ProviderManager); RegisterSingleInstance(ChannelManager); - SessionManager = new SessionManager(UserDataManager, LoggerFactory.CreateLogger("SessionManager"), LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager, MediaSourceManager, TimerFactory); + SessionManager = new SessionManager(UserDataManager, LoggerFactory, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager, MediaSourceManager, TimerFactory); RegisterSingleInstance(SessionManager); - var dlnaManager = new DlnaManager(XmlSerializer, FileSystemManager, ApplicationPaths, LoggerFactory.CreateLogger("Dlna"), JsonSerializer, this, assemblyInfo); + var dlnaManager = new DlnaManager(XmlSerializer, FileSystemManager, ApplicationPaths, LoggerFactory, JsonSerializer, this, assemblyInfo); RegisterSingleInstance(dlnaManager); - CollectionManager = new CollectionManager(LibraryManager, ApplicationPaths, LocalizationManager, FileSystemManager, LibraryMonitor, LoggerFactory.CreateLogger("CollectionManager"), ProviderManager); + CollectionManager = new CollectionManager(LibraryManager, ApplicationPaths, LocalizationManager, FileSystemManager, LibraryMonitor, LoggerFactory, ProviderManager); RegisterSingleInstance(CollectionManager); - PlaylistManager = new PlaylistManager(LibraryManager, FileSystemManager, LibraryMonitor, LoggerFactory.CreateLogger("PlaylistManager"), UserManager, ProviderManager); + PlaylistManager = new PlaylistManager(LibraryManager, FileSystemManager, LibraryMonitor, LoggerFactory, UserManager, ProviderManager); RegisterSingleInstance(PlaylistManager); - LiveTvManager = new LiveTvManager(this, HttpClient, ServerConfigurationManager, Logger, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, LocalizationManager, JsonSerializer, ProviderManager, FileSystemManager, () => ChannelManager); + LiveTvManager = new LiveTvManager(this, ServerConfigurationManager, LoggerFactory, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, LocalizationManager, JsonSerializer, ProviderManager, FileSystemManager, () => ChannelManager); RegisterSingleInstance(LiveTvManager); UserViewManager = new UserViewManager(LibraryManager, LocalizationManager, UserManager, ChannelManager, LiveTvManager, ServerConfigurationManager); @@ -925,19 +921,19 @@ namespace Emby.Server.Implementations NotificationManager = new NotificationManager(LoggerFactory, UserManager, ServerConfigurationManager); RegisterSingleInstance(NotificationManager); - RegisterSingleInstance(new DeviceDiscovery(LoggerFactory.CreateLogger("IDeviceDiscovery"), ServerConfigurationManager, SocketFactory, TimerFactory)); + RegisterSingleInstance(new DeviceDiscovery(LoggerFactory, ServerConfigurationManager, SocketFactory, TimerFactory)); - ChapterManager = new ChapterManager(LibraryManager, LoggerFactory.CreateLogger("ChapterManager"), ServerConfigurationManager, ItemRepository); + ChapterManager = new ChapterManager(LibraryManager, LoggerFactory, ServerConfigurationManager, ItemRepository); RegisterSingleInstance(ChapterManager); RegisterMediaEncoder(assemblyInfo); - EncodingManager = new MediaEncoder.EncodingManager(FileSystemManager, Logger, MediaEncoder, ChapterManager, LibraryManager); + EncodingManager = new MediaEncoder.EncodingManager(FileSystemManager, LoggerFactory, MediaEncoder, ChapterManager, LibraryManager); RegisterSingleInstance(EncodingManager); var activityLogRepo = GetActivityLogRepository(); RegisterSingleInstance(activityLogRepo); - RegisterSingleInstance(new ActivityManager(LoggerFactory.CreateLogger("ActivityManager"), activityLogRepo, UserManager)); + RegisterSingleInstance(new ActivityManager(LoggerFactory, activityLogRepo, UserManager)); var authContext = new AuthorizationContext(AuthenticationRepository, UserManager); RegisterSingleInstance(authContext); @@ -946,14 +942,14 @@ namespace Emby.Server.Implementations AuthService = new AuthService(UserManager, authContext, ServerConfigurationManager, SessionManager, NetworkManager); RegisterSingleInstance(AuthService); - SubtitleEncoder = new MediaBrowser.MediaEncoding.Subtitles.SubtitleEncoder(LibraryManager, LoggerFactory.CreateLogger("SubtitleEncoder"), ApplicationPaths, FileSystemManager, MediaEncoder, JsonSerializer, HttpClient, MediaSourceManager, ProcessFactory); + SubtitleEncoder = new MediaBrowser.MediaEncoding.Subtitles.SubtitleEncoder(LibraryManager, LoggerFactory, ApplicationPaths, FileSystemManager, MediaEncoder, JsonSerializer, HttpClient, MediaSourceManager, ProcessFactory); RegisterSingleInstance(SubtitleEncoder); RegisterSingleInstance(CreateResourceFileManager()); displayPreferencesRepo.Initialize(); - var userDataRepo = new SqliteUserDataRepository(LoggerFactory.CreateLogger("SqliteUserDataRepository"), ApplicationPaths, FileSystemManager); + var userDataRepo = new SqliteUserDataRepository(LoggerFactory, ApplicationPaths); SetStaticProperties(); @@ -1046,7 +1042,7 @@ namespace Emby.Server.Implementations private IImageProcessor GetImageProcessor() { - return new ImageProcessor(LoggerFactory.CreateLogger("ImageProcessor"), ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer, ImageEncoder, () => LibraryManager, TimerFactory, () => MediaEncoder); + return new ImageProcessor(LoggerFactory, ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer, ImageEncoder, () => LibraryManager, TimerFactory, () => MediaEncoder); } protected virtual FFMpegInstallInfo GetFfmpegInstallInfo() @@ -1105,7 +1101,7 @@ namespace Emby.Server.Implementations var hasExternalEncoder = string.Equals(info.Version, "external", StringComparison.OrdinalIgnoreCase); var mediaEncoder = new MediaBrowser.MediaEncoding.Encoder.MediaEncoder( - LoggerFactory.CreateLogger("MediaEncoder"), + LoggerFactory, JsonSerializer, encoderPath, probePath, @@ -1134,7 +1130,7 @@ namespace Emby.Server.Implementations /// Task{IUserRepository}. private IUserRepository GetUserRepository() { - var repo = new SqliteUserRepository(LoggerFactory.CreateLogger("SqliteUserRepository"), ApplicationPaths, JsonSerializer); + var repo = new SqliteUserRepository(LoggerFactory, ApplicationPaths, JsonSerializer); repo.Initialize(); @@ -1143,7 +1139,7 @@ namespace Emby.Server.Implementations private IAuthenticationRepository GetAuthenticationRepository() { - var repo = new AuthenticationRepository(LoggerFactory.CreateLogger("AuthenticationRepository"), ServerConfigurationManager); + var repo = new AuthenticationRepository(LoggerFactory, ServerConfigurationManager); repo.Initialize(); @@ -1152,7 +1148,7 @@ namespace Emby.Server.Implementations private IActivityRepository GetActivityLogRepository() { - var repo = new ActivityRepository(LoggerFactory.CreateLogger("ActivityRepository"), ServerConfigurationManager.ApplicationPaths, FileSystemManager); + var repo = new ActivityRepository(LoggerFactory, ServerConfigurationManager.ApplicationPaths, FileSystemManager); repo.Initialize(); diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index f98e199e6..660547c85 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -45,12 +45,23 @@ namespace Emby.Server.Implementations.Channels private readonly ILocalizationManager _localization; - public ChannelManager(IUserManager userManager, IDtoService dtoService, ILibraryManager libraryManager, ILogger logger, IServerConfigurationManager config, IFileSystem fileSystem, IUserDataManager userDataManager, IJsonSerializer jsonSerializer, ILocalizationManager localization, IHttpClient httpClient, IProviderManager providerManager) + public ChannelManager( + IUserManager userManager, + IDtoService dtoService, + ILibraryManager libraryManager, + ILoggerFactory loggerFactory, + IServerConfigurationManager config, + IFileSystem fileSystem, + IUserDataManager userDataManager, + IJsonSerializer jsonSerializer, + ILocalizationManager localization, + IHttpClient httpClient, + IProviderManager providerManager) { _userManager = userManager; _dtoService = dtoService; _libraryManager = libraryManager; - _logger = logger; + _logger = loggerFactory.CreateLogger(nameof(ChannelManager)); _config = config; _fileSystem = fileSystem; _userDataManager = userDataManager; diff --git a/Emby.Server.Implementations/Collections/CollectionManager.cs b/Emby.Server.Implementations/Collections/CollectionManager.cs index 213bb35e4..0166bbc5a 100644 --- a/Emby.Server.Implementations/Collections/CollectionManager.cs +++ b/Emby.Server.Implementations/Collections/CollectionManager.cs @@ -34,12 +34,19 @@ namespace Emby.Server.Implementations.Collections public event EventHandler ItemsAddedToCollection; public event EventHandler ItemsRemovedFromCollection; - public CollectionManager(ILibraryManager libraryManager, IApplicationPaths appPaths, ILocalizationManager localizationManager, IFileSystem fileSystem, ILibraryMonitor iLibraryMonitor, ILogger logger, IProviderManager providerManager) + public CollectionManager( + ILibraryManager libraryManager, + IApplicationPaths appPaths, + ILocalizationManager localizationManager, + IFileSystem fileSystem, + ILibraryMonitor iLibraryMonitor, + ILoggerFactory loggerFactory, + IProviderManager providerManager) { _libraryManager = libraryManager; _fileSystem = fileSystem; _iLibraryMonitor = iLibraryMonitor; - _logger = logger; + _logger = loggerFactory.CreateLogger(nameof(CollectionManager)); _providerManager = providerManager; _localizationManager = localizationManager; _appPaths = appPaths; diff --git a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs index 9ed2b49e5..3d60925da 100644 --- a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs @@ -20,8 +20,8 @@ namespace Emby.Server.Implementations.Data { protected IFileSystem FileSystem { get; private set; } - public SqliteDisplayPreferencesRepository(ILogger logger, IJsonSerializer jsonSerializer, IApplicationPaths appPaths, IFileSystem fileSystem) - : base(logger) + public SqliteDisplayPreferencesRepository(ILoggerFactory loggerFactory, IJsonSerializer jsonSerializer, IApplicationPaths appPaths, IFileSystem fileSystem) + : base(loggerFactory.CreateLogger(nameof(SqliteDisplayPreferencesRepository))) { _jsonSerializer = jsonSerializer; FileSystem = fileSystem; diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 727a9e868..492adef6a 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -67,8 +67,16 @@ namespace Emby.Server.Implementations.Data /// /// Initializes a new instance of the class. /// - public SqliteItemRepository(IServerConfigurationManager config, IServerApplicationHost appHost, IJsonSerializer jsonSerializer, ILogger logger, IAssemblyInfo assemblyInfo, IFileSystem fileSystem, IEnvironmentInfo environmentInfo, ITimerFactory timerFactory) - : base(logger) + public SqliteItemRepository( + IServerConfigurationManager config, + IServerApplicationHost appHost, + IJsonSerializer jsonSerializer, + ILoggerFactory loggerFactory, + IAssemblyInfo assemblyInfo, + IFileSystem fileSystem, + IEnvironmentInfo environmentInfo, + ITimerFactory timerFactory) + : base(loggerFactory.CreateLogger(nameof(SqliteItemRepository))) { if (config == null) { diff --git a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs index 48ff9ded8..7a9b72244 100644 --- a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs @@ -15,12 +15,11 @@ namespace Emby.Server.Implementations.Data { public class SqliteUserDataRepository : BaseSqliteRepository, IUserDataRepository { - private readonly IFileSystem _fileSystem; - - public SqliteUserDataRepository(ILogger logger, IApplicationPaths appPaths, IFileSystem fileSystem) - : base(logger) + public SqliteUserDataRepository( + ILoggerFactory loggerFactory, + IApplicationPaths appPaths) + : base(loggerFactory.CreateLogger(nameof(SqliteUserDataRepository))) { - _fileSystem = fileSystem; DbFilePath = Path.Combine(appPaths.DataPath, "library.db"); } diff --git a/Emby.Server.Implementations/Data/SqliteUserRepository.cs b/Emby.Server.Implementations/Data/SqliteUserRepository.cs index ad37a0275..db359d7dd 100644 --- a/Emby.Server.Implementations/Data/SqliteUserRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteUserRepository.cs @@ -17,8 +17,11 @@ namespace Emby.Server.Implementations.Data { private readonly IJsonSerializer _jsonSerializer; - public SqliteUserRepository(ILogger logger, IServerApplicationPaths appPaths, IJsonSerializer jsonSerializer) - : base(logger) + public SqliteUserRepository( + ILoggerFactory loggerFactory, + IServerApplicationPaths appPaths, + IJsonSerializer jsonSerializer) + : base(loggerFactory.CreateLogger(nameof(SqliteUserRepository))) { _jsonSerializer = jsonSerializer; diff --git a/Emby.Server.Implementations/Devices/DeviceId.cs b/Emby.Server.Implementations/Devices/DeviceId.cs index 56e555937..00761809a 100644 --- a/Emby.Server.Implementations/Devices/DeviceId.cs +++ b/Emby.Server.Implementations/Devices/DeviceId.cs @@ -86,7 +86,10 @@ namespace Emby.Server.Implementations.Devices private string _id; - public DeviceId(IApplicationPaths appPaths, ILogger logger, IFileSystem fileSystem) + public DeviceId( + IApplicationPaths appPaths, + ILoggerFactory loggerFactory, + IFileSystem fileSystem) { if (fileSystem == null) { @@ -94,7 +97,7 @@ namespace Emby.Server.Implementations.Devices } _appPaths = appPaths; - _logger = logger; + _logger = loggerFactory.CreateLogger("SystemId"); _fileSystem = fileSystem; } diff --git a/Emby.Server.Implementations/Devices/DeviceManager.cs b/Emby.Server.Implementations/Devices/DeviceManager.cs index f2ab28d4c..60d57519e 100644 --- a/Emby.Server.Implementations/Devices/DeviceManager.cs +++ b/Emby.Server.Implementations/Devices/DeviceManager.cs @@ -47,14 +47,24 @@ namespace Emby.Server.Implementations.Devices private readonly object _cameraUploadSyncLock = new object(); private readonly object _capabilitiesSyncLock = new object(); - public DeviceManager(IAuthenticationRepository authRepo, IJsonSerializer json, ILibraryManager libraryManager, ILocalizationManager localizationManager, IUserManager userManager, IFileSystem fileSystem, ILibraryMonitor libraryMonitor, IServerConfigurationManager config, ILogger logger, INetworkManager network) + public DeviceManager( + IAuthenticationRepository authRepo, + IJsonSerializer json, + ILibraryManager libraryManager, + ILocalizationManager localizationManager, + IUserManager userManager, + IFileSystem fileSystem, + ILibraryMonitor libraryMonitor, + IServerConfigurationManager config, + ILoggerFactory loggerFactory, + INetworkManager network) { _json = json; _userManager = userManager; _fileSystem = fileSystem; _libraryMonitor = libraryMonitor; _config = config; - _logger = logger; + _logger = loggerFactory.CreateLogger(nameof(DeviceManager)); _network = network; _libraryManager = libraryManager; _localizationManager = localizationManager; diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index a45cde980..13febc214 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -46,9 +46,22 @@ namespace Emby.Server.Implementations.Dto private readonly Func _mediaSourceManager; private readonly Func _livetvManager; - public DtoService(ILogger logger, ILibraryManager libraryManager, IUserDataManager userDataRepository, IItemRepository itemRepo, IImageProcessor imageProcessor, IServerConfigurationManager config, IFileSystem fileSystem, IProviderManager providerManager, Func channelManagerFactory, IApplicationHost appHost, Func deviceManager, Func mediaSourceManager, Func livetvManager) + public DtoService( + ILoggerFactory loggerFactory, + ILibraryManager libraryManager, + IUserDataManager userDataRepository, + IItemRepository itemRepo, + IImageProcessor imageProcessor, + IServerConfigurationManager config, + IFileSystem fileSystem, + IProviderManager providerManager, + Func channelManagerFactory, + IApplicationHost appHost, + Func deviceManager, + Func mediaSourceManager, + Func livetvManager) { - _logger = logger; + _logger = loggerFactory.CreateLogger(nameof(DtoService)); _libraryManager = libraryManager; _userDataRepository = userDataRepository; _itemRepo = itemRepo; diff --git a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs index 3aab10026..9d25ad1b3 100644 --- a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs +++ b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs @@ -44,18 +44,22 @@ namespace Emby.Server.Implementations.HttpClientManager /// /// Initializes a new instance of the class. /// - public HttpClientManager(IApplicationPaths appPaths, ILogger logger, IFileSystem fileSystem, Func defaultUserAgentFn) + public HttpClientManager( + IApplicationPaths appPaths, + ILoggerFactory loggerFactory, + IFileSystem fileSystem, + Func defaultUserAgentFn) { if (appPaths == null) { throw new ArgumentNullException(nameof(appPaths)); } - if (logger == null) + if (loggerFactory == null) { - throw new ArgumentNullException(nameof(logger)); + throw new ArgumentNullException(nameof(loggerFactory)); } - _logger = logger; + _logger = loggerFactory.CreateLogger("HttpClient"); _fileSystem = fileSystem; _appPaths = appPaths; _defaultUserAgentFn = defaultUserAgentFn; diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs index 7dfe029f8..834ffb130 100644 --- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -51,7 +51,7 @@ namespace Emby.Server.Implementations.HttpServer public HttpListenerHost( IServerApplicationHost applicationHost, - ILogger logger, + ILoggerFactory loggerFactory, IServerConfigurationManager config, string defaultRedirectPath, INetworkManager networkManager, @@ -60,7 +60,7 @@ namespace Emby.Server.Implementations.HttpServer Func> funcParseFn) { _appHost = applicationHost; - _logger = logger; + _logger = loggerFactory.CreateLogger("HttpServer"); _config = config; DefaultRedirectPath = defaultRedirectPath; _networkManager = networkManager; diff --git a/Emby.Server.Implementations/IO/ManagedFileSystem.cs b/Emby.Server.Implementations/IO/ManagedFileSystem.cs index ae1470190..1c7b0d46b 100644 --- a/Emby.Server.Implementations/IO/ManagedFileSystem.cs +++ b/Emby.Server.Implementations/IO/ManagedFileSystem.cs @@ -29,9 +29,14 @@ namespace Emby.Server.Implementations.IO private string _defaultDirectory; - public ManagedFileSystem(ILogger logger, IEnvironmentInfo environmentInfo, string defaultDirectory, string tempPath, bool enableSeparateFileAndDirectoryQueries) - { - Logger = logger; + public ManagedFileSystem( + ILoggerFactory loggerFactory, + IEnvironmentInfo environmentInfo, + string defaultDirectory, + string tempPath, + bool enableSeparateFileAndDirectoryQueries) + { + Logger = loggerFactory.CreateLogger("FileSystem"); _supportsAsyncFileStreams = true; _tempPath = tempPath; _environmentInfo = environmentInfo; diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 073005a1e..ad070ed79 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -155,9 +155,19 @@ namespace Emby.Server.Implementations.Library /// The user manager. /// The configuration manager. /// The user data repository. - public LibraryManager(IServerApplicationHost appHost, ILogger logger, ITaskManager taskManager, IUserManager userManager, IServerConfigurationManager configurationManager, IUserDataManager userDataRepository, Func libraryMonitorFactory, IFileSystem fileSystem, Func providerManagerFactory, Func userviewManager) - { - _logger = logger; + public LibraryManager( + IServerApplicationHost appHost, + ILoggerFactory loggerFactory, + ITaskManager taskManager, + IUserManager userManager, + IServerConfigurationManager configurationManager, + IUserDataManager userDataRepository, + Func libraryMonitorFactory, + IFileSystem fileSystem, + Func providerManagerFactory, + Func userviewManager) + { + _logger = loggerFactory.CreateLogger(nameof(LibraryManager)); _taskManager = taskManager; _userManager = userManager; ConfigurationManager = configurationManager; diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs index e0ecb2bce..0adc5553b 100644 --- a/Emby.Server.Implementations/Library/MediaSourceManager.cs +++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs @@ -41,12 +41,23 @@ namespace Emby.Server.Implementations.Library private ILocalizationManager _localizationManager; private IApplicationPaths _appPaths; - public MediaSourceManager(IItemRepository itemRepo, IApplicationPaths applicationPaths, ILocalizationManager localizationManager, IUserManager userManager, ILibraryManager libraryManager, ILogger logger, IJsonSerializer jsonSerializer, IFileSystem fileSystem, IUserDataManager userDataManager, ITimerFactory timerFactory, Func mediaEncoder) + public MediaSourceManager( + IItemRepository itemRepo, + IApplicationPaths applicationPaths, + ILocalizationManager localizationManager, + IUserManager userManager, + ILibraryManager libraryManager, + ILoggerFactory loggerFactory, + IJsonSerializer jsonSerializer, + IFileSystem fileSystem, + IUserDataManager userDataManager, + ITimerFactory timerFactory, + Func mediaEncoder) { _itemRepo = itemRepo; _userManager = userManager; _libraryManager = libraryManager; - _logger = logger; + _logger = loggerFactory.CreateLogger(nameof(MediaSourceManager)); _jsonSerializer = jsonSerializer; _fileSystem = fileSystem; _userDataManager = userDataManager; diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs index f06c71386..d5bc3d332 100644 --- a/Emby.Server.Implementations/Library/UserManager.cs +++ b/Emby.Server.Implementations/Library/UserManager.cs @@ -80,9 +80,20 @@ namespace Emby.Server.Implementations.Library private IAuthenticationProvider[] _authenticationProviders; private DefaultAuthenticationProvider _defaultAuthenticationProvider; - public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func imageProcessorFactory, Func dtoServiceFactory, IServerApplicationHost appHost, IJsonSerializer jsonSerializer, IFileSystem fileSystem, ICryptoProvider cryptographyProvider) + public UserManager( + ILoggerFactory loggerFactory, + IServerConfigurationManager configurationManager, + IUserRepository userRepository, + IXmlSerializer xmlSerializer, + INetworkManager networkManager, + Func imageProcessorFactory, + Func dtoServiceFactory, + IServerApplicationHost appHost, + IJsonSerializer jsonSerializer, + IFileSystem fileSystem, + ICryptoProvider cryptographyProvider) { - _logger = logger; + _logger = loggerFactory.CreateLogger(nameof(UserManager)); UserRepository = userRepository; _xmlSerializer = xmlSerializer; _networkManager = networkManager; diff --git a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs index d0cde0643..724e8afdf 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs @@ -26,11 +26,16 @@ namespace Emby.Server.Implementations.LiveTv private readonly IApplicationHost _appHost; private readonly ILibraryManager _libraryManager; - public LiveTvDtoService(IDtoService dtoService, IImageProcessor imageProcessor, ILogger logger, IApplicationHost appHost, ILibraryManager libraryManager) + public LiveTvDtoService( + IDtoService dtoService, + IImageProcessor imageProcessor, + ILoggerFactory loggerFactory, + IApplicationHost appHost, + ILibraryManager libraryManager) { _dtoService = dtoService; _imageProcessor = imageProcessor; - _logger = logger; + _logger = loggerFactory.CreateLogger(nameof(LiveTvDtoService)); _appHost = appHost; _libraryManager = libraryManager; } diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index 11d7facbe..575cb1c77 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -72,14 +72,10 @@ namespace Emby.Server.Implementations.LiveTv return EmbyTV.EmbyTV.Current.GetActiveRecordingPath(id); } - private IServerApplicationHost _appHost; - private IHttpClient _httpClient; - public LiveTvManager( IServerApplicationHost appHost, - IHttpClient httpClient, IServerConfigurationManager config, - ILogger logger, + ILoggerFactory loggerFactory, IItemRepository itemRepo, IImageProcessor imageProcessor, IUserDataManager userDataManager, @@ -93,9 +89,8 @@ namespace Emby.Server.Implementations.LiveTv IFileSystem fileSystem, Func channelManager) { - _appHost = appHost; _config = config; - _logger = logger; + _logger = loggerFactory.CreateLogger(nameof(LiveTvManager)); _itemRepo = itemRepo; _userManager = userManager; _libraryManager = libraryManager; @@ -107,9 +102,8 @@ namespace Emby.Server.Implementations.LiveTv _dtoService = dtoService; _userDataManager = userDataManager; _channelManager = channelManager; - _httpClient = httpClient; - _tvDtoService = new LiveTvDtoService(dtoService, imageProcessor, logger, appHost, _libraryManager); + _tvDtoService = new LiveTvDtoService(dtoService, imageProcessor, loggerFactory, appHost, _libraryManager); } /// diff --git a/Emby.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.cs index 5d3c39af4..af05cd7d7 100644 --- a/Emby.Server.Implementations/Localization/LocalizationManager.cs +++ b/Emby.Server.Implementations/Localization/LocalizationManager.cs @@ -45,12 +45,18 @@ namespace Emby.Server.Implementations.Localization /// The configuration manager. /// The file system. /// The json serializer. - public LocalizationManager(IServerConfigurationManager configurationManager, IFileSystem fileSystem, IJsonSerializer jsonSerializer, ILogger logger, IAssemblyInfo assemblyInfo, ITextLocalizer textLocalizer) + public LocalizationManager( + IServerConfigurationManager configurationManager, + IFileSystem fileSystem, + IJsonSerializer jsonSerializer, + ILoggerFactory loggerFactory, + IAssemblyInfo assemblyInfo, + ITextLocalizer textLocalizer) { _configurationManager = configurationManager; _fileSystem = fileSystem; _jsonSerializer = jsonSerializer; - _logger = logger; + _logger = loggerFactory.CreateLogger(nameof(LocalizationManager)); _assemblyInfo = assemblyInfo; _textLocalizer = textLocalizer; diff --git a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs index 316c2c2a3..0575ff553 100644 --- a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs +++ b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs @@ -26,13 +26,14 @@ namespace Emby.Server.Implementations.MediaEncoder private readonly IChapterManager _chapterManager; private readonly ILibraryManager _libraryManager; - public EncodingManager(IFileSystem fileSystem, - ILogger logger, + public EncodingManager( + IFileSystem fileSystem, + ILoggerFactory loggerFactory, IMediaEncoder encoder, IChapterManager chapterManager, ILibraryManager libraryManager) { _fileSystem = fileSystem; - _logger = logger; + _logger = loggerFactory.CreateLogger(nameof(EncodingManager)); _encoder = encoder; _chapterManager = chapterManager; _libraryManager = libraryManager; diff --git a/Emby.Server.Implementations/Net/SocketFactory.cs b/Emby.Server.Implementations/Net/SocketFactory.cs index 2e22fbbb8..6beb14f55 100644 --- a/Emby.Server.Implementations/Net/SocketFactory.cs +++ b/Emby.Server.Implementations/Net/SocketFactory.cs @@ -17,18 +17,6 @@ namespace Emby.Server.Implementations.Net // but that wasn't really the point so kept to YAGNI principal for now, even if the // interfaces are a bit ugly, specific and make assumptions. - private readonly ILogger _logger; - - public SocketFactory(ILogger logger) - { - if (logger == null) - { - throw new ArgumentNullException(nameof(logger)); - } - - _logger = logger; - } - public ISocket CreateTcpSocket(IpAddressInfo remoteAddress, int remotePort) { if (remotePort < 0) throw new ArgumentException("remotePort cannot be less than zero.", nameof(remotePort)); diff --git a/Emby.Server.Implementations/Networking/NetworkManager.cs b/Emby.Server.Implementations/Networking/NetworkManager.cs index b486c0ef7..f4b9f84dc 100644 --- a/Emby.Server.Implementations/Networking/NetworkManager.cs +++ b/Emby.Server.Implementations/Networking/NetworkManager.cs @@ -22,9 +22,11 @@ namespace Emby.Server.Implementations.Networking public event EventHandler NetworkChanged; public Func LocalSubnetsFn { get; set; } - public NetworkManager(ILogger logger, IEnvironmentInfo environment) + public NetworkManager( + ILoggerFactory loggerFactory, + IEnvironmentInfo environment) { - Logger = logger; + Logger = loggerFactory.CreateLogger(nameof(NetworkManager)); // In FreeBSD these events cause a crash if (environment.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.BSD) diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs index c39897b53..17f445708 100644 --- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs +++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs @@ -28,12 +28,18 @@ namespace Emby.Server.Implementations.Playlists private readonly IUserManager _userManager; private readonly IProviderManager _providerManager; - public PlaylistManager(ILibraryManager libraryManager, IFileSystem fileSystem, ILibraryMonitor iLibraryMonitor, ILogger logger, IUserManager userManager, IProviderManager providerManager) + public PlaylistManager( + ILibraryManager libraryManager, + IFileSystem fileSystem, + ILibraryMonitor iLibraryMonitor, + ILoggerFactory loggerFactory, + IUserManager userManager, + IProviderManager providerManager) { _libraryManager = libraryManager; _fileSystem = fileSystem; _iLibraryMonitor = iLibraryMonitor; - _logger = logger; + _logger = loggerFactory.CreateLogger(nameof(PlaylistManager)); _userManager = userManager; _providerManager = providerManager; } diff --git a/Emby.Server.Implementations/ResourceFileManager.cs b/Emby.Server.Implementations/ResourceFileManager.cs index f54e3205a..6acc7e1d1 100644 --- a/Emby.Server.Implementations/ResourceFileManager.cs +++ b/Emby.Server.Implementations/ResourceFileManager.cs @@ -15,10 +15,13 @@ namespace Emby.Server.Implementations private readonly ILogger _logger; private readonly IHttpResultFactory _resultFactory; - public ResourceFileManager(IHttpResultFactory resultFactory, ILogger logger, IFileSystem fileSystem) + public ResourceFileManager( + IHttpResultFactory resultFactory, + ILoggerFactory loggerFactory, + IFileSystem fileSystem) { _resultFactory = resultFactory; - _logger = logger; + _logger = loggerFactory.CreateLogger("ResourceManager"); _fileSystem = fileSystem; } diff --git a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs index 09c348e24..a221ac475 100644 --- a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs +++ b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs @@ -61,12 +61,17 @@ namespace Emby.Server.Implementations.ScheduledTasks /// The application paths. /// The json serializer. /// The logger. - /// kernel - public TaskManager(IApplicationPaths applicationPaths, IJsonSerializer jsonSerializer, ILogger logger, IFileSystem fileSystem, ISystemEvents systemEvents) + /// kernel + public TaskManager( + IApplicationPaths applicationPaths, + IJsonSerializer jsonSerializer, + ILoggerFactory loggerFactory, + IFileSystem fileSystem, + ISystemEvents systemEvents) { ApplicationPaths = applicationPaths; JsonSerializer = jsonSerializer; - Logger = logger; + Logger = loggerFactory.CreateLogger(nameof(TaskManager)); _fileSystem = fileSystem; _systemEvents = systemEvents; diff --git a/Emby.Server.Implementations/Security/AuthenticationRepository.cs b/Emby.Server.Implementations/Security/AuthenticationRepository.cs index e0f174f9d..c81a93767 100644 --- a/Emby.Server.Implementations/Security/AuthenticationRepository.cs +++ b/Emby.Server.Implementations/Security/AuthenticationRepository.cs @@ -18,8 +18,8 @@ namespace Emby.Server.Implementations.Security private readonly IServerConfigurationManager _config; private readonly CultureInfo _usCulture = new CultureInfo("en-US"); - public AuthenticationRepository(ILogger logger, IServerConfigurationManager config) - : base(logger) + public AuthenticationRepository(ILoggerFactory loggerFactory, IServerConfigurationManager config) + : base(loggerFactory.CreateLogger(nameof(AuthenticationRepository))) { _config = config; DbFilePath = Path.Combine(config.ApplicationPaths.DataPath, "authentication.db"); diff --git a/Emby.Server.Implementations/Serialization/JsonSerializer.cs b/Emby.Server.Implementations/Serialization/JsonSerializer.cs index 60bf2d5a9..53ef5d60c 100644 --- a/Emby.Server.Implementations/Serialization/JsonSerializer.cs +++ b/Emby.Server.Implementations/Serialization/JsonSerializer.cs @@ -13,12 +13,11 @@ namespace Emby.Common.Implementations.Serialization public class JsonSerializer : IJsonSerializer { private readonly IFileSystem _fileSystem; - private readonly ILogger _logger; - public JsonSerializer(IFileSystem fileSystem, ILogger logger) + public JsonSerializer( + IFileSystem fileSystem) { _fileSystem = fileSystem; - _logger = logger; Configure(); } @@ -69,7 +68,6 @@ namespace Emby.Common.Implementations.Serialization private static Stream OpenFile(string path) { - //_logger.LogDebug("Deserializing file {0}", path); return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 131072); } diff --git a/Emby.Server.Implementations/Serialization/XmlSerializer.cs b/Emby.Server.Implementations/Serialization/XmlSerializer.cs index 22d6712ec..f7428eff7 100644 --- a/Emby.Server.Implementations/Serialization/XmlSerializer.cs +++ b/Emby.Server.Implementations/Serialization/XmlSerializer.cs @@ -17,10 +17,12 @@ namespace Emby.Server.Implementations.Serialization private readonly IFileSystem _fileSystem; private readonly ILogger _logger; - public MyXmlSerializer(IFileSystem fileSystem, ILogger logger) + public MyXmlSerializer( + IFileSystem fileSystem, + ILoggerFactory loggerFactory) { _fileSystem = fileSystem; - _logger = logger; + _logger = loggerFactory.CreateLogger("XmlSerializer"); } // Need to cache these diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index e60593198..b03345e03 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -90,10 +90,24 @@ namespace Emby.Server.Implementations.Session public event EventHandler SessionEnded; public event EventHandler SessionActivity; - public SessionManager(IUserDataManager userDataManager, ILogger logger, ILibraryManager libraryManager, IUserManager userManager, IMusicManager musicManager, IDtoService dtoService, IImageProcessor imageProcessor, IJsonSerializer jsonSerializer, IServerApplicationHost appHost, IHttpClient httpClient, IAuthenticationRepository authRepo, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, ITimerFactory timerFactory) + public SessionManager( + IUserDataManager userDataManager, + ILoggerFactory loggerFactory, + ILibraryManager libraryManager, + IUserManager userManager, + IMusicManager musicManager, + IDtoService dtoService, + IImageProcessor imageProcessor, + IJsonSerializer jsonSerializer, + IServerApplicationHost appHost, + IHttpClient httpClient, + IAuthenticationRepository authRepo, + IDeviceManager deviceManager, + IMediaSourceManager mediaSourceManager, + ITimerFactory timerFactory) { _userDataManager = userDataManager; - _logger = logger; + _logger = loggerFactory.CreateLogger(nameof(SessionManager)); _libraryManager = libraryManager; _userManager = userManager; _musicManager = musicManager; diff --git a/Emby.Server.Implementations/SystemEvents.cs b/Emby.Server.Implementations/SystemEvents.cs index 1297200f9..e4c54c3c5 100644 --- a/Emby.Server.Implementations/SystemEvents.cs +++ b/Emby.Server.Implementations/SystemEvents.cs @@ -1,6 +1,5 @@ using System; using MediaBrowser.Model.System; -using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations { @@ -10,12 +9,5 @@ namespace Emby.Server.Implementations public event EventHandler Suspend; public event EventHandler SessionLogoff; public event EventHandler SystemShutdown; - - private readonly ILogger _logger; - - public SystemEvents(ILogger logger) - { - _logger = logger; - } } } diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index 6e69ecb56..44377a897 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -121,7 +121,7 @@ namespace Emby.Server.Implementations.Updates private readonly string _packageRuntime; public InstallationManager( - ILogger logger, + ILoggerFactory loggerFactory, IApplicationHost appHost, IApplicationPaths appPaths, IHttpClient httpClient, @@ -131,9 +131,9 @@ namespace Emby.Server.Implementations.Updates ICryptoProvider cryptographyProvider, string packageRuntime) { - if (logger == null) + if (loggerFactory == null) { - throw new ArgumentNullException(nameof(logger)); + throw new ArgumentNullException(nameof(loggerFactory)); } CurrentInstallations = new List>(); @@ -147,7 +147,7 @@ namespace Emby.Server.Implementations.Updates _fileSystem = fileSystem; _cryptographyProvider = cryptographyProvider; _packageRuntime = packageRuntime; - _logger = logger; + _logger = loggerFactory.CreateLogger(nameof(InstallationManager)); } private static Version GetPackageVersion(PackageVersionInfo version) diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index d07761619..573c63385 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -89,7 +89,7 @@ namespace Jellyfin.Server // Allow all https requests ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; }); - var fileSystem = new ManagedFileSystem(_loggerFactory.CreateLogger("FileSystem"), environmentInfo, null, appPaths.TempDirectory, true); + var fileSystem = new ManagedFileSystem(_loggerFactory, environmentInfo, null, appPaths.TempDirectory, true); using (var appHost = new CoreAppHost( appPaths, @@ -98,12 +98,12 @@ namespace Jellyfin.Server fileSystem, environmentInfo, new NullImageEncoder(), - new SystemEvents(_loggerFactory.CreateLogger("SystemEvents")), - new NetworkManager(_loggerFactory.CreateLogger("NetworkManager"), environmentInfo))) + new SystemEvents(), + new NetworkManager(_loggerFactory, environmentInfo))) { appHost.Init(); - appHost.ImageProcessor.ImageEncoder = getImageEncoder(_logger, fileSystem, options, () => appHost.HttpClient, appPaths, environmentInfo, appHost.LocalizationManager); + appHost.ImageProcessor.ImageEncoder = getImageEncoder(_loggerFactory, fileSystem, options, () => appHost.HttpClient, appPaths, environmentInfo, appHost.LocalizationManager); _logger.LogInformation("Running startup tasks"); @@ -257,7 +257,7 @@ namespace Jellyfin.Server } public static IImageEncoder getImageEncoder( - ILogger logger, + ILoggerFactory loggerFactory, IFileSystem fileSystem, StartupOptions startupOptions, Func httpClient, @@ -267,11 +267,11 @@ namespace Jellyfin.Server { try { - return new SkiaEncoder(logger, appPaths, httpClient, fileSystem, localizationManager); + return new SkiaEncoder(loggerFactory, appPaths, httpClient, fileSystem, localizationManager); } catch (Exception ex) { - logger.LogInformation(ex, "Skia not available. Will fallback to NullIMageEncoder. {0}"); + _logger.LogInformation(ex, "Skia not available. Will fallback to NullIMageEncoder. {0}"); } return new NullImageEncoder(); diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index 63642b571..6d82384cc 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -70,7 +70,8 @@ namespace MediaBrowser.MediaEncoding.Encoder private readonly string _originalFFProbePath; private readonly int DefaultImageExtractionTimeoutMs; - public MediaEncoder(ILogger logger, + public MediaEncoder( + ILoggerFactory loggerFactory, IJsonSerializer jsonSerializer, string ffMpegPath, string ffProbePath, @@ -89,7 +90,7 @@ namespace MediaBrowser.MediaEncoding.Encoder IProcessFactory processFactory, int defaultImageExtractionTimeoutMs) { - _logger = logger; + _logger = loggerFactory.CreateLogger(nameof(MediaEncoder)); _jsonSerializer = jsonSerializer; ConfigurationManager = configurationManager; FileSystem = fileSystem; diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs index cd915b37b..59a624433 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs @@ -35,8 +35,9 @@ namespace MediaBrowser.MediaEncoding.Subtitles private readonly IMediaSourceManager _mediaSourceManager; private readonly IProcessFactory _processFactory; - public SubtitleEncoder(ILibraryManager libraryManager, - ILogger logger, + public SubtitleEncoder( + ILibraryManager libraryManager, + ILoggerFactory loggerFactory, IApplicationPaths appPaths, IFileSystem fileSystem, IMediaEncoder mediaEncoder, @@ -46,7 +47,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles IProcessFactory processFactory) { _libraryManager = libraryManager; - _logger = logger; + _logger = loggerFactory.CreateLogger(nameof(SubtitleEncoder)); _appPaths = appPaths; _fileSystem = fileSystem; _mediaEncoder = mediaEncoder; diff --git a/MediaBrowser.Providers/Chapters/ChapterManager.cs b/MediaBrowser.Providers/Chapters/ChapterManager.cs index aaadfce80..45e87f137 100644 --- a/MediaBrowser.Providers/Chapters/ChapterManager.cs +++ b/MediaBrowser.Providers/Chapters/ChapterManager.cs @@ -16,10 +16,14 @@ namespace MediaBrowser.Providers.Chapters private readonly IServerConfigurationManager _config; private readonly IItemRepository _itemRepo; - public ChapterManager(ILibraryManager libraryManager, ILogger logger, IServerConfigurationManager config, IItemRepository itemRepo) + public ChapterManager( + ILibraryManager libraryManager, + ILoggerFactory loggerFactory, + IServerConfigurationManager config, + IItemRepository itemRepo) { _libraryManager = libraryManager; - _logger = logger; + _logger = loggerFactory.CreateLogger(nameof(ChapterManager)); _config = config; _itemRepo = itemRepo; } diff --git a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs index 544cfba0d..468ba730a 100644 --- a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs +++ b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs @@ -37,9 +37,15 @@ namespace MediaBrowser.Providers.Subtitles private ILocalizationManager _localization; - public SubtitleManager(ILogger logger, IFileSystem fileSystem, ILibraryMonitor monitor, IMediaSourceManager mediaSourceManager, IServerConfigurationManager config, ILocalizationManager localizationManager) + public SubtitleManager( + ILoggerFactory loggerFactory, + IFileSystem fileSystem, + ILibraryMonitor monitor, + IMediaSourceManager mediaSourceManager, + IServerConfigurationManager config, + ILocalizationManager localizationManager) { - _logger = logger; + _logger = loggerFactory.CreateLogger(nameof(SubtitleManager)); _fileSystem = fileSystem; _monitor = monitor; _mediaSourceManager = mediaSourceManager; -- cgit v1.2.3