From 0f8b3c634708ce8e7b2e2ae6fed87b6b943b5bca Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Thu, 13 Dec 2018 14:18:25 +0100 Subject: Use Microsoft.Extensions.Logging abstraction --- MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs | 4 ++-- MediaBrowser.Controller/MediaEncoding/JobLogger.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'MediaBrowser.Controller/MediaEncoding') diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs index 3d2871e650..e1762fbdad 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs @@ -8,7 +8,7 @@ using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; -using MediaBrowser.Model.Logging; +using Microsoft.Extensions.Logging; using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.Drawing; using MediaBrowser.Model.Session; @@ -738,7 +738,7 @@ namespace MediaBrowser.Controller.MediaEncoding } catch (Exception ex) { - _logger.ErrorException("Error disposing iso mount", ex); + _logger.LogError(ex, "Error disposing iso mount"); } IsoMount = null; diff --git a/MediaBrowser.Controller/MediaEncoding/JobLogger.cs b/MediaBrowser.Controller/MediaEncoding/JobLogger.cs index 5f3f79d775..539aab7b3a 100644 --- a/MediaBrowser.Controller/MediaEncoding/JobLogger.cs +++ b/MediaBrowser.Controller/MediaEncoding/JobLogger.cs @@ -1,10 +1,10 @@ using MediaBrowser.Model.Extensions; -using MediaBrowser.Model.Logging; using System; using System.Globalization; using System.IO; using System.Linq; using System.Text; +using Microsoft.Extension.Logging; namespace MediaBrowser.Controller.MediaEncoding { @@ -43,7 +43,7 @@ namespace MediaBrowser.Controller.MediaEncoding } catch (Exception ex) { - _logger.ErrorException("Error reading ffmpeg log", ex); + _logger.LogError(ex, "Error reading ffmpeg log"); } } -- cgit v1.2.3 From 0c1b9d3bff7041b7d3b875885b8745680afcee72 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Sat, 15 Dec 2018 00:48:06 +0100 Subject: Rebase --- .../HttpServer/WebSocketConnection.cs | 2 +- Emby.Server.Implementations/SystemEvents.cs | 1 - Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs | 4 +- MediaBrowser.Api/ApiEntryPoint.cs | 36 ++++++++-------- MediaBrowser.Api/LiveTv/ProgressiveFileCopier.cs | 2 +- MediaBrowser.Api/Playback/BaseStreamingService.cs | 13 +++--- MediaBrowser.Api/Playback/Hls/BaseHlsService.cs | 7 ++-- MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs | 19 +++++---- MediaBrowser.Api/Playback/MediaInfoService.cs | 7 ++-- .../Progressive/BaseProgressiveStreamingService.cs | 2 + .../Progressive/ProgressiveStreamWriter.cs | 7 ++-- MediaBrowser.Api/Playback/StreamState.cs | 8 ++-- MediaBrowser.Api/Playback/TranscodingThrottler.cs | 22 +++++----- .../MediaEncoding/EncodingJobInfo.cs | 2 +- MediaBrowser.Controller/MediaEncoding/JobLogger.cs | 2 +- MediaBrowser.MediaEncoding/Encoder/AudioEncoder.cs | 2 +- MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs | 16 ++++---- .../Encoder/EncoderValidator.cs | 22 +++++----- MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs | 6 +-- .../Encoder/EncodingJobFactory.cs | 2 +- .../Encoder/FontConfigLoader.cs | 14 +++---- MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 38 ++++++++--------- MediaBrowser.MediaEncoding/Encoder/VideoEncoder.cs | 4 +- .../Probing/ProbeResultNormalizer.cs | 6 +-- .../Subtitles/OpenSubtitleDownloader.cs | 18 ++++---- MediaBrowser.MediaEncoding/Subtitles/SrtParser.cs | 4 +- .../Subtitles/SubtitleEncoder.cs | 48 +++++++++++----------- 27 files changed, 158 insertions(+), 156 deletions(-) (limited to 'MediaBrowser.Controller/MediaEncoding') diff --git a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs index ca8723dde6..037bdde771 100644 --- a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs +++ b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs @@ -180,7 +180,7 @@ namespace Emby.Server.Implementations.HttpServer if (!message.StartsWith("{", StringComparison.OrdinalIgnoreCase)) { // This info is useful sometimes but also clogs up the log - //_logger.Error("Received web socket message that is not a json structure: " + message); + //_lLogError("Received web socket message that is not a json structure: " + message); return; } diff --git a/Emby.Server.Implementations/SystemEvents.cs b/Emby.Server.Implementations/SystemEvents.cs index e529628332..f39d63002a 100644 --- a/Emby.Server.Implementations/SystemEvents.cs +++ b/Emby.Server.Implementations/SystemEvents.cs @@ -1,5 +1,4 @@ using System; -using MediaBrowser.Common.Events; using Microsoft.Extensions.Logging; using MediaBrowser.Model.System; diff --git a/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs b/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs index 2817d9e8ce..bbcd1eed35 100644 --- a/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs +++ b/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs @@ -87,7 +87,7 @@ namespace Emby.XmlTv.Classes if (string.IsNullOrEmpty(id)) { - //Logger.Error("No id found for channel row"); + //LLogError("No id found for channel row"); // Log.Error(" channel#{0} doesnt contain an id", iChannel); return null; } @@ -130,7 +130,7 @@ namespace Emby.XmlTv.Classes if (string.IsNullOrEmpty(result.DisplayName)) { - //Logger.Error("No display-name found for channel {0}", id); + //LLogError("No display-name found for channel {0}", id); return null; } diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs index 1e99b8c7a1..b51bdf6fd5 100644 --- a/MediaBrowser.Api/ApiEntryPoint.cs +++ b/MediaBrowser.Api/ApiEntryPoint.cs @@ -147,7 +147,7 @@ namespace MediaBrowser.Api } catch (Exception ex) { - Logger.ErrorException("Error deleting encoded media cache", ex); + Logger.LogError("Error deleting encoded media cache", ex); } } @@ -378,7 +378,7 @@ namespace MediaBrowser.Api public void OnTranscodeEndRequest(TranscodingJob job) { job.ActiveRequestCount--; - //Logger.Debug("OnTranscodeEndRequest job.ActiveRequestCount={0}", job.ActiveRequestCount); + //Logger.LogDebug("OnTranscodeEndRequest job.ActiveRequestCount={0}", job.ActiveRequestCount); if (job.ActiveRequestCount <= 0) { PingTimer(job, false); @@ -391,7 +391,7 @@ namespace MediaBrowser.Api throw new ArgumentNullException("playSessionId"); } - //Logger.Debug("PingTranscodingJob PlaySessionId={0} isUsedPaused: {1}", playSessionId, isUserPaused); + //Logger.LogDebug("PingTranscodingJob PlaySessionId={0} isUsedPaused: {1}", playSessionId, isUserPaused); List jobs; @@ -406,7 +406,7 @@ namespace MediaBrowser.Api { if (isUserPaused.HasValue) { - //Logger.Debug("Setting job.IsUserPaused to {0}. jobId: {1}", isUserPaused, job.Id); + //Logger.LogDebug("Setting job.IsUserPaused to {0}. jobId: {1}", isUserPaused, job.Id); job.IsUserPaused = isUserPaused.Value; } PingTimer(job, true); @@ -461,7 +461,7 @@ namespace MediaBrowser.Api } } - Logger.Info("Transcoding kill timer stopped for JobId {0} PlaySessionId {1}. Killing transcoding", job.Id, job.PlaySessionId); + Logger.LogInformation("Transcoding kill timer stopped for JobId {0} PlaySessionId {1}. Killing transcoding", job.Id, job.PlaySessionId); KillTranscodingJob(job, true, path => true); } @@ -525,7 +525,7 @@ namespace MediaBrowser.Api { job.DisposeKillTimer(); - Logger.Debug("KillTranscodingJob - JobId {0} PlaySessionId {1}. Killing transcoding", job.Id, job.PlaySessionId); + Logger.LogDebug("KillTranscodingJob - JobId {0} PlaySessionId {1}. Killing transcoding", job.Id, job.PlaySessionId); lock (_activeTranscodingJobs) { @@ -557,7 +557,7 @@ namespace MediaBrowser.Api { try { - Logger.Info("Stopping ffmpeg process with q command for {0}", job.Path); + Logger.LogInformation("Stopping ffmpeg process with q command for {0}", job.Path); //process.Kill(); process.StandardInput.WriteLine("q"); @@ -565,13 +565,13 @@ namespace MediaBrowser.Api // Need to wait because killing is asynchronous if (!process.WaitForExit(5000)) { - Logger.Info("Killing ffmpeg process for {0}", job.Path); + Logger.LogInformation("Killing ffmpeg process for {0}", job.Path); process.Kill(); } } catch (Exception ex) { - Logger.ErrorException("Error killing transcoding job for {0}", ex, job.Path); + Logger.LogError("Error killing transcoding job for {0}", ex, job.Path); } } } @@ -589,7 +589,7 @@ namespace MediaBrowser.Api } catch (Exception ex) { - Logger.ErrorException("Error closing live stream for {0}", ex, job.Path); + Logger.LogError("Error closing live stream for {0}", ex, job.Path); } } } @@ -601,7 +601,7 @@ namespace MediaBrowser.Api return; } - Logger.Info("Deleting partial stream file(s) {0}", path); + Logger.LogInformation("Deleting partial stream file(s) {0}", path); await Task.Delay(delayMs).ConfigureAwait(false); @@ -622,13 +622,13 @@ namespace MediaBrowser.Api } catch (IOException) { - //Logger.ErrorException("Error deleting partial stream file(s) {0}", ex, path); + //Logger.LogError("Error deleting partial stream file(s) {0}", ex, path); DeletePartialStreamFiles(path, jobType, retryCount + 1, 500); } catch { - //Logger.ErrorException("Error deleting partial stream file(s) {0}", ex, path); + //Logger.LogError("Error deleting partial stream file(s) {0}", ex, path); } } @@ -660,7 +660,7 @@ namespace MediaBrowser.Api { try { - //Logger.Debug("Deleting HLS file {0}", file); + //Logger.LogDebug("Deleting HLS file {0}", file); _fileSystem.DeleteFile(file); } catch (FileNotFoundException) @@ -670,7 +670,7 @@ namespace MediaBrowser.Api catch (IOException ex) { e = ex; - //Logger.ErrorException("Error deleting HLS file {0}", ex, file); + //Logger.LogError("Error deleting HLS file {0}", ex, file); } } @@ -802,12 +802,12 @@ namespace MediaBrowser.Api { if (KillTimer == null) { - //Logger.Debug("Starting kill timer at {0}ms. JobId {1} PlaySessionId {2}", intervalMs, Id, PlaySessionId); + //Logger.LogDebug("Starting kill timer at {0}ms. JobId {1} PlaySessionId {2}", intervalMs, Id, PlaySessionId); KillTimer = _timerFactory.Create(callback, this, intervalMs, Timeout.Infinite); } else { - //Logger.Debug("Changing kill timer to {0}ms. JobId {1} PlaySessionId {2}", intervalMs, Id, PlaySessionId); + //Logger.LogDebug("Changing kill timer to {0}ms. JobId {1} PlaySessionId {2}", intervalMs, Id, PlaySessionId); KillTimer.Change(intervalMs, Timeout.Infinite); } } @@ -826,7 +826,7 @@ namespace MediaBrowser.Api { var intervalMs = PingTimeout; - //Logger.Debug("Changing kill timer to {0}ms. JobId {1} PlaySessionId {2}", intervalMs, Id, PlaySessionId); + //Logger.LogDebug("Changing kill timer to {0}ms. JobId {1} PlaySessionId {2}", intervalMs, Id, PlaySessionId); KillTimer.Change(intervalMs, Timeout.Infinite); } } diff --git a/MediaBrowser.Api/LiveTv/ProgressiveFileCopier.cs b/MediaBrowser.Api/LiveTv/ProgressiveFileCopier.cs index bf8aba8dfe..07ac7f28d8 100644 --- a/MediaBrowser.Api/LiveTv/ProgressiveFileCopier.cs +++ b/MediaBrowser.Api/LiveTv/ProgressiveFileCopier.cs @@ -5,10 +5,10 @@ using System.Threading; using System.Threading.Tasks; using MediaBrowser.Controller.Library; using MediaBrowser.Model.IO; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.Services; using MediaBrowser.Model.System; using MediaBrowser.Controller.IO; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.LiveTv { diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 9c2e0e9d8f..37cc8d2d76 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -24,6 +24,7 @@ using MediaBrowser.Controller; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Diagnostics; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Playback { @@ -248,7 +249,7 @@ namespace MediaBrowser.Api.Playback cancellationTokenSource); var commandLineLogMessage = process.StartInfo.FileName + " " + process.StartInfo.Arguments; - Logger.Info(commandLineLogMessage); + Logger.LogInformation(commandLineLogMessage); var logFilePrefix = "ffmpeg-transcode"; if (state.VideoRequest != null && string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase) && string.Equals(state.OutputAudioCodec, "copy", StringComparison.OrdinalIgnoreCase)) @@ -277,7 +278,7 @@ namespace MediaBrowser.Api.Playback } catch (Exception ex) { - Logger.ErrorException("Error starting ffmpeg", ex); + Logger.LogError("Error starting ffmpeg", ex); ApiEntryPoint.Instance.OnTranscodeFailedToStart(outputPath, TranscodingJobType, state); @@ -351,16 +352,16 @@ namespace MediaBrowser.Api.Playback job.HasExited = true; } - Logger.Debug("Disposing stream resources"); + Logger.LogDebug("Disposing stream resources"); state.Dispose(); try { - Logger.Info("FFMpeg exited with code {0}", process.ExitCode); + Logger.LogInformation("FFMpeg exited with code {0}", process.ExitCode); } catch { - Logger.Error("FFMpeg exited with an error."); + Logger.LogError("FFMpeg exited with an error."); } // This causes on exited to be called twice: @@ -371,7 +372,7 @@ namespace MediaBrowser.Api.Playback //} //catch (Exception ex) //{ - // Logger.ErrorException("Error disposing ffmpeg.", ex); + // Logger.LogError("Error disposing ffmpeg.", ex); //} } diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs index a0f4a2e715..7ef7b81e63 100644 --- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs @@ -15,6 +15,7 @@ using System.Threading; using System.Threading.Tasks; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Configuration; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Playback.Hls { @@ -185,7 +186,7 @@ namespace MediaBrowser.Api.Playback.Hls protected virtual async Task WaitForMinimumSegmentCount(string playlist, int segmentCount, CancellationToken cancellationToken) { - Logger.Debug("Waiting for {0} segments in {1}", segmentCount, playlist); + Logger.LogDebug("Waiting for {0} segments in {1}", segmentCount, playlist); while (!cancellationToken.IsCancellationRequested) { @@ -207,7 +208,7 @@ namespace MediaBrowser.Api.Playback.Hls count++; if (count >= segmentCount) { - Logger.Debug("Finished waiting for {0} segments in {1}", segmentCount, playlist); + Logger.LogDebug("Finished waiting for {0} segments in {1}", segmentCount, playlist); return; } } @@ -330,4 +331,4 @@ namespace MediaBrowser.Api.Playback.Hls { } } -} \ No newline at end of file +} diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index 0525c8cc48..7dda91e5a9 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -21,6 +21,7 @@ using System.Threading.Tasks; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Services; using MimeTypes = MediaBrowser.Model.Net.MimeTypes; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Playback.Hls { @@ -190,17 +191,17 @@ namespace MediaBrowser.Api.Playback.Hls if (currentTranscodingIndex == null) { - Logger.Debug("Starting transcoding because currentTranscodingIndex=null"); + Logger.LogDebug("Starting transcoding because currentTranscodingIndex=null"); startTranscoding = true; } else if (requestedIndex < currentTranscodingIndex.Value) { - Logger.Debug("Starting transcoding because requestedIndex={0} and currentTranscodingIndex={1}", requestedIndex, currentTranscodingIndex); + Logger.LogDebug("Starting transcoding because requestedIndex={0} and currentTranscodingIndex={1}", requestedIndex, currentTranscodingIndex); startTranscoding = true; } else if (requestedIndex - currentTranscodingIndex.Value > segmentGapRequiringTranscodingChange) { - Logger.Debug("Starting transcoding because segmentGap is {0} and max allowed gap is {1}. requestedIndex={2}", requestedIndex - currentTranscodingIndex.Value, segmentGapRequiringTranscodingChange, requestedIndex); + Logger.LogDebug("Starting transcoding because segmentGap is {0} and max allowed gap is {1}. requestedIndex={2}", requestedIndex - currentTranscodingIndex.Value, segmentGapRequiringTranscodingChange, requestedIndex); startTranscoding = true; } if (startTranscoding) @@ -245,13 +246,13 @@ namespace MediaBrowser.Api.Playback.Hls } } - //Logger.Info("waiting for {0}", segmentPath); + //Logger.LogInformation("waiting for {0}", segmentPath); //while (!File.Exists(segmentPath)) //{ // await Task.Delay(50, cancellationToken).ConfigureAwait(false); //} - Logger.Info("returning {0}", segmentPath); + Logger.LogInformation("returning {0}", segmentPath); job = job ?? ApiEntryPoint.Instance.OnTranscodeBeginRequest(playlistPath, TranscodingJobType); return await GetSegmentResult(state, playlistPath, segmentPath, segmentExtension, requestedIndex, job, cancellationToken).ConfigureAwait(false); } @@ -358,7 +359,7 @@ namespace MediaBrowser.Api.Playback.Hls return; } - Logger.Debug("Deleting partial HLS file {0}", path); + Logger.LogDebug("Deleting partial HLS file {path}", path); try { @@ -366,7 +367,7 @@ namespace MediaBrowser.Api.Playback.Hls } catch (IOException ex) { - Logger.ErrorException("Error deleting partial stream file(s) {0}", ex, path); + Logger.LogError("Error deleting partial stream file(s) {0}", ex, path); var task = Task.Delay(100); Task.WaitAll(task); @@ -374,7 +375,7 @@ namespace MediaBrowser.Api.Playback.Hls } catch (Exception ex) { - Logger.ErrorException("Error deleting partial stream file(s) {0}", ex, path); + Logger.LogError("Error deleting partial stream file(s) {0}", ex, path); } } @@ -968,4 +969,4 @@ namespace MediaBrowser.Api.Playback.Hls ).Trim(); } } -} \ No newline at end of file +} diff --git a/MediaBrowser.Api/Playback/MediaInfoService.cs b/MediaBrowser.Api/Playback/MediaInfoService.cs index 2db0f8f419..6dafe134ce 100644 --- a/MediaBrowser.Api/Playback/MediaInfoService.cs +++ b/MediaBrowser.Api/Playback/MediaInfoService.cs @@ -18,6 +18,7 @@ using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Playback { @@ -381,11 +382,11 @@ namespace MediaBrowser.Api.Playback if (item is Audio) { - Logger.Info("User policy for {0}. EnableAudioPlaybackTranscoding: {1}", user.Name, user.Policy.EnableAudioPlaybackTranscoding); + Logger.LogInformation("User policy for {0}. EnableAudioPlaybackTranscoding: {1}", user.Name, user.Policy.EnableAudioPlaybackTranscoding); } else { - Logger.Info("User policy for {0}. EnablePlaybackRemuxing: {1} EnableVideoPlaybackTranscoding: {2} EnableAudioPlaybackTranscoding: {3}", + Logger.LogInformation("User policy for {0}. EnablePlaybackRemuxing: {1} EnableVideoPlaybackTranscoding: {2} EnableAudioPlaybackTranscoding: {3}", user.Name, user.Policy.EnablePlaybackRemuxing, user.Policy.EnableVideoPlaybackTranscoding, @@ -525,7 +526,7 @@ namespace MediaBrowser.Api.Playback { var isInLocalNetwork = _networkManager.IsInLocalNetwork(Request.RemoteIp); - Logger.Info("RemoteClientBitrateLimit: {0}, RemoteIp: {1}, IsInLocalNetwork: {2}", remoteClientMaxBitrate, Request.RemoteIp, isInLocalNetwork); + Logger.LogInformation("RemoteClientBitrateLimit: {0}, RemoteIp: {1}, IsInLocalNetwork: {2}", remoteClientMaxBitrate, Request.RemoteIp, isInLocalNetwork); if (!isInLocalNetwork) { maxBitrate = Math.Min(maxBitrate ?? remoteClientMaxBitrate, remoteClientMaxBitrate); diff --git a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs index 44261f2d55..cc59b1049f 100644 --- a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs +++ b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs @@ -17,6 +17,8 @@ using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.Services; using MediaBrowser.Model.System; +using Microsoft.Extensions.Logging; +using MediaBrowser.Api.LiveTv; namespace MediaBrowser.Api.Playback.Progressive { diff --git a/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs b/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs index 9839a7a9aa..ed2930b4d4 100644 --- a/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs +++ b/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs @@ -1,16 +1,15 @@ -using MediaBrowser.Model.Logging; -using System; +using System; using System.IO; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.IO; using MediaBrowser.Controller.Net; using System.Collections.Generic; - using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Library; using MediaBrowser.Model.Services; using MediaBrowser.Model.System; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Playback.Progressive { @@ -110,7 +109,7 @@ namespace MediaBrowser.Api.Playback.Progressive } //var position = fs.Position; - //_logger.Debug("Streamed {0} bytes to position {1} from file {2}", bytesRead, position, path); + //_logger.LogDebug("Streamed {0} bytes to position {1} from file {2}", bytesRead, position, path); if (bytesRead == 0) { diff --git a/MediaBrowser.Api/Playback/StreamState.cs b/MediaBrowser.Api/Playback/StreamState.cs index db5d256c47..981a4725d1 100644 --- a/MediaBrowser.Api/Playback/StreamState.cs +++ b/MediaBrowser.Api/Playback/StreamState.cs @@ -4,7 +4,6 @@ using MediaBrowser.Model.Drawing; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; -using MediaBrowser.Model.Logging; using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.Net; using System; @@ -14,6 +13,7 @@ using System.IO; using System.Linq; using System.Threading; using MediaBrowser.Controller.MediaEncoding; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Playback { @@ -162,7 +162,7 @@ namespace MediaBrowser.Api.Playback } catch (Exception ex) { - _logger.ErrorException("Error disposing log stream", ex); + _logger.LogError("Error disposing log stream", ex); } LogFileStream = null; @@ -179,7 +179,7 @@ namespace MediaBrowser.Api.Playback } catch (Exception ex) { - _logger.ErrorException("Error disposing TranscodingThrottler", ex); + _logger.LogError("Error disposing TranscodingThrottler", ex); } TranscodingThrottler = null; @@ -196,7 +196,7 @@ namespace MediaBrowser.Api.Playback } catch (Exception ex) { - _logger.ErrorException("Error closing media source", ex); + _logger.LogError("Error closing media source", ex); } } } diff --git a/MediaBrowser.Api/Playback/TranscodingThrottler.cs b/MediaBrowser.Api/Playback/TranscodingThrottler.cs index c42d0c3e4c..47f1f777af 100644 --- a/MediaBrowser.Api/Playback/TranscodingThrottler.cs +++ b/MediaBrowser.Api/Playback/TranscodingThrottler.cs @@ -1,9 +1,9 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Model.Configuration; -using MediaBrowser.Model.Logging; using System; using MediaBrowser.Model.IO; using MediaBrowser.Model.Threading; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api.Playback { @@ -60,7 +60,7 @@ namespace MediaBrowser.Api.Playback { if (!_isPaused) { - _logger.Debug("Sending pause command to ffmpeg"); + _logger.LogDebug("Sending pause command to ffmpeg"); try { @@ -69,7 +69,7 @@ namespace MediaBrowser.Api.Playback } catch (Exception ex) { - _logger.ErrorException("Error pausing transcoding", ex); + _logger.LogError("Error pausing transcoding", ex); } } } @@ -78,7 +78,7 @@ namespace MediaBrowser.Api.Playback { if (_isPaused) { - _logger.Debug("Sending unpause command to ffmpeg"); + _logger.LogDebug("Sending unpause command to ffmpeg"); try { @@ -87,7 +87,7 @@ namespace MediaBrowser.Api.Playback } catch (Exception ex) { - _logger.ErrorException("Error unpausing transcoding", ex); + _logger.LogError("Error unpausing transcoding", ex); } } } @@ -110,11 +110,11 @@ namespace MediaBrowser.Api.Playback if (gap < targetGap) { - //_logger.Debug("Not throttling transcoder gap {0} target gap {1}", gap, targetGap); + //_logger.LogDebug("Not throttling transcoder gap {0} target gap {1}", gap, targetGap); return false; } - //_logger.Debug("Throttling transcoder gap {0} target gap {1}", gap, targetGap); + //_logger.LogDebug("Throttling transcoder gap {0} target gap {1}", gap, targetGap); return true; } @@ -135,21 +135,21 @@ namespace MediaBrowser.Api.Playback if (gap < targetGap) { - //_logger.Debug("Not throttling transcoder gap {0} target gap {1} bytes downloaded {2}", gap, targetGap, bytesDownloaded); + //_logger.LogDebug("Not throttling transcoder gap {0} target gap {1} bytes downloaded {2}", gap, targetGap, bytesDownloaded); return false; } - //_logger.Debug("Throttling transcoder gap {0} target gap {1} bytes downloaded {2}", gap, targetGap, bytesDownloaded); + //_logger.LogDebug("Throttling transcoder gap {0} target gap {1} bytes downloaded {2}", gap, targetGap, bytesDownloaded); return true; } catch { - //_logger.Error("Error getting output size"); + //_logger.LogError("Error getting output size"); return false; } } - //_logger.Debug("No throttle data for " + path); + //_logger.LogDebug("No throttle data for " + path); return false; } diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs index e1762fbdad..3ec4e3bb7b 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs @@ -8,10 +8,10 @@ using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.Drawing; using MediaBrowser.Model.Session; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Controller.MediaEncoding { diff --git a/MediaBrowser.Controller/MediaEncoding/JobLogger.cs b/MediaBrowser.Controller/MediaEncoding/JobLogger.cs index 539aab7b3a..8bb826bd1e 100644 --- a/MediaBrowser.Controller/MediaEncoding/JobLogger.cs +++ b/MediaBrowser.Controller/MediaEncoding/JobLogger.cs @@ -4,7 +4,7 @@ using System.Globalization; using System.IO; using System.Linq; using System.Text; -using Microsoft.Extension.Logging; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Controller.MediaEncoding { diff --git a/MediaBrowser.MediaEncoding/Encoder/AudioEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/AudioEncoder.cs index 566e7946d3..2a874eba16 100644 --- a/MediaBrowser.MediaEncoding/Encoder/AudioEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/AudioEncoder.cs @@ -3,7 +3,7 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.Session; using MediaBrowser.Model.IO; -using MediaBrowser.Model.Logging; +using Microsoft.Extensions.Logging; using System; using MediaBrowser.Model.Diagnostics; diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index 3383276bcb..1fd34c8fdf 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -7,7 +7,7 @@ using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; -using MediaBrowser.Model.Logging; +using Microsoft.Extensions.Logging; using MediaBrowser.Model.MediaInfo; using System; using System.Collections.Generic; @@ -105,7 +105,7 @@ namespace MediaBrowser.MediaEncoding.Encoder OnTranscodeBeginning(encodingJob); var commandLineLogMessage = process.StartInfo.FileName + " " + process.StartInfo.Arguments; - Logger.Info(commandLineLogMessage); + Logger.LogInformation(commandLineLogMessage); var logFilePath = Path.Combine(ConfigurationManager.CommonApplicationPaths.LogDirectoryPath, "transcode-" + Guid.NewGuid() + ".txt"); FileSystem.CreateDirectory(FileSystem.GetDirectoryName(logFilePath)); @@ -124,7 +124,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } catch (Exception ex) { - Logger.ErrorException("Error starting ffmpeg", ex); + Logger.LogError("Error starting ffmpeg", ex); OnTranscodeFailedToStart(encodingJob.OutputFilePath, encodingJob); @@ -150,7 +150,7 @@ namespace MediaBrowser.MediaEncoding.Encoder private void Cancel(IProcess process, EncodingJob job) { - Logger.Info("Killing ffmpeg process for {0}", job.OutputFilePath); + Logger.LogInformation("Killing ffmpeg process for {0}", job.OutputFilePath); //process.Kill(); process.StandardInput.WriteLine("q"); @@ -167,7 +167,7 @@ namespace MediaBrowser.MediaEncoding.Encoder { job.HasExited = true; - Logger.Debug("Disposing stream resources"); + Logger.LogDebug("Disposing stream resources"); job.Dispose(); var isSuccesful = false; @@ -175,13 +175,13 @@ namespace MediaBrowser.MediaEncoding.Encoder try { var exitCode = process.ExitCode; - Logger.Info("FFMpeg exited with code {0}", exitCode); + Logger.LogInformation("FFMpeg exited with code {0}", exitCode); isSuccesful = exitCode == 0; } catch { - Logger.Error("FFMpeg exited with an error."); + Logger.LogError("FFMpeg exited with an error."); } if (isSuccesful && !job.IsCancelled) @@ -231,7 +231,7 @@ namespace MediaBrowser.MediaEncoding.Encoder //} //catch (Exception ex) //{ - // Logger.ErrorException("Error disposing ffmpeg.", ex); + // Logger.LogError("Error disposing ffmpeg.", ex); //} } diff --git a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs index 59f3576ec8..9653e561c0 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using MediaBrowser.Model.Diagnostics; -using MediaBrowser.Model.Logging; +using Microsoft.Extensions.Logging; namespace MediaBrowser.MediaEncoding.Encoder { @@ -20,12 +20,12 @@ namespace MediaBrowser.MediaEncoding.Encoder public Tuple, List> Validate(string encoderPath) { - _logger.Info("Validating media encoder at {0}", encoderPath); + _logger.LogInformation("Validating media encoder at {0}", encoderPath); var decoders = GetDecoders(encoderPath); var encoders = GetEncoders(encoderPath); - _logger.Info("Encoder validation complete"); + _logger.LogInformation("Encoder validation complete"); return new Tuple, List>(decoders, encoders); } @@ -41,7 +41,7 @@ namespace MediaBrowser.MediaEncoding.Encoder { if (logOutput) { - _logger.ErrorException("Error validating encoder", ex); + _logger.LogError("Error validating encoder", ex); } } @@ -50,7 +50,7 @@ namespace MediaBrowser.MediaEncoding.Encoder return false; } - _logger.Info("ffmpeg info: {0}", output); + _logger.LogInformation("ffmpeg info: {0}", output); if (output.IndexOf("Libav developers", StringComparison.OrdinalIgnoreCase) != -1) { @@ -80,7 +80,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } catch (Exception ) { - //_logger.ErrorException("Error detecting available decoders", ex); + //_logger.LogError("Error detecting available decoders", ex); } var found = new List(); @@ -107,7 +107,7 @@ namespace MediaBrowser.MediaEncoding.Encoder if (output.IndexOf(srch, StringComparison.OrdinalIgnoreCase) != -1) { - _logger.Info("Decoder available: " + codec); + _logger.LogInformation("Decoder available: " + codec); found.Add(codec); } } @@ -163,7 +163,7 @@ namespace MediaBrowser.MediaEncoding.Encoder { if (index < required.Length - 1) { - _logger.Info("Encoder available: " + codec); + _logger.LogInformation("Encoder available: " + codec); } found.Add(codec); @@ -187,7 +187,7 @@ namespace MediaBrowser.MediaEncoding.Encoder RedirectStandardOutput = true }); - _logger.Info("Running {0} {1}", path, arguments); + _logger.LogInformation("Running {0} {1}", path, arguments); using (process) { @@ -199,7 +199,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } catch { - _logger.Info("Killing process {0} {1}", path, arguments); + _logger.LogInformation("Killing process {0} {1}", path, arguments); // Hate having to do this try @@ -208,7 +208,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } catch (Exception ex1) { - _logger.ErrorException("Error killing process", ex1); + _logger.LogError("Error killing process", ex1); } throw; diff --git a/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs b/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs index 294181fccc..dcaf4a2b17 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs @@ -5,7 +5,6 @@ using MediaBrowser.Model.Drawing; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; -using MediaBrowser.Model.Logging; using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.Net; using System; @@ -14,6 +13,7 @@ using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; +using Microsoft.Extensions.Logging; namespace MediaBrowser.MediaEncoding.Encoder { @@ -81,7 +81,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } catch (Exception ex) { - _logger.ErrorException("Error disposing log stream", ex); + _logger.LogError("Error disposing log stream", ex); } LogFileStream = null; @@ -98,7 +98,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } catch (Exception ex) { - _logger.ErrorException("Error closing media source", ex); + _logger.LogError("Error closing media source", ex); } } } diff --git a/MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.cs b/MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.cs index 8d8d05a16e..4e6ee89e1b 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncodingJobFactory.cs @@ -5,7 +5,7 @@ using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Logging; +using Microsoft.Extensions.Logging; using MediaBrowser.Model.MediaInfo; using System; using System.Collections.Generic; diff --git a/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs b/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs index e21292cbd7..2f0161962e 100644 --- a/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs +++ b/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs @@ -10,7 +10,7 @@ using MediaBrowser.Common.Net; using MediaBrowser.Common.Progress; using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; -using MediaBrowser.Model.Logging; +using Microsoft.Extensions.Logging; using MediaBrowser.Model.Net; namespace MediaBrowser.MediaEncoding.Encoder @@ -72,12 +72,12 @@ namespace MediaBrowser.MediaEncoding.Encoder catch (HttpException ex) { // Don't let the server crash because of this - _logger.ErrorException("Error downloading ffmpeg font files", ex); + _logger.LogError("Error downloading ffmpeg font files", ex); } catch (Exception ex) { // Don't let the server crash because of this - _logger.ErrorException("Error writing ffmpeg font files", ex); + _logger.LogError("Error writing ffmpeg font files", ex); } } @@ -103,7 +103,7 @@ namespace MediaBrowser.MediaEncoding.Encoder catch (IOException ex) { // Log this, but don't let it fail the operation - _logger.ErrorException("Error copying file", ex); + _logger.LogError("Error copying file", ex); } } @@ -127,7 +127,7 @@ namespace MediaBrowser.MediaEncoding.Encoder catch (Exception ex) { // The core can function without the font file, so handle this - _logger.ErrorException("Failed to download ffmpeg font file from {0}", ex, url); + _logger.LogError("Failed to download ffmpeg font file from {0}", ex, url); } } @@ -145,12 +145,12 @@ namespace MediaBrowser.MediaEncoding.Encoder catch (IOException ex) { // Log this, but don't let it fail the operation - _logger.ErrorException("Error deleting temp file {0}", ex, tempFile); + _logger.LogError("Error deleting temp file {0}", ex, tempFile); } } private void Extract7zArchive(string archivePath, string targetPath) { - _logger.Info("Extracting {0} to {1}", archivePath, targetPath); + _logger.LogInformation("Extracting {0} to {1}", archivePath, targetPath); _zipClient.ExtractAllFrom7z(archivePath, targetPath, true); } diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index 64372c0727..4cd66e5ced 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -9,7 +9,6 @@ using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; -using MediaBrowser.Model.Logging; using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.Serialization; using System; @@ -25,6 +24,7 @@ using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Net; using MediaBrowser.Model.Diagnostics; using MediaBrowser.Model.System; +using Microsoft.Extensions.Logging; namespace MediaBrowser.MediaEncoding.Encoder { @@ -117,7 +117,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } catch (Exception ex) { - _logger.ErrorException("Error setting FFREPORT environment variable", ex); + _logger.LogError("Error setting FFREPORT environment variable", ex); } } } @@ -132,7 +132,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } catch (Exception ex) { - //_logger.ErrorException("Error setting FFREPORT environment variable", ex); + //_logger.LogError("Error setting FFREPORT environment variable", ex); } } } @@ -145,7 +145,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } catch (Exception ex) { - _logger.ErrorException("Error setting FFREPORT environment variable", ex); + _logger.LogError("Error setting FFREPORT environment variable", ex); } try { @@ -153,7 +153,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } catch (Exception ex) { - _logger.ErrorException("Error setting FFREPORT environment variable", ex); + _logger.LogError("Error setting FFREPORT environment variable", ex); } } @@ -252,7 +252,7 @@ namespace MediaBrowser.MediaEncoding.Encoder return; } - _logger.Info("Attempting to update encoder path to {0}. pathType: {1}", path ?? string.Empty, pathType ?? string.Empty); + _logger.LogInformation("Attempting to update encoder path to {0}. pathType: {1}", path ?? string.Empty, pathType ?? string.Empty); Tuple newPaths; @@ -414,8 +414,8 @@ namespace MediaBrowser.MediaEncoding.Encoder private void LogPaths() { - _logger.Info("FFMpeg: {0}", FFMpegPath ?? "not found"); - _logger.Info("FFProbe: {0}", FFProbePath ?? "not found"); + _logger.LogInformation("FFMpeg: {0}", FFMpegPath ?? "not found"); + _logger.LogInformation("FFProbe: {0}", FFProbePath ?? "not found"); } private EncodingOptions GetEncodingOptions() @@ -557,11 +557,11 @@ namespace MediaBrowser.MediaEncoding.Encoder if (forceEnableLogging) { - _logger.Info("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments); + _logger.LogInformation("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments); } else { - _logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments); + _logger.LogDebug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments); } using (var processWrapper = new ProcessWrapper(process, this, _logger)) @@ -651,7 +651,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } catch { - _logger.Error("I-frame image extraction failed, will attempt standard way. Input: {0}", inputArgument); + _logger.LogError("I-frame image extraction failed, will attempt standard way. Input: {0}", inputArgument); } } @@ -755,7 +755,7 @@ namespace MediaBrowser.MediaEncoding.Encoder ErrorDialog = false }); - _logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments); + _logger.LogDebug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments); using (var processWrapper = new ProcessWrapper(process, this, _logger)) { @@ -783,7 +783,7 @@ namespace MediaBrowser.MediaEncoding.Encoder { var msg = string.Format("ffmpeg image extraction failed for {0}", inputPath); - _logger.Error(msg); + _logger.LogError(msg); throw new Exception(msg); } @@ -877,7 +877,7 @@ namespace MediaBrowser.MediaEncoding.Encoder ErrorDialog = false }); - _logger.Info(process.StartInfo.FileName + " " + process.StartInfo.Arguments); + _logger.LogInformation(process.StartInfo.FileName + " " + process.StartInfo.Arguments); await resourcePool.WaitAsync(cancellationToken).ConfigureAwait(false); @@ -929,7 +929,7 @@ namespace MediaBrowser.MediaEncoding.Encoder { var msg = string.Format("ffmpeg image extraction failed for {0}", inputArgument); - _logger.Error(msg); + _logger.LogError(msg); throw new Exception(msg); } @@ -961,7 +961,7 @@ namespace MediaBrowser.MediaEncoding.Encoder IProgress progress, CancellationToken cancellationToken) { - _logger.Error("EncodeVideo"); + _logger.LogError("EncodeVideo"); var job = await new VideoEncoder(this, _logger, ConfigurationManager, @@ -999,18 +999,18 @@ namespace MediaBrowser.MediaEncoding.Encoder } catch (Exception ex) { - _logger.Error("Error in WaitForExit", ex); + _logger.LogError("Error in WaitForExit", ex); } try { - _logger.Info("Killing ffmpeg process"); + _logger.LogInformation("Killing ffmpeg process"); process.Process.Kill(); } catch (Exception ex) { - _logger.ErrorException("Error killing process", ex); + _logger.LogError("Error killing process", ex); } } diff --git a/MediaBrowser.MediaEncoding/Encoder/VideoEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/VideoEncoder.cs index 96c1269236..732b5bf846 100644 --- a/MediaBrowser.MediaEncoding/Encoder/VideoEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/VideoEncoder.cs @@ -4,7 +4,7 @@ using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Dlna; using MediaBrowser.Model.IO; -using MediaBrowser.Model.Logging; +using Microsoft.Extensions.Logging; using System; using System.IO; using System.Threading.Tasks; @@ -63,4 +63,4 @@ namespace MediaBrowser.MediaEncoding.Encoder } } -} \ No newline at end of file +} diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs index 0a3532b8cf..c3cf61dc1e 100644 --- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs +++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs @@ -13,7 +13,7 @@ using MediaBrowser.Model.IO; using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Library; using MediaBrowser.Model.IO; -using MediaBrowser.Model.Logging; +using Microsoft.Extensions.Logging; using MediaBrowser.Model.MediaInfo; namespace MediaBrowser.MediaEncoding.Probing @@ -1351,11 +1351,11 @@ namespace MediaBrowser.MediaEncoding.Probing { video.Timestamp = GetMpegTimestamp(video.Path); - _logger.Debug("Video has {0} timestamp", video.Timestamp); + _logger.LogDebug("Video has {0} timestamp", video.Timestamp); } catch (Exception ex) { - _logger.ErrorException("Error extracting timestamp info from {0}", ex, video.Path); + _logger.LogError("Error extracting timestamp info from {0}", ex, video.Path); video.Timestamp = null; } } diff --git a/MediaBrowser.MediaEncoding/Subtitles/OpenSubtitleDownloader.cs b/MediaBrowser.MediaEncoding/Subtitles/OpenSubtitleDownloader.cs index 3954897cac..2d29f29e3d 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/OpenSubtitleDownloader.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/OpenSubtitleDownloader.cs @@ -15,9 +15,9 @@ using MediaBrowser.Controller.Subtitles; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; -using MediaBrowser.Model.Logging; using MediaBrowser.Model.Providers; using MediaBrowser.Model.Serialization; +using Microsoft.Extensions.Logging; using OpenSubtitlesHandler; namespace MediaBrowser.MediaEncoding.Subtitles @@ -34,9 +34,9 @@ namespace MediaBrowser.MediaEncoding.Subtitles private readonly IJsonSerializer _json; private readonly IFileSystem _fileSystem; - public OpenSubtitleDownloader(ILogManager logManager, IHttpClient httpClient, IServerConfigurationManager config, IEncryptionManager encryption, IJsonSerializer json, IFileSystem fileSystem) + public OpenSubtitleDownloader(ILoggerFactory loggerFactory, IHttpClient httpClient, IServerConfigurationManager config, IEncryptionManager encryption, IJsonSerializer json, IFileSystem fileSystem) { - _logger = logManager.GetLogger(GetType().Name); + _logger = loggerFactory.CreateLogger(GetType().Name); _httpClient = httpClient; _config = config; _encryption = encryption; @@ -208,7 +208,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles var result = OpenSubtitles.GetSubLanguages("en"); if (!(result is MethodResponseGetSubLanguages)) { - _logger.Error("Invalid response type"); + _logger.LogError("Invalid response type"); return new List(); } @@ -243,19 +243,19 @@ namespace MediaBrowser.MediaEncoding.Subtitles case VideoContentType.Episode: if (!request.IndexNumber.HasValue || !request.ParentIndexNumber.HasValue || string.IsNullOrEmpty(request.SeriesName)) { - _logger.Debug("Episode information missing"); + _logger.LogDebug("Episode information missing"); return new List(); } break; case VideoContentType.Movie: if (string.IsNullOrEmpty(request.Name)) { - _logger.Debug("Movie name missing"); + _logger.LogDebug("Movie name missing"); return new List(); } if (string.IsNullOrWhiteSpace(imdbIdText) || !long.TryParse(imdbIdText.TrimStart('t'), NumberStyles.Any, _usCulture, out imdbId)) { - _logger.Debug("Imdb id missing"); + _logger.LogDebug("Imdb id missing"); return new List(); } break; @@ -263,7 +263,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles if (string.IsNullOrEmpty(request.MediaPath)) { - _logger.Debug("Path Missing"); + _logger.LogDebug("Path Missing"); return new List(); } @@ -300,7 +300,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles var result = await OpenSubtitles.SearchSubtitlesAsync(parms.ToArray(), cancellationToken).ConfigureAwait(false); if (!(result is MethodResponseSubtitleSearch)) { - _logger.Error("Invalid response type"); + _logger.LogError("Invalid response type"); return new List(); } diff --git a/MediaBrowser.MediaEncoding/Subtitles/SrtParser.cs b/MediaBrowser.MediaEncoding/Subtitles/SrtParser.cs index de6d7bc725..7ca8aa1fd8 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SrtParser.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SrtParser.cs @@ -1,5 +1,5 @@ using MediaBrowser.Model.Extensions; -using MediaBrowser.Model.Logging; +using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Globalization; @@ -50,7 +50,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles { // This occurs when subtitle text has an empty line as part of the text. // Need to adjust the break statement below to resolve this. - _logger.Warn("Unrecognized line in srt: {0}", line); + _logger.LogWarning("Unrecognized line in srt: {0}", line); continue; } subEvent.StartPositionTicks = GetTicks(time[0]); diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs index d565ff3e20..a3e0f89a97 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs @@ -5,7 +5,7 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Logging; +using Microsoft.Extensions.Logging; using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.Serialization; using System; @@ -190,7 +190,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles var bytes = await GetBytes(path, protocol, cancellationToken).ConfigureAwait(false); var charset = _textEncoding.GetDetectedEncodingName(bytes, bytes.Length, language, true); - _logger.Debug("charset {0} detected for {1}", charset ?? "null", path); + _logger.LogDebug("charset {0} detected for {1}", charset ?? "null", path); if (!string.IsNullOrEmpty(charset)) { @@ -423,7 +423,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles ErrorDialog = false }); - _logger.Info("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments); + _logger.LogInformation("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments); try { @@ -431,7 +431,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles } catch (Exception ex) { - _logger.ErrorException("Error starting ffmpeg", ex); + _logger.LogError("Error starting ffmpeg", ex); throw; } @@ -442,13 +442,13 @@ namespace MediaBrowser.MediaEncoding.Subtitles { try { - _logger.Info("Killing ffmpeg subtitle conversion process"); + _logger.LogInformation("Killing ffmpeg subtitle conversion process"); process.Kill(); } catch (Exception ex) { - _logger.ErrorException("Error killing subtitle conversion process", ex); + _logger.LogError("Error killing subtitle conversion process", ex); } } @@ -466,12 +466,12 @@ namespace MediaBrowser.MediaEncoding.Subtitles { try { - _logger.Info("Deleting converted subtitle due to failure: ", outputPath); + _logger.LogInformation("Deleting converted subtitle due to failure: ", outputPath); _fileSystem.DeleteFile(outputPath); } catch (IOException ex) { - _logger.ErrorException("Error deleting converted subtitle {0}", ex, outputPath); + _logger.LogError("Error deleting converted subtitle {0}", ex, outputPath); } } } @@ -484,13 +484,13 @@ namespace MediaBrowser.MediaEncoding.Subtitles { var msg = string.Format("ffmpeg subtitle conversion failed for {0}", inputPath); - _logger.Error(msg); + _logger.LogError(msg); throw new Exception(msg); } await SetAssFont(outputPath).ConfigureAwait(false); - _logger.Info("ffmpeg subtitle conversion succeeded for {0}", inputPath); + _logger.LogInformation("ffmpeg subtitle conversion succeeded for {0}", inputPath); } /// @@ -553,7 +553,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles ErrorDialog = false }); - _logger.Info("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments); + _logger.LogInformation("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments); try { @@ -561,7 +561,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles } catch (Exception ex) { - _logger.ErrorException("Error starting ffmpeg", ex); + _logger.LogError("Error starting ffmpeg", ex); throw; } @@ -572,13 +572,13 @@ namespace MediaBrowser.MediaEncoding.Subtitles { try { - _logger.Info("Killing ffmpeg subtitle extraction process"); + _logger.LogInformation("Killing ffmpeg subtitle extraction process"); process.Kill(); } catch (Exception ex) { - _logger.ErrorException("Error killing subtitle extraction process", ex); + _logger.LogError("Error killing subtitle extraction process", ex); } } @@ -594,7 +594,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles try { - _logger.Info("Deleting extracted subtitle due to failure: {0}", outputPath); + _logger.LogInformation("Deleting extracted subtitle due to failure: {0}", outputPath); _fileSystem.DeleteFile(outputPath); } catch (FileNotFoundException) @@ -603,7 +603,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles } catch (IOException ex) { - _logger.ErrorException("Error deleting extracted subtitle {0}", ex, outputPath); + _logger.LogError("Error deleting extracted subtitle {0}", ex, outputPath); } } else if (!_fileSystem.FileExists(outputPath)) @@ -615,7 +615,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles { var msg = string.Format("ffmpeg subtitle extraction failed for {0} to {1}", inputPath, outputPath); - _logger.Error(msg); + _logger.LogError(msg); throw new Exception(msg); } @@ -623,7 +623,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles { var msg = string.Format("ffmpeg subtitle extraction completed for {0} to {1}", inputPath, outputPath); - _logger.Info(msg); + _logger.LogInformation(msg); } if (string.Equals(outputCodec, "ass", StringComparison.OrdinalIgnoreCase)) @@ -639,7 +639,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles /// Task. private async Task SetAssFont(string file) { - _logger.Info("Setting ass font within {0}", file); + _logger.LogInformation("Setting ass font within {0}", file); string text; Encoding encoding; @@ -659,11 +659,9 @@ namespace MediaBrowser.MediaEncoding.Subtitles if (!string.Equals(text, newText)) { using (var fileStream = _fileSystem.GetFileStream(file, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read)) + using (var writer = new StreamWriter(fileStream, encoding)) { - using (var writer = new StreamWriter(fileStream, encoding)) - { - writer.Write(newText); - } + writer.Write(newText); } } } @@ -698,7 +696,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles var charset = _textEncoding.GetDetectedEncodingName(bytes, bytes.Length, language, true); - _logger.Debug("charset {0} detected for {1}", charset ?? "null", path); + _logger.LogDebug("charset {0} detected for {1}", charset ?? "null", path); return charset; } @@ -730,4 +728,4 @@ namespace MediaBrowser.MediaEncoding.Subtitles } } -} \ No newline at end of file +} -- cgit v1.2.3 From ea4c914123ba8279b9d9fcf7d5318e11f7a3da4c Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Thu, 20 Dec 2018 13:11:26 +0100 Subject: Fix exception logging --- Emby.Dlna/Didl/DidlBuilder.cs | 8 +- Emby.Dlna/DlnaManager.cs | 6 +- Emby.Dlna/Main/DlnaEntryPoint.cs | 12 +- Emby.Dlna/PlayTo/Device.cs | 6 +- Emby.Dlna/PlayTo/PlayToController.cs | 10 +- Emby.Dlna/PlayTo/PlayToManager.cs | 2 +- Emby.Dlna/Service/BaseControlHandler.cs | 2 +- Emby.Drawing.ImageMagick/ImageMagickEncoder.cs | 4 +- Emby.Drawing.Net/GDIImageEncoder.cs | 2 +- Emby.Drawing.Skia/SkiaEncoder.cs | 2 +- Emby.Drawing/ImageProcessor.cs | 10 +- Emby.Notifications/NotificationManager.cs | 6 +- Emby.Notifications/Notifications.cs | 2 +- Emby.Photos/PhotoProvider.cs | 4 +- .../Activity/ActivityRepository.cs | 228 ++++++++++----------- .../AppBase/BaseConfigurationManager.cs | 2 +- Emby.Server.Implementations/ApplicationHost.cs | 58 +++--- .../Channels/ChannelManager.cs | 6 +- .../Collections/CollectionManager.cs | 2 +- .../Data/BaseSqliteRepository.cs | 2 +- .../Data/SqliteDisplayPreferencesRepository.cs | 2 +- .../Data/SqliteItemRepository.cs | 2 +- .../Data/SqliteUserRepository.cs | 2 +- Emby.Server.Implementations/Devices/DeviceId.cs | 4 +- .../Devices/DeviceManager.cs | 2 +- Emby.Server.Implementations/Dto/DtoService.cs | 12 +- .../EntryPoints/AutomaticRestartEntryPoint.cs | 4 +- .../EntryPoints/ExternalPortForwarding.cs | 6 +- .../EntryPoints/KeepServerAwake.cs | 2 +- .../EntryPoints/LibraryChangedNotifier.cs | 4 +- .../EntryPoints/RecordingNotifier.cs | 2 +- .../EntryPoints/ServerEventNotifier.cs | 12 +- .../EntryPoints/UdpServerEntryPoint.cs | 2 +- .../EntryPoints/UsageEntryPoint.cs | 4 +- .../HttpClientManager/HttpClientManager.cs | 4 +- .../HttpServer/HttpListenerHost.cs | 14 +- .../HttpServer/ResponseFilter.cs | 2 +- .../HttpServer/WebSocketConnection.cs | 4 +- Emby.Server.Implementations/IO/FileRefresher.cs | 8 +- Emby.Server.Implementations/IO/LibraryMonitor.cs | 16 +- .../IO/ManagedFileSystem.cs | 6 +- .../Library/LibraryManager.cs | 33 ++- .../Library/MediaSourceManager.cs | 4 +- Emby.Server.Implementations/Library/UserManager.cs | 14 +- .../Library/Validators/ArtistsValidator.cs | 2 +- .../Library/Validators/GameGenresValidator.cs | 2 +- .../Library/Validators/GenresValidator.cs | 2 +- .../Library/Validators/MusicGenresValidator.cs | 2 +- .../Library/Validators/PeopleValidator.cs | 2 +- .../Library/Validators/StudiosValidator.cs | 2 +- .../LiveTv/EmbyTV/EmbyTV.cs | 52 ++--- .../LiveTv/EmbyTV/EncodedRecorder.cs | 24 +-- .../LiveTv/EmbyTV/ItemDataProvider.cs | 2 +- .../LiveTv/EmbyTV/TimerManager.cs | 6 +- .../LiveTv/Listings/SchedulesDirect.cs | 34 ++- .../LiveTv/LiveTvDtoService.cs | 9 +- .../LiveTv/LiveTvManager.cs | 16 +- .../LiveTv/TunerHosts/BaseTunerHost.cs | 8 +- .../LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs | 2 +- .../TunerHosts/HdHomerun/HdHomerunUdpStream.cs | 84 ++++---- .../LiveTv/TunerHosts/LiveStream.cs | 6 +- .../LiveTv/TunerHosts/SharedHttpStream.cs | 2 +- .../MediaEncoder/EncodingManager.cs | 6 +- .../Networking/NetworkManager.cs | 10 +- Emby.Server.Implementations/News/NewsEntryPoint.cs | 2 +- Emby.Server.Implementations/ResourceFileManager.cs | 2 +- .../ScheduledTasks/PluginUpdateTask.cs | 4 +- .../ScheduledTasks/ScheduledTaskWorker.cs | 10 +- .../ScheduledTasks/Tasks/DeleteCacheFileTask.cs | 8 +- .../Security/AuthenticationRepository.cs | 2 +- .../Security/PluginSecurityManager.cs | 11 +- Emby.Server.Implementations/Udp/UdpServer.cs | 12 +- .../Updates/InstallationManager.cs | 10 +- Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs | 4 +- MediaBrowser.Api/ApiEntryPoint.cs | 20 +- MediaBrowser.Api/Images/ImageService.cs | 2 +- MediaBrowser.Api/Library/LibraryService.cs | 2 +- MediaBrowser.Api/Playback/BaseStreamingService.cs | 4 +- MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs | 4 +- MediaBrowser.Api/Playback/StreamState.cs | 6 +- MediaBrowser.Api/Playback/TranscodingThrottler.cs | 20 +- MediaBrowser.Api/PluginService.cs | 6 +- MediaBrowser.Api/Subtitles/SubtitleService.cs | 2 +- MediaBrowser.Common/Events/EventHelper.cs | 8 +- MediaBrowser.Controller/Entities/BaseItem.cs | 2 +- .../Entities/CollectionFolder.cs | 2 +- MediaBrowser.Controller/Entities/Folder.cs | 2 +- .../Entities/UserViewBuilder.cs | 10 +- MediaBrowser.Controller/IO/FileData.cs | 2 +- .../MediaEncoding/EncodingJobInfo.cs | 1 - .../Net/BasePeriodicWebSocketListener.cs | 2 +- MediaBrowser.Controller/Session/SessionInfo.cs | 4 +- MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs | 2 +- MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs | 6 +- .../Encoder/EncoderValidator.cs | 14 +- MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs | 4 +- .../Encoder/FontConfigLoader.cs | 12 +- MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 34 +-- .../Probing/ProbeResultNormalizer.cs | 4 +- .../Subtitles/SubtitleEncoder.cs | 12 +- MediaBrowser.Providers/Manager/ImageSaver.cs | 4 +- .../Manager/ItemImageProvider.cs | 8 +- MediaBrowser.Providers/Manager/MetadataService.cs | 14 +- MediaBrowser.Providers/Manager/ProviderManager.cs | 20 +- .../MediaInfo/FFProbeVideoInfo.cs | 2 +- .../MediaInfo/SubtitleDownloader.cs | 2 +- .../MediaInfo/SubtitleScheduledTask.cs | 2 +- .../Music/MusicBrainzAlbumProvider.cs | 2 +- .../Subtitles/SubtitleManager.cs | 4 +- MediaBrowser.Providers/TV/SeriesMetadataService.cs | 2 +- .../TV/TheMovieDb/MovieDbSeasonProvider.cs | 2 +- .../TV/TheTVDB/TvdbPrescanTask.cs | 2 +- MediaBrowser.Server.Mono/Program.cs | 2 +- .../SocketSharp/WebSocketSharpListener.cs | 6 +- .../SocketSharp/WebSocketSharpResponse.cs | 2 +- MediaBrowser.WebDashboard/Api/DashboardService.cs | 2 +- MediaBrowser.XbmcMetadata/EntryPoint.cs | 2 +- .../Parsers/MovieNfoParser.cs | 2 +- MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs | 6 +- Mono.Nat/Pmp/PmpNatDevice.cs | 2 +- Mono.Nat/Upnp/Searchers/UpnpSearcher.cs | 2 +- RSSDP/SsdpCommunicationsServer.cs | 6 +- SocketHttpListener/Net/HttpEndPointListener.cs | 4 +- 123 files changed, 561 insertions(+), 603 deletions(-) (limited to 'MediaBrowser.Controller/MediaEncoding') diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.cs index 2cde379eaa..6de35b8426 100644 --- a/Emby.Dlna/Didl/DidlBuilder.cs +++ b/Emby.Dlna/Didl/DidlBuilder.cs @@ -913,9 +913,9 @@ namespace Emby.Dlna.Didl writer.WriteFullEndElement(); } - catch (XmlException) + catch (XmlException ex) { - _logger.LogError("Error adding xml value: {value}", name); + _logger.LogError(ex, "Error adding xml value: {value}", name); } } @@ -925,9 +925,9 @@ namespace Emby.Dlna.Didl { writer.WriteElementString(prefix, name, namespaceUri, value); } - catch (XmlException) + catch (XmlException ex) { - _logger.LogError("Error adding xml value: {value}", value); + _logger.LogError(ex, "Error adding xml value: {value}", value); } } diff --git a/Emby.Dlna/DlnaManager.cs b/Emby.Dlna/DlnaManager.cs index 4c5bde6cd4..eae4f32716 100644 --- a/Emby.Dlna/DlnaManager.cs +++ b/Emby.Dlna/DlnaManager.cs @@ -58,7 +58,7 @@ namespace Emby.Dlna } catch (Exception ex) { - _logger.LogError("Error extracting DLNA profiles.", ex); + _logger.LogError(ex, "Error extracting DLNA profiles."); } } @@ -198,7 +198,7 @@ namespace Emby.Dlna } catch (ArgumentException ex) { - _logger.LogError("Error evaluating regex pattern {0}", ex, pattern); + _logger.LogError(ex, "Error evaluating regex pattern {0}", pattern); return false; } } @@ -324,7 +324,7 @@ namespace Emby.Dlna } catch (Exception ex) { - _logger.LogError("Error parsing profile file: {0}", ex, path); + _logger.LogError(ex, "Error parsing profile file: {0}", path); return null; } diff --git a/Emby.Dlna/Main/DlnaEntryPoint.cs b/Emby.Dlna/Main/DlnaEntryPoint.cs index 4697287e9b..6ab0767a5a 100644 --- a/Emby.Dlna/Main/DlnaEntryPoint.cs +++ b/Emby.Dlna/Main/DlnaEntryPoint.cs @@ -185,7 +185,7 @@ namespace Emby.Dlna.Main } catch (Exception ex) { - _logger.LogError("Error starting ssdp handlers", ex); + _logger.LogError(ex, "Error starting ssdp handlers"); } } @@ -202,7 +202,7 @@ namespace Emby.Dlna.Main } catch (Exception ex) { - _logger.LogError("Error starting device discovery", ex); + _logger.LogError(ex, "Error starting device discovery"); } } @@ -215,7 +215,7 @@ namespace Emby.Dlna.Main } catch (Exception ex) { - _logger.LogError("Error stopping device discovery", ex); + _logger.LogError(ex, "Error stopping device discovery"); } } @@ -243,7 +243,7 @@ namespace Emby.Dlna.Main } catch (Exception ex) { - _logger.LogError("Error registering endpoint", ex); + _logger.LogError(ex, "Error registering endpoint"); } } @@ -361,7 +361,7 @@ namespace Emby.Dlna.Main } catch (Exception ex) { - _logger.LogError("Error starting PlayTo manager", ex); + _logger.LogError(ex, "Error starting PlayTo manager"); } } } @@ -379,7 +379,7 @@ namespace Emby.Dlna.Main } catch (Exception ex) { - _logger.LogError("Error disposing PlayTo manager", ex); + _logger.LogError(ex, "Error disposing PlayTo manager"); } _manager = null; } diff --git a/Emby.Dlna/PlayTo/Device.cs b/Emby.Dlna/PlayTo/Device.cs index 1cbb69d1da..a1df90ec03 100644 --- a/Emby.Dlna/PlayTo/Device.cs +++ b/Emby.Dlna/PlayTo/Device.cs @@ -140,7 +140,7 @@ namespace Emby.Dlna.PlayTo } catch (Exception ex) { - _logger.LogError("Error updating device volume info for {0}", ex, Properties.Name); + _logger.LogError(ex, "Error updating device volume info for {0}", Properties.Name); } } @@ -507,7 +507,7 @@ namespace Emby.Dlna.PlayTo if (_disposed) return; - //_logger.LogError("Error updating device info for {0}", ex, Properties.Name); + //_logger.LogError(ex, "Error updating device info for {0}", Properties.Name); _connectFailureCount++; @@ -767,7 +767,7 @@ namespace Emby.Dlna.PlayTo } catch (Exception ex) { - _logger.LogError("Unable to parse xml {0}", ex, trackString); + _logger.LogError(ex, "Unable to parse xml {0}", trackString); return new Tuple(true, null); } } diff --git a/Emby.Dlna/PlayTo/PlayToController.cs b/Emby.Dlna/PlayTo/PlayToController.cs index e722f83d81..c51f220ef5 100644 --- a/Emby.Dlna/PlayTo/PlayToController.cs +++ b/Emby.Dlna/PlayTo/PlayToController.cs @@ -156,7 +156,7 @@ namespace Emby.Dlna.PlayTo } catch (Exception ex) { - _logger.LogError("Error reporting progress", ex); + _logger.LogError(ex, "Error reporting progress"); } } @@ -204,7 +204,7 @@ namespace Emby.Dlna.PlayTo } catch (Exception ex) { - _logger.LogError("Error reporting playback stopped", ex); + _logger.LogError(ex, "Error reporting playback stopped"); } } @@ -223,7 +223,7 @@ namespace Emby.Dlna.PlayTo } catch (Exception ex) { - _logger.LogError("Error reporting progress", ex); + _logger.LogError(ex, "Error reporting progress"); } } @@ -247,7 +247,7 @@ namespace Emby.Dlna.PlayTo } catch (Exception ex) { - _logger.LogError("Error reporting progress", ex); + _logger.LogError(ex, "Error reporting progress"); } } @@ -278,7 +278,7 @@ namespace Emby.Dlna.PlayTo } catch (Exception ex) { - _logger.LogError("Error reporting progress", ex); + _logger.LogError(ex, "Error reporting progress"); } } diff --git a/Emby.Dlna/PlayTo/PlayToManager.cs b/Emby.Dlna/PlayTo/PlayToManager.cs index 0384d8f11c..47d00aad56 100644 --- a/Emby.Dlna/PlayTo/PlayToManager.cs +++ b/Emby.Dlna/PlayTo/PlayToManager.cs @@ -121,7 +121,7 @@ namespace Emby.Dlna.PlayTo } catch (Exception ex) { - _logger.LogError("Error creating PlayTo device.", ex); + _logger.LogError(ex, "Error creating PlayTo device."); } finally { diff --git a/Emby.Dlna/Service/BaseControlHandler.cs b/Emby.Dlna/Service/BaseControlHandler.cs index 55fe7fb80d..ae094cc2f6 100644 --- a/Emby.Dlna/Service/BaseControlHandler.cs +++ b/Emby.Dlna/Service/BaseControlHandler.cs @@ -52,7 +52,7 @@ namespace Emby.Dlna.Service } catch (Exception ex) { - _logger.LogError("Error processing control request", ex); + _logger.LogError(ex, "Error processing control request"); return new ControlErrorHandler().GetResponse(ex); } diff --git a/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs b/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs index f5de730a10..6aac77cf4b 100644 --- a/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs +++ b/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs @@ -103,7 +103,7 @@ namespace Emby.Drawing.ImageMagick } catch { - //_logger.LogError("Error loading webp: ", ex); + //_logger.LogError(ex, "Error loading webp: "); _webpAvailable = false; } } @@ -295,7 +295,7 @@ namespace Emby.Drawing.ImageMagick } catch (Exception ex) { - _logger.LogError("Error drawing indicator overlay", ex); + _logger.LogError(ex, "Error drawing indicator overlay"); } } diff --git a/Emby.Drawing.Net/GDIImageEncoder.cs b/Emby.Drawing.Net/GDIImageEncoder.cs index 4391cc618e..1639125d37 100644 --- a/Emby.Drawing.Net/GDIImageEncoder.cs +++ b/Emby.Drawing.Net/GDIImageEncoder.cs @@ -214,7 +214,7 @@ namespace Emby.Drawing.Net } catch (Exception ex) { - _logger.LogError("Error drawing indicator overlay", ex); + _logger.LogError(ex, "Error drawing indicator overlay"); } } diff --git a/Emby.Drawing.Skia/SkiaEncoder.cs b/Emby.Drawing.Skia/SkiaEncoder.cs index 185b11f45b..7a445a09ce 100644 --- a/Emby.Drawing.Skia/SkiaEncoder.cs +++ b/Emby.Drawing.Skia/SkiaEncoder.cs @@ -660,7 +660,7 @@ namespace Emby.Drawing.Skia } catch (Exception ex) { - _logger.LogError("Error drawing indicator overlay", ex); + _logger.LogError(ex, "Error drawing indicator overlay"); } } diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 8cbe5f96a3..c417f37854 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -302,7 +302,7 @@ namespace Emby.Drawing { // Decoder failed to decode it #if DEBUG - _logger.LogError("Error encoding image", ex); + _logger.LogError(ex, "Error encoding image"); #endif // Just spit out the original file if all the options are default return new Tuple(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified); @@ -310,7 +310,7 @@ namespace Emby.Drawing catch (Exception ex) { // If it fails for whatever reason, return the original image - _logger.LogError("Error encoding image", ex); + _logger.LogError(ex, "Error encoding image"); // Just spit out the original file if all the options are default return new Tuple(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified); @@ -603,7 +603,7 @@ namespace Emby.Drawing } catch (Exception ex) { - _logger.LogError("Image conversion failed for {0}", ex, originalImagePath); + _logger.LogError(ex, "Image conversion failed for {originalImagePath}", originalImagePath); } } @@ -660,7 +660,7 @@ namespace Emby.Drawing } catch (Exception ex) { - _logger.LogError("Error enhancing image", ex); + _logger.LogError(ex, "Error enhancing image"); } return new ValueTuple(originalImagePath, dateModified, inputImageSupportsTransparency); @@ -853,7 +853,7 @@ namespace Emby.Drawing } catch (Exception ex) { - _logger.LogError("Error in image enhancer: {0}", ex, i.GetType().Name); + _logger.LogError(ex, "Error in image enhancer: {0}", i.GetType().Name); } } diff --git a/Emby.Notifications/NotificationManager.cs b/Emby.Notifications/NotificationManager.cs index 209bc82aa7..fa8fdd9c15 100644 --- a/Emby.Notifications/NotificationManager.cs +++ b/Emby.Notifications/NotificationManager.cs @@ -134,7 +134,7 @@ namespace Emby.Notifications } catch (Exception ex) { - _logger.LogError("Error sending notification to {0}", ex, service.Name); + _logger.LogError(ex, "Error sending notification to {0}", service.Name); } } @@ -146,7 +146,7 @@ namespace Emby.Notifications } catch (Exception ex) { - _logger.LogError("Error in IsEnabledForUser", ex); + _logger.LogError(ex, "Error in IsEnabledForUser"); return false; } } @@ -177,7 +177,7 @@ namespace Emby.Notifications } catch (Exception ex) { - _logger.LogError("Error in GetNotificationTypes", ex); + _logger.LogError(ex, "Error in GetNotificationTypes"); return new List(); } diff --git a/Emby.Notifications/Notifications.cs b/Emby.Notifications/Notifications.cs index ab78f9f917..c09c4d449a 100644 --- a/Emby.Notifications/Notifications.cs +++ b/Emby.Notifications/Notifications.cs @@ -273,7 +273,7 @@ namespace Emby.Notifications } catch (Exception ex) { - _logger.LogError("Error sending notification", ex); + _logger.LogError(ex, "Error sending notification"); } } diff --git a/Emby.Photos/PhotoProvider.cs b/Emby.Photos/PhotoProvider.cs index ace3b2afbf..726fd1d79d 100644 --- a/Emby.Photos/PhotoProvider.cs +++ b/Emby.Photos/PhotoProvider.cs @@ -170,9 +170,9 @@ namespace Emby.Photos } } } - catch (Exception e) + catch (Exception ex) { - _logger.LogError("Image Provider - Error reading image tag for {0}", e, item.Path); + _logger.LogError(ex, "Image Provider - Error reading image tag for {0}", item.Path); } } diff --git a/Emby.Server.Implementations/Activity/ActivityRepository.cs b/Emby.Server.Implementations/Activity/ActivityRepository.cs index a84d6d45fd..fcdcb0c2c2 100644 --- a/Emby.Server.Implementations/Activity/ActivityRepository.cs +++ b/Emby.Server.Implementations/Activity/ActivityRepository.cs @@ -34,7 +34,7 @@ namespace Emby.Server.Implementations.Activity } catch (Exception ex) { - Logger.LogError("Error loading database file. Will reset and retry.", ex); + Logger.LogError(ex, "Error loading database file. Will reset and retry."); FileSystem.DeleteFile(DbFilePath); @@ -73,7 +73,7 @@ namespace Emby.Server.Implementations.Activity } catch (Exception ex) { - Logger.LogError("Error migrating activity log database", ex); + Logger.LogError(ex, "Error migrating activity log database"); } } @@ -87,36 +87,34 @@ namespace Emby.Server.Implementations.Activity } using (WriteLock.Write()) + using (var connection = CreateConnection()) { - using (var connection = CreateConnection()) + connection.RunInTransaction(db => { - connection.RunInTransaction(db => + using (var statement = db.PrepareStatement("insert into ActivityLog (Name, Overview, ShortOverview, Type, ItemId, UserId, DateCreated, LogSeverity) values (@Name, @Overview, @ShortOverview, @Type, @ItemId, @UserId, @DateCreated, @LogSeverity)")) { - using (var statement = db.PrepareStatement("insert into ActivityLog (Name, Overview, ShortOverview, Type, ItemId, UserId, DateCreated, LogSeverity) values (@Name, @Overview, @ShortOverview, @Type, @ItemId, @UserId, @DateCreated, @LogSeverity)")) + statement.TryBind("@Name", entry.Name); + + statement.TryBind("@Overview", entry.Overview); + statement.TryBind("@ShortOverview", entry.ShortOverview); + statement.TryBind("@Type", entry.Type); + statement.TryBind("@ItemId", entry.ItemId); + + if (entry.UserId.Equals(Guid.Empty)) { - statement.TryBind("@Name", entry.Name); - - statement.TryBind("@Overview", entry.Overview); - statement.TryBind("@ShortOverview", entry.ShortOverview); - statement.TryBind("@Type", entry.Type); - statement.TryBind("@ItemId", entry.ItemId); - - if (entry.UserId.Equals(Guid.Empty)) - { - statement.TryBindNull("@UserId"); - } - else - { - statement.TryBind("@UserId", entry.UserId.ToString("N")); - } - - statement.TryBind("@DateCreated", entry.Date.ToDateTimeParamValue()); - statement.TryBind("@LogSeverity", entry.Severity.ToString()); - - statement.MoveNext(); + statement.TryBindNull("@UserId"); } - }, TransactionMode); - } + else + { + statement.TryBind("@UserId", entry.UserId.ToString("N")); + } + + statement.TryBind("@DateCreated", entry.Date.ToDateTimeParamValue()); + statement.TryBind("@LogSeverity", entry.Severity.ToString()); + + statement.MoveNext(); + } + }, TransactionMode); } } @@ -128,132 +126,128 @@ namespace Emby.Server.Implementations.Activity } using (WriteLock.Write()) + using (var connection = CreateConnection()) { - using (var connection = CreateConnection()) + connection.RunInTransaction(db => { - connection.RunInTransaction(db => + using (var statement = db.PrepareStatement("Update ActivityLog set Name=@Name,Overview=@Overview,ShortOverview=@ShortOverview,Type=@Type,ItemId=@ItemId,UserId=@UserId,DateCreated=@DateCreated,LogSeverity=@LogSeverity where Id=@Id")) { - using (var statement = db.PrepareStatement("Update ActivityLog set Name=@Name,Overview=@Overview,ShortOverview=@ShortOverview,Type=@Type,ItemId=@ItemId,UserId=@UserId,DateCreated=@DateCreated,LogSeverity=@LogSeverity where Id=@Id")) + statement.TryBind("@Id", entry.Id); + + statement.TryBind("@Name", entry.Name); + statement.TryBind("@Overview", entry.Overview); + statement.TryBind("@ShortOverview", entry.ShortOverview); + statement.TryBind("@Type", entry.Type); + statement.TryBind("@ItemId", entry.ItemId); + + if (entry.UserId.Equals(Guid.Empty)) { - statement.TryBind("@Id", entry.Id); - - statement.TryBind("@Name", entry.Name); - statement.TryBind("@Overview", entry.Overview); - statement.TryBind("@ShortOverview", entry.ShortOverview); - statement.TryBind("@Type", entry.Type); - statement.TryBind("@ItemId", entry.ItemId); - - if (entry.UserId.Equals(Guid.Empty)) - { - statement.TryBindNull("@UserId"); - } - else - { - statement.TryBind("@UserId", entry.UserId.ToString("N")); - } - - statement.TryBind("@DateCreated", entry.Date.ToDateTimeParamValue()); - statement.TryBind("@LogSeverity", entry.Severity.ToString()); - - statement.MoveNext(); + statement.TryBindNull("@UserId"); } - }, TransactionMode); - } + else + { + statement.TryBind("@UserId", entry.UserId.ToString("N")); + } + + statement.TryBind("@DateCreated", entry.Date.ToDateTimeParamValue()); + statement.TryBind("@LogSeverity", entry.Severity.ToString()); + + statement.MoveNext(); + } + }, TransactionMode); } } public QueryResult GetActivityLogEntries(DateTime? minDate, bool? hasUserId, int? startIndex, int? limit) { using (WriteLock.Read()) + using (var connection = CreateConnection(true)) { - using (var connection = CreateConnection(true)) - { - var commandText = BaseActivitySelectText; - var whereClauses = new List(); + var commandText = BaseActivitySelectText; + var whereClauses = new List(); - if (minDate.HasValue) + if (minDate.HasValue) + { + whereClauses.Add("DateCreated>=@DateCreated"); + } + if (hasUserId.HasValue) + { + if (hasUserId.Value) { - whereClauses.Add("DateCreated>=@DateCreated"); + whereClauses.Add("UserId not null"); } - if (hasUserId.HasValue) + else { - if (hasUserId.Value) - { - whereClauses.Add("UserId not null"); - } - else - { - whereClauses.Add("UserId is null"); - } + whereClauses.Add("UserId is null"); } + } - var whereTextWithoutPaging = whereClauses.Count == 0 ? - string.Empty : - " where " + string.Join(" AND ", whereClauses.ToArray()); - - if (startIndex.HasValue && startIndex.Value > 0) - { - var pagingWhereText = whereClauses.Count == 0 ? - string.Empty : - " where " + string.Join(" AND ", whereClauses.ToArray()); + var whereTextWithoutPaging = whereClauses.Count == 0 ? + string.Empty : + " where " + string.Join(" AND ", whereClauses.ToArray(whereClauses.Count)); - whereClauses.Add(string.Format("Id NOT IN (SELECT Id FROM ActivityLog {0} ORDER BY DateCreated DESC LIMIT {1})", - pagingWhereText, - startIndex.Value.ToString(_usCulture))); - } - - var whereText = whereClauses.Count == 0 ? + if (startIndex.HasValue && startIndex.Value > 0) + { + var pagingWhereText = whereClauses.Count == 0 ? string.Empty : " where " + string.Join(" AND ", whereClauses.ToArray()); - commandText += whereText; + whereClauses.Add(string.Format("Id NOT IN (SELECT Id FROM ActivityLog {0} ORDER BY DateCreated DESC LIMIT {1})", + pagingWhereText, + startIndex.Value.ToString(_usCulture))); + } - commandText += " ORDER BY DateCreated DESC"; + var whereText = whereClauses.Count == 0 ? + string.Empty : + " where " + string.Join(" AND ", whereClauses.ToArray(whereClauses.Count)); - if (limit.HasValue) - { - commandText += " LIMIT " + limit.Value.ToString(_usCulture); - } + commandText += whereText; - var statementTexts = new List(); - statementTexts.Add(commandText); - statementTexts.Add("select count (Id) from ActivityLog" + whereTextWithoutPaging); + commandText += " ORDER BY DateCreated DESC"; - return connection.RunInTransaction(db => - { - var list = new List(); - var result = new QueryResult(); + if (limit.HasValue) + { + commandText += " LIMIT " + limit.Value.ToString(_usCulture); + } - var statements = PrepareAllSafe(db, statementTexts).ToList(); + var statementTexts = new List(); + statementTexts.Add(commandText); + statementTexts.Add("select count (Id) from ActivityLog" + whereTextWithoutPaging); + + return connection.RunInTransaction(db => + { + var list = new List(); + var result = new QueryResult(); - using (var statement = statements[0]) + var statements = PrepareAllSafe(db, statementTexts).ToList(); + + using (var statement = statements[0]) + { + if (minDate.HasValue) { - if (minDate.HasValue) - { - statement.TryBind("@DateCreated", minDate.Value.ToDateTimeParamValue()); - } - - foreach (var row in statement.ExecuteQuery()) - { - list.Add(GetEntry(row)); - } + statement.TryBind("@DateCreated", minDate.Value.ToDateTimeParamValue()); } - using (var statement = statements[1]) + foreach (var row in statement.ExecuteQuery()) { - if (minDate.HasValue) - { - statement.TryBind("@DateCreated", minDate.Value.ToDateTimeParamValue()); - } + list.Add(GetEntry(row)); + } + } - result.TotalRecordCount = statement.ExecuteQuery().SelectScalarInt().First(); + using (var statement = statements[1]) + { + if (minDate.HasValue) + { + statement.TryBind("@DateCreated", minDate.Value.ToDateTimeParamValue()); } - result.Items = list.ToArray(); - return result; + result.TotalRecordCount = statement.ExecuteQuery().SelectScalarInt().First(); + } - }, ReadTransactionMode); - } + result.Items = list.ToArray(list.Count); + return result; + + }, ReadTransactionMode); } } diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs index fdf2a3b731..fddf19893f 100644 --- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs +++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs @@ -259,7 +259,7 @@ namespace Emby.Server.Implementations.AppBase } catch (Exception ex) { - Logger.LogError("Error loading configuration file: {0}", ex, path); + Logger.LogError(ex, "Error loading configuration file: {path}", path); return Activator.CreateInstance(configurationType); } diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index aa9b6e82a3..888635c9d8 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -545,7 +545,7 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - Logger.LogError("Error creating {0}", ex, type.FullName); + Logger.LogError(ex, "Error creating {type}", type.FullName); // Don't blow up in release mode return null; } @@ -625,7 +625,7 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - Logger.LogError("Error loading assembly {0}", ex, file); + Logger.LogError(ex, "Error loading assembly {file}", file); return null; } } @@ -648,7 +648,7 @@ namespace Emby.Server.Implementations /// /// if set to true [manage liftime]. /// IEnumerable{``0}. - public IEnumerable GetExports(bool manageLiftime = true) + public IEnumerable GetExports(bool manageLifetime = true) { var parts = GetExportTypes() .Select(CreateInstanceSafe) @@ -656,7 +656,7 @@ namespace Emby.Server.Implementations .Cast() .ToList(); - if (manageLiftime) + if (manageLifetime) { lock (DisposableParts) { @@ -667,7 +667,7 @@ namespace Emby.Server.Implementations return parts; } - public List> GetExportsWithInfo(bool manageLiftime = true) + public List> GetExportsWithInfo(bool manageLifetime = true) { var parts = GetExportTypes() .Select(i => @@ -683,7 +683,7 @@ namespace Emby.Server.Implementations .Where(i => i != null) .ToList(); - if (manageLiftime) + if (manageLifetime) { lock (DisposableParts) { @@ -693,6 +693,8 @@ namespace Emby.Server.Implementations return parts; } + + // TODO: @bond /* private void SetBaseExceptionMessage() { @@ -760,7 +762,7 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - Logger.LogError("Error in {0}", ex, name); + Logger.LogError(ex, "Error in {name}", name); } Logger.LogInformation("Entry point completed: {0}. Duration: {1} seconds", name, (DateTime.UtcNow - now).TotalSeconds.ToString(CultureInfo.InvariantCulture), "ImageInfos"); } @@ -777,7 +779,7 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - Logger.LogError("Error configuring autorun", ex); + Logger.LogError(ex, "Error configuring autorun"); } } @@ -1119,7 +1121,7 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - Logger.LogError("Error setting http limit", ex); + Logger.LogError(ex, "Error setting http limit"); } } @@ -1186,7 +1188,7 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - Logger.LogError("Error loading cert from {0}", ex, certificateLocation); + Logger.LogError(ex, "Error loading cert from {certificateLocation}", certificateLocation); return null; } } @@ -1415,7 +1417,7 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - Logger.LogError("Error getting plugin Id from {0}.", ex, plugin.GetType().FullName); + Logger.LogError(ex, "Error getting plugin Id from {pluginName}.", plugin.GetType().FullName); } } @@ -1427,7 +1429,7 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - Logger.LogError("Error loading plugin {0}", ex, plugin.GetType().FullName); + Logger.LogError(ex, "Error loading plugin {pluginName}", plugin.GetType().FullName); return null; } @@ -1450,11 +1452,11 @@ namespace Emby.Server.Implementations if (path == null) { - Logger.LogInformation("Loading {0}", assembly.FullName); + Logger.LogInformation("Loading {assemblyName}", assembly.FullName); } else { - Logger.LogInformation("Loading {0} from {1}", assembly.FullName, path); + Logger.LogInformation("Loading {assemblyName} from {path}", assembly.FullName, path); } } @@ -1507,7 +1509,7 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - Logger.LogError("Error loading types from assembly", ex); + Logger.LogError(ex, "Error loading types from assembly"); return new List>(); } @@ -1554,7 +1556,7 @@ namespace Emby.Server.Implementations ? "The http server is unable to start due to a Socket error. This can occasionally happen when the operating system takes longer than usual to release the IP bindings from the previous session. This can take up to five minutes. Please try waiting or rebooting the system." : "Error starting Http Server"; - Logger.LogError(msg, ex); + Logger.LogError(ex, msg); if (HttpPort == ServerConfiguration.DefaultHttpPort) { @@ -1570,7 +1572,7 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - Logger.LogError("Error starting http server", ex); + Logger.LogError(ex, "Error starting http server"); throw; } @@ -1605,7 +1607,7 @@ namespace Emby.Server.Implementations // } // catch (Exception ex) // { - // Logger.LogError("Error creating ssl cert", ex); + // Logger.LogError(ex, "Error creating ssl cert"); // return null; // } // } @@ -1710,7 +1712,7 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - Logger.LogError("Error sending server restart notification", ex); + Logger.LogError(ex, "Error sending server restart notification"); } Logger.LogInformation("Calling RestartInternal"); @@ -1845,7 +1847,7 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - Logger.LogError("Error getting version number from {0}", ex, path); + Logger.LogError(ex, "Error getting version number from {path}", path); return new Version(1, 0); } @@ -1930,13 +1932,13 @@ namespace Emby.Server.Implementations if (version < minRequiredVersion) { - Logger.LogInformation("Not loading {0} {1} because the minimum supported version is {2}. Please update to the newer version", filename, version, minRequiredVersion); + Logger.LogInformation("Not loading {filename} {version} because the minimum supported version is {minRequiredVersion}. Please update to the newer version", filename, version, minRequiredVersion); return false; } } catch (Exception ex) { - Logger.LogError("Error getting version number from {0}", ex, path); + Logger.LogError(ex, "Error getting version number from {path}", path); return false; } @@ -2043,7 +2045,7 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - Logger.LogError("Error getting local Ip address information", ex); + Logger.LogError(ex, "Error getting local Ip address information"); } return null; @@ -2251,7 +2253,7 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - Logger.LogError("Error sending server shutdown notification", ex); + Logger.LogError(ex, "Error sending server shutdown notification"); } ShutdownInternal(); @@ -2276,7 +2278,7 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - Logger.LogError("Error authorizing server", ex); + Logger.LogError(ex, "Error authorizing server"); } } @@ -2443,9 +2445,7 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - Console.WriteLine("Error launching url: {0}", url); - Logger.LogError("Error launching url: {0}", ex, url); - + Logger.LogError(ex, "Error launching url: {url}", url); throw; } } @@ -2516,7 +2516,7 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - Logger.LogError("Error disposing {0}", ex, part.GetType().Name); + Logger.LogError(ex, "Error disposing {0}", part.GetType().Name); } } } diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index 88dfbd7c15..00da46f303 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -300,7 +300,7 @@ namespace Emby.Server.Implementations.Channels } catch (Exception ex) { - _logger.LogError("Error getting channel information for {0}", ex, channelInfo.Name); + _logger.LogError(ex, "Error getting channel information for {0}", channelInfo.Name); } numComplete++; @@ -848,7 +848,7 @@ namespace Emby.Server.Implementations.Channels } catch (Exception ex) { - _logger.LogError("Error writing to channel cache file: {0}", ex, path); + _logger.LogError(ex, "Error writing to channel cache file: {path}", path); } } @@ -911,7 +911,7 @@ namespace Emby.Server.Implementations.Channels } catch (Exception ex) { - _logger.LogError("Error retrieving channel item from database", ex); + _logger.LogError(ex, "Error retrieving channel item from database"); } if (item == null) diff --git a/Emby.Server.Implementations/Collections/CollectionManager.cs b/Emby.Server.Implementations/Collections/CollectionManager.cs index af7c70d7d8..d1afb0712a 100644 --- a/Emby.Server.Implementations/Collections/CollectionManager.cs +++ b/Emby.Server.Implementations/Collections/CollectionManager.cs @@ -365,7 +365,7 @@ namespace Emby.Server.Implementations.Collections } catch (Exception ex) { - _logger.LogError("Error creating camera uploads library", ex); + _logger.LogError(ex, "Error creating camera uploads library"); } _config.Configuration.CollectionsUpgraded = true; diff --git a/Emby.Server.Implementations/Data/BaseSqliteRepository.cs b/Emby.Server.Implementations/Data/BaseSqliteRepository.cs index 8e59596dd3..59776c3736 100644 --- a/Emby.Server.Implementations/Data/BaseSqliteRepository.cs +++ b/Emby.Server.Implementations/Data/BaseSqliteRepository.cs @@ -323,7 +323,7 @@ namespace Emby.Server.Implementations.Data } catch (Exception ex) { - Logger.LogError("Error disposing database", ex); + Logger.LogError(ex, "Error disposing database"); } } diff --git a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs index 307342135e..00e1956cf8 100644 --- a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs @@ -53,7 +53,7 @@ namespace Emby.Server.Implementations.Data } catch (Exception ex) { - Logger.LogError("Error loading database file. Will reset and retry.", ex); + Logger.LogError(ex, "Error loading database file. Will reset and retry."); FileSystem.DeleteFile(DbFilePath); diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 7239eec931..0f9770e8f7 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -1364,7 +1364,7 @@ namespace Emby.Server.Implementations.Data } catch (SerializationException ex) { - Logger.LogError("Error deserializing item", ex); + Logger.LogError(ex, "Error deserializing item"); } } } diff --git a/Emby.Server.Implementations/Data/SqliteUserRepository.cs b/Emby.Server.Implementations/Data/SqliteUserRepository.cs index 9ac255ec44..d490a481e4 100644 --- a/Emby.Server.Implementations/Data/SqliteUserRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteUserRepository.cs @@ -74,7 +74,7 @@ namespace Emby.Server.Implementations.Data } catch (Exception ex) { - Logger.LogError("Error migrating users database", ex); + Logger.LogError(ex, "Error migrating users database"); } } diff --git a/Emby.Server.Implementations/Devices/DeviceId.cs b/Emby.Server.Implementations/Devices/DeviceId.cs index fe953bfb99..90cef5d06e 100644 --- a/Emby.Server.Implementations/Devices/DeviceId.cs +++ b/Emby.Server.Implementations/Devices/DeviceId.cs @@ -45,7 +45,7 @@ namespace Emby.Server.Implementations.Devices } catch (Exception ex) { - _logger.LogError("Error reading file", ex); + _logger.LogError(ex, "Error reading file"); } return null; @@ -66,7 +66,7 @@ namespace Emby.Server.Implementations.Devices } catch (Exception ex) { - _logger.LogError("Error writing to file", ex); + _logger.LogError(ex, "Error writing to file"); } } diff --git a/Emby.Server.Implementations/Devices/DeviceManager.cs b/Emby.Server.Implementations/Devices/DeviceManager.cs index c5c86f5b9d..2503162118 100644 --- a/Emby.Server.Implementations/Devices/DeviceManager.cs +++ b/Emby.Server.Implementations/Devices/DeviceManager.cs @@ -434,7 +434,7 @@ namespace Emby.Server.Implementations.Devices } catch (Exception ex) { - _logger.LogError("Error creating camera uploads library", ex); + _logger.LogError(ex, "Error creating camera uploads library"); } _config.Configuration.CameraUploadUpgraded = true; diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index 4243099950..e8d06ec002 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -225,7 +225,7 @@ namespace Emby.Server.Implementations.Dto catch (Exception ex) { // Have to use a catch-all unfortunately because some .net image methods throw plain Exceptions - _logger.LogError("Error generating PrimaryImageAspectRatio for {0}", ex, item.Name); + _logger.LogError(ex, "Error generating PrimaryImageAspectRatio for {itemName}", item.Name); } } @@ -547,7 +547,7 @@ namespace Emby.Server.Implementations.Dto } catch (Exception ex) { - _logger.LogError("Error getting {0} image info", ex, type); + _logger.LogError(ex, "Error getting {type} image info", type); return null; } } @@ -560,7 +560,7 @@ namespace Emby.Server.Implementations.Dto } catch (Exception ex) { - _logger.LogError("Error getting {0} image info for {1}", ex, image.Type, image.Path); + _logger.LogError(ex, "Error getting {imageType} image info for {path}", image.Type, image.Path); return null; } } @@ -619,7 +619,7 @@ namespace Emby.Server.Implementations.Dto } catch (Exception ex) { - _logger.LogError("Error getting person {0}", ex, c); + _logger.LogError(ex, "Error getting person {0}", c); return null; } @@ -1451,7 +1451,7 @@ namespace Emby.Server.Implementations.Dto } catch (Exception ex) { - //_logger.LogError("Failed to determine primary image aspect ratio for {0}", ex, imageInfo.Path); + _logger.LogError(ex, "Failed to determine primary image aspect ratio for {0}", imageInfo.Path); return null; } } @@ -1464,7 +1464,7 @@ namespace Emby.Server.Implementations.Dto } catch (Exception ex) { - _logger.LogError("Error in image enhancer: {0}", ex, enhancer.GetType().Name); + _logger.LogError(ex, "Error in image enhancer: {0}", enhancer.GetType().Name); } } diff --git a/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs b/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs index cd5fca40d1..a0947c87d5 100644 --- a/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs +++ b/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs @@ -73,7 +73,7 @@ namespace Emby.Server.Implementations.EntryPoints } catch (Exception ex) { - _logger.LogError("Error restarting server", ex); + _logger.LogError(ex, "Error restarting server"); } } } @@ -98,7 +98,7 @@ namespace Emby.Server.Implementations.EntryPoints } catch (Exception ex) { - _logger.LogError("Error getting timers", ex); + _logger.LogError(ex, "Error getting timers"); } } diff --git a/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs b/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs index 46fbc94fdc..a95e21e1c5 100644 --- a/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs +++ b/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs @@ -216,7 +216,7 @@ namespace Emby.Server.Implementations.EntryPoints catch { // Commenting out because users are reporting problems out of our control - //_logger.LogError("Error creating port forwarding rules", ex); + //_logger.LogError(ex, "Error creating port forwarding rules"); } } @@ -253,6 +253,7 @@ namespace Emby.Server.Implementations.EntryPoints } catch (Exception ex) { + _logger.LogError(ex, "Error creating http port map"); return; } @@ -262,6 +263,7 @@ namespace Emby.Server.Implementations.EntryPoints } catch (Exception ex) { + _logger.LogError(ex, "Error creating https port map"); } } @@ -309,7 +311,7 @@ namespace Emby.Server.Implementations.EntryPoints } catch (Exception ex) { - _logger.LogError("Error stopping NAT Discovery", ex); + _logger.LogError(ex, "Error stopping NAT Discovery"); } } } diff --git a/Emby.Server.Implementations/EntryPoints/KeepServerAwake.cs b/Emby.Server.Implementations/EntryPoints/KeepServerAwake.cs index a9121ba32d..a6dadcef0c 100644 --- a/Emby.Server.Implementations/EntryPoints/KeepServerAwake.cs +++ b/Emby.Server.Implementations/EntryPoints/KeepServerAwake.cs @@ -49,7 +49,7 @@ namespace Emby.Server.Implementations.EntryPoints } catch (Exception ex) { - _logger.LogError("Error resetting system standby timer", ex); + _logger.LogError(ex, "Error resetting system standby timer"); } } diff --git a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs index ff283667bc..bb8ef52f18 100644 --- a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs @@ -331,7 +331,7 @@ namespace Emby.Server.Implementations.EntryPoints } catch (Exception ex) { - _logger.LogError("Error in GetLibraryUpdateInfo", ex); + _logger.LogError(ex, "Error in GetLibraryUpdateInfo"); return; } @@ -346,7 +346,7 @@ namespace Emby.Server.Implementations.EntryPoints } catch (Exception ex) { - _logger.LogError("Error sending LibraryChanged message", ex); + _logger.LogError(ex, "Error sending LibraryChanged message"); } } } diff --git a/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs b/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs index 24cd659e10..0b377dc682 100644 --- a/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs @@ -66,7 +66,7 @@ namespace Emby.Server.Implementations.EntryPoints } catch (Exception ex) { - _logger.LogError("Error sending message", ex); + _logger.LogError(ex, "Error sending message"); } } diff --git a/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs b/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs index f6a74c4ecf..72dcabab38 100644 --- a/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs @@ -156,14 +156,10 @@ namespace Emby.Server.Implementations.EntryPoints try { await _sessionManager.SendMessageToAdminSessions(name, data, CancellationToken.None); - } - catch (ObjectDisposedException) - { - } catch (Exception) { - //Logger.LogError("Error sending message", ex); + } } @@ -172,14 +168,10 @@ namespace Emby.Server.Implementations.EntryPoints try { await _sessionManager.SendMessageToUserSessions(new List { user.Id }, name, data, CancellationToken.None); - } - catch (ObjectDisposedException) - { - } catch (Exception) { - //Logger.LogError("Error sending message", ex); + } } diff --git a/Emby.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs b/Emby.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs index 1bb11ce406..f8e2d32ddf 100644 --- a/Emby.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs +++ b/Emby.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs @@ -58,7 +58,7 @@ namespace Emby.Server.Implementations.EntryPoints } catch (Exception ex) { - _logger.LogError("Failed to start UDP Server", ex); + _logger.LogError(ex, "Failed to start UDP Server"); } } diff --git a/Emby.Server.Implementations/EntryPoints/UsageEntryPoint.cs b/Emby.Server.Implementations/EntryPoints/UsageEntryPoint.cs index ca79262b0b..f7542a5e92 100644 --- a/Emby.Server.Implementations/EntryPoints/UsageEntryPoint.cs +++ b/Emby.Server.Implementations/EntryPoints/UsageEntryPoint.cs @@ -91,7 +91,7 @@ namespace Emby.Server.Implementations.EntryPoints } catch (Exception ex) { - //_logger.LogError("Error sending anonymous usage statistics.", ex); + _logger.LogError(ex, "Error sending anonymous usage statistics."); } } @@ -119,7 +119,7 @@ namespace Emby.Server.Implementations.EntryPoints } catch (Exception ex) { - //_logger.LogError("Error sending anonymous usage statistics.", ex); + _logger.LogError(ex, "Error sending anonymous usage statistics."); } } diff --git a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs index b3f8ef8848..23dd55b183 100644 --- a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs +++ b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs @@ -685,7 +685,7 @@ namespace Emby.Server.Implementations.HttpClientManager { if (options.LogErrors) { - _logger.LogError("Error " + webException.Status + " getting response from " + options.Url, webException); + _logger.LogError(webException, "Error {status} getting response from {url}", webException.Status, options.Url); } var exception = new HttpException(webException.Message, webException); @@ -723,7 +723,7 @@ namespace Emby.Server.Implementations.HttpClientManager if (options.LogErrors) { - _logger.LogError("Error getting response from " + options.Url, ex); + _logger.LogError(ex, "Error getting response from {url}", options.Url); } return ex; diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs index 1d87d0e445..704b7f8a6f 100644 --- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -252,7 +252,7 @@ namespace Emby.Server.Implementations.HttpServer if (logExceptionStackTrace) { - _logger.LogError("Error processing request", ex); + _logger.LogError(ex, "Error processing request"); } else if (logExceptionMessage) { @@ -272,9 +272,9 @@ namespace Emby.Server.Implementations.HttpServer httpRes.ContentType = "text/html"; await Write(httpRes, NormalizeExceptionMessage(ex.Message)).ConfigureAwait(false); } - catch + catch (Exception errorEx) { - //_logger.LogError("Error this.ProcessRequest(context)(Exception while writing error to the response)", errorEx); + _logger.LogError(errorEx, "Error this.ProcessRequest(context)(Exception while writing error to the response)"); } } @@ -713,7 +713,7 @@ namespace Emby.Server.Implementations.HttpServer var pathParts = pathInfo.TrimStart('/').Split('/'); if (pathParts.Length == 0) { - _logger.LogError("Path parts empty for PathInfo: {0}, Url: {1}", pathInfo, httpReq.RawUrl); + _logger.LogError("Path parts empty for PathInfo: {pathInfo}, Url: {RawUrl}", pathInfo, httpReq.RawUrl); return null; } @@ -729,7 +729,7 @@ namespace Emby.Server.Implementations.HttpServer }; } - _logger.LogError("Could not find handler for {0}", pathInfo); + _logger.LogError("Could not find handler for {pathInfo}", pathInfo); return null; } @@ -919,7 +919,7 @@ namespace Emby.Server.Implementations.HttpServer return Task.CompletedTask; } - //_logger.LogDebug("Websocket message received: {0}", result.MessageType); + _logger.LogDebug("Websocket message received: {0}", result.MessageType); var tasks = _webSocketListeners.Select(i => Task.Run(async () => { @@ -929,7 +929,7 @@ namespace Emby.Server.Implementations.HttpServer } catch (Exception ex) { - _logger.LogError("{0} failed processing WebSocket message {1}", ex, i.GetType().Name, result.MessageType ?? string.Empty); + _logger.LogError(ex, "{0} failed processing WebSocket message {1}", i.GetType().Name, result.MessageType ?? string.Empty); } })); diff --git a/Emby.Server.Implementations/HttpServer/ResponseFilter.cs b/Emby.Server.Implementations/HttpServer/ResponseFilter.cs index b1759069cc..f38aa5ea06 100644 --- a/Emby.Server.Implementations/HttpServer/ResponseFilter.cs +++ b/Emby.Server.Implementations/HttpServer/ResponseFilter.cs @@ -34,7 +34,7 @@ namespace Emby.Server.Implementations.HttpServer if (exception != null) { - _logger.LogError("Error processing request for {0}", exception, req.RawUrl); + _logger.LogError(exception, "Error processing request for {RawUrl}", req.RawUrl); if (!string.IsNullOrEmpty(exception.Message)) { diff --git a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs index 037bdde771..8b5dfd4440 100644 --- a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs +++ b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs @@ -180,7 +180,7 @@ namespace Emby.Server.Implementations.HttpServer if (!message.StartsWith("{", StringComparison.OrdinalIgnoreCase)) { // This info is useful sometimes but also clogs up the log - //_lLogError("Received web socket message that is not a json structure: " + message); + _logger.LogDebug("Received web socket message that is not a json structure: {message}", message); return; } @@ -204,7 +204,7 @@ namespace Emby.Server.Implementations.HttpServer } catch (Exception ex) { - _logger.LogError("Error processing web socket message", ex); + _logger.LogError(ex, "Error processing web socket message"); } } diff --git a/Emby.Server.Implementations/IO/FileRefresher.cs b/Emby.Server.Implementations/IO/FileRefresher.cs index 6087f3cf27..df484d04c7 100644 --- a/Emby.Server.Implementations/IO/FileRefresher.cs +++ b/Emby.Server.Implementations/IO/FileRefresher.cs @@ -141,7 +141,7 @@ namespace Emby.Server.Implementations.IO } catch (Exception ex) { - Logger.LogError("Error processing directory changes", ex); + Logger.LogError(ex, "Error processing directory changes"); } } @@ -161,7 +161,7 @@ namespace Emby.Server.Implementations.IO continue; } - Logger.LogInformation(item.Name + " (" + item.Path + ") will be refreshed."); + Logger.LogInformation("{name} ({path}}) will be refreshed.", item.Name, item.Path); try { @@ -172,11 +172,11 @@ namespace Emby.Server.Implementations.IO // For now swallow and log. // Research item: If an IOException occurs, the item may be in a disconnected state (media unavailable) // Should we remove it from it's parent? - Logger.LogError("Error refreshing {0}", ex, item.Name); + Logger.LogError(ex, "Error refreshing {name}", item.Name); } catch (Exception ex) { - Logger.LogError("Error refreshing {0}", ex, item.Name); + Logger.LogError(ex, "Error refreshing {name}", item.Name); } } } diff --git a/Emby.Server.Implementations/IO/LibraryMonitor.cs b/Emby.Server.Implementations/IO/LibraryMonitor.cs index 22d1783eda..ca5810fd6c 100644 --- a/Emby.Server.Implementations/IO/LibraryMonitor.cs +++ b/Emby.Server.Implementations/IO/LibraryMonitor.cs @@ -114,7 +114,7 @@ namespace Emby.Server.Implementations.IO } catch (Exception ex) { - Logger.LogError("Error in ReportFileSystemChanged for {0}", ex, path); + Logger.LogError(ex, "Error in ReportFileSystemChanged for {path}", path); } } } @@ -354,7 +354,7 @@ namespace Emby.Server.Implementations.IO } catch (Exception ex) { - Logger.LogError("Error watching path: {0}", ex, path); + Logger.LogError(ex, "Error watching path: {path}", path); } }); } @@ -382,7 +382,7 @@ namespace Emby.Server.Implementations.IO { using (watcher) { - Logger.LogInformation("Stopping directory watching for path {0}", watcher.Path); + Logger.LogInformation("Stopping directory watching for path {path}", watcher.Path); watcher.Created -= watcher_Changed; watcher.Deleted -= watcher_Changed; @@ -439,7 +439,7 @@ namespace Emby.Server.Implementations.IO var ex = e.GetException(); var dw = (FileSystemWatcher)sender; - Logger.LogError("Error in Directory watcher for: " + dw.Path, ex); + Logger.LogError(ex, "Error in Directory watcher for: {path}", dw.Path); DisposeWatcher(dw, true); } @@ -461,7 +461,7 @@ namespace Emby.Server.Implementations.IO } catch (Exception ex) { - Logger.LogError("Exception in ReportFileSystemChanged. Path: {0}", ex, e.FullPath); + Logger.LogError(ex, "Exception in ReportFileSystemChanged. Path: {FullPath}", e.FullPath); } } @@ -487,13 +487,13 @@ namespace Emby.Server.Implementations.IO { if (_fileSystem.AreEqual(i, path)) { - //logger.LogDebug("Ignoring change to {0}", path); + Logger.LogDebug("Ignoring change to {path}", path); return true; } if (_fileSystem.ContainsSubPath(i, path)) { - //logger.LogDebug("Ignoring change to {0}", path); + Logger.LogDebug("Ignoring change to {path}", path); return true; } @@ -503,7 +503,7 @@ namespace Emby.Server.Implementations.IO { if (_fileSystem.AreEqual(parent, path)) { - //logger.LogDebug("Ignoring change to {0}", path); + Logger.LogDebug("Ignoring change to {path}", path); return true; } } diff --git a/Emby.Server.Implementations/IO/ManagedFileSystem.cs b/Emby.Server.Implementations/IO/ManagedFileSystem.cs index 42b9ae23bc..8819449b5c 100644 --- a/Emby.Server.Implementations/IO/ManagedFileSystem.cs +++ b/Emby.Server.Implementations/IO/ManagedFileSystem.cs @@ -175,7 +175,7 @@ namespace Emby.Server.Implementations.IO path = System.IO.Path.GetFullPath(path); return path; } - catch (ArgumentException ex) + catch (ArgumentException) { return filePath; } @@ -395,7 +395,7 @@ namespace Emby.Server.Implementations.IO } catch (Exception ex) { - Logger.LogError("Error determining CreationTimeUtc for {0}", ex, info.FullName); + Logger.LogError(ex, "Error determining CreationTimeUtc for {FullName}", info.FullName); return DateTime.MinValue; } } @@ -434,7 +434,7 @@ namespace Emby.Server.Implementations.IO } catch (Exception ex) { - Logger.LogError("Error determining LastAccessTimeUtc for {0}", ex, info.FullName); + Logger.LogError(ex, "Error determining LastAccessTimeUtc for {FullName}", info.FullName); return DateTime.MinValue; } } diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index e1a725c936..451f16bef8 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -384,7 +384,7 @@ namespace Emby.Server.Implementations.Library } catch (Exception ex) { - _logger.LogError("Error deleting {0}", ex, metadataPath); + _logger.LogError(ex, "Error deleting {metadataPath}", metadataPath); } } @@ -398,14 +398,13 @@ namespace Emby.Server.Implementations.Library { try { + _logger.LogDebug("Deleting path {path}", fileSystemInfo.FullName); if (fileSystemInfo.IsDirectory) { - _logger.LogDebug("Deleting path {0}", fileSystemInfo.FullName); _fileSystem.DeleteDirectory(fileSystemInfo.FullName, true); } else { - _logger.LogDebug("Deleting path {0}", fileSystemInfo.FullName); _fileSystem.DeleteFile(fileSystemInfo.FullName); } } @@ -489,7 +488,7 @@ namespace Emby.Server.Implementations.Library } catch (Exception ex) { - _logger.LogError("Error in {0} resolving {1}", ex, resolver.GetType().Name, args.Path); + _logger.LogError(ex, "Error in {resolver} resolving {path}", resolver.GetType().Name, args.Path); return null; } } @@ -587,7 +586,7 @@ namespace Emby.Server.Implementations.Library { if (parent != null && parent.IsPhysicalRoot) { - _logger.LogError("Error in GetFilteredFileSystemEntries isPhysicalRoot: {0} IsVf: {1}", ex, isPhysicalRoot, isVf); + _logger.LogError(ex, "Error in GetFilteredFileSystemEntries isPhysicalRoot: {0} IsVf: {1}", isPhysicalRoot, isVf); files = new FileSystemMetadata[] { }; } @@ -713,7 +712,7 @@ namespace Emby.Server.Implementations.Library } catch (Exception ex) { - _logger.LogError("Error resolving path {0}", ex, f.FullName); + _logger.LogError(ex, "Error resolving path {path}", f.FullName); return null; } }).Where(i => i != null); @@ -1148,7 +1147,7 @@ namespace Emby.Server.Implementations.Library } catch (Exception ex) { - _logger.LogError("Error running postscan task", ex); + _logger.LogError(ex, "Error running postscan task"); } numComplete++; @@ -1199,7 +1198,7 @@ namespace Emby.Server.Implementations.Library } catch (Exception ex) { - _logger.LogError("Error resolving shortcut file {0}", ex, i); + _logger.LogError(ex, "Error resolving shortcut file {file}", i); return null; } }) @@ -1650,7 +1649,7 @@ namespace Emby.Server.Implementations.Library } catch (Exception ex) { - _logger.LogError("Error getting intros", ex); + _logger.LogError(ex, "Error getting intros"); return new List(); } @@ -1670,7 +1669,7 @@ namespace Emby.Server.Implementations.Library } catch (Exception ex) { - _logger.LogError("Error getting intro files", ex); + _logger.LogError(ex, "Error getting intro files"); return new List(); } @@ -1693,7 +1692,7 @@ namespace Emby.Server.Implementations.Library if (video == null) { - _logger.LogError("Unable to locate item with Id {0}.", info.ItemId.Value); + _logger.LogError("Unable to locate item with Id {ID}.", info.ItemId.Value); } } else if (!string.IsNullOrEmpty(info.Path)) @@ -1705,7 +1704,7 @@ namespace Emby.Server.Implementations.Library if (video == null) { - _logger.LogError("Intro resolver returned null for {0}.", info.Path); + _logger.LogError("Intro resolver returned null for {path}.", info.Path); } else { @@ -1724,7 +1723,7 @@ namespace Emby.Server.Implementations.Library } catch (Exception ex) { - _logger.LogError("Error resolving path {0}.", ex, info.Path); + _logger.LogError(ex, "Error resolving path {path}.", info.Path); } } else @@ -1873,7 +1872,7 @@ namespace Emby.Server.Implementations.Library } catch (Exception ex) { - _logger.LogError("Error in ItemAdded event handler", ex); + _logger.LogError(ex, "Error in ItemAdded event handler"); } } } @@ -1929,7 +1928,7 @@ namespace Emby.Server.Implementations.Library } catch (Exception ex) { - _logger.LogError("Error in ItemUpdated event handler", ex); + _logger.LogError(ex, "Error in ItemUpdated event handler"); } } } @@ -1965,7 +1964,7 @@ namespace Emby.Server.Implementations.Library } catch (Exception ex) { - _logger.LogError("Error in ItemRemoved event handler", ex); + _logger.LogError(ex, "Error in ItemRemoved event handler"); } } } @@ -2808,7 +2807,7 @@ namespace Emby.Server.Implementations.Library } catch (Exception ex) { - _logger.LogError("Error getting person", ex); + _logger.LogError(ex, "Error getting person"); return null; } diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs index 15673d25d5..e5fd289979 100644 --- a/Emby.Server.Implementations/Library/MediaSourceManager.cs +++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs @@ -256,7 +256,7 @@ namespace Emby.Server.Implementations.Library } catch (Exception ex) { - _logger.LogError("Error getting media sources", ex); + _logger.LogError(ex, "Error getting media sources"); return new List(); } } @@ -477,7 +477,7 @@ namespace Emby.Server.Implementations.Library } catch (Exception ex) { - _logger.LogError("Error probing live tv stream", ex); + _logger.LogError(ex, "Error probing live tv stream"); AddMediaInfo(mediaSource, isAudio); } diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs index 35b0ca304e..ae3577b7d0 100644 --- a/Emby.Server.Implementations/Library/UserManager.cs +++ b/Emby.Server.Implementations/Library/UserManager.cs @@ -392,7 +392,7 @@ namespace Emby.Server.Implementations.Library } catch (Exception ex) { - _logger.LogError("Error authenticating with provider {0}", ex, provider.Name); + _logger.LogError(ex, "Error authenticating with provider {provider}", provider.Name); return false; } @@ -575,7 +575,7 @@ namespace Emby.Server.Implementations.Library catch (Exception ex) { // Have to use a catch-all unfortunately because some .net image methods throw plain Exceptions - _logger.LogError("Error generating PrimaryImageAspectRatio for {0}", ex, user.Name); + _logger.LogError(ex, "Error generating PrimaryImageAspectRatio for {user}", user.Name); } } @@ -599,7 +599,7 @@ namespace Emby.Server.Implementations.Library } catch (Exception ex) { - _logger.LogError("Error getting {0} image info for {1}", ex, image.Type, image.Path); + _logger.LogError(ex, "Error getting {imageType} image info for {imagePath}", image.Type, image.Path); return null; } } @@ -775,7 +775,7 @@ namespace Emby.Server.Implementations.Library } catch (IOException ex) { - _logger.LogError("Error deleting file {0}", ex, configPath); + _logger.LogError(ex, "Error deleting file {path}", configPath); } DeleteUserPolicy(user); @@ -1045,7 +1045,7 @@ namespace Emby.Server.Implementations.Library } catch (Exception ex) { - _logger.LogError("Error reading policy file: {0}", ex, path); + _logger.LogError(ex, "Error reading policy file: {path}", path); return GetDefaultPolicy(user); } @@ -1109,7 +1109,7 @@ namespace Emby.Server.Implementations.Library } catch (Exception ex) { - _logger.LogError("Error deleting policy file", ex); + _logger.LogError(ex, "Error deleting policy file"); } } @@ -1144,7 +1144,7 @@ namespace Emby.Server.Implementations.Library } catch (Exception ex) { - _logger.LogError("Error reading policy file: {0}", ex, path); + _logger.LogError(ex, "Error reading policy file: {path}", path); return new UserConfiguration(); } diff --git a/Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs b/Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs index 593a9a1ef4..1686dc23c1 100644 --- a/Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs +++ b/Emby.Server.Implementations/Library/Validators/ArtistsValidator.cs @@ -70,7 +70,7 @@ namespace Emby.Server.Implementations.Library.Validators } catch (Exception ex) { - _logger.LogError("Error refreshing {0}", ex, name); + _logger.LogError(ex, "Error refreshing {ArtistName}", name); } numComplete++; diff --git a/Emby.Server.Implementations/Library/Validators/GameGenresValidator.cs b/Emby.Server.Implementations/Library/Validators/GameGenresValidator.cs index ffa5608ddd..070777475c 100644 --- a/Emby.Server.Implementations/Library/Validators/GameGenresValidator.cs +++ b/Emby.Server.Implementations/Library/Validators/GameGenresValidator.cs @@ -57,7 +57,7 @@ namespace Emby.Server.Implementations.Library.Validators } catch (Exception ex) { - _logger.LogError("Error refreshing {0}", ex, name); + _logger.LogError(ex, "Error refreshing {GenreName}", name); } numComplete++; diff --git a/Emby.Server.Implementations/Library/Validators/GenresValidator.cs b/Emby.Server.Implementations/Library/Validators/GenresValidator.cs index e59b747de4..775cde299b 100644 --- a/Emby.Server.Implementations/Library/Validators/GenresValidator.cs +++ b/Emby.Server.Implementations/Library/Validators/GenresValidator.cs @@ -58,7 +58,7 @@ namespace Emby.Server.Implementations.Library.Validators } catch (Exception ex) { - _logger.LogError("Error refreshing {0}", ex, name); + _logger.LogError(ex, "Error refreshing {GenreName}", name); } numComplete++; diff --git a/Emby.Server.Implementations/Library/Validators/MusicGenresValidator.cs b/Emby.Server.Implementations/Library/Validators/MusicGenresValidator.cs index ec8568afcc..b5ed1c0e6e 100644 --- a/Emby.Server.Implementations/Library/Validators/MusicGenresValidator.cs +++ b/Emby.Server.Implementations/Library/Validators/MusicGenresValidator.cs @@ -58,7 +58,7 @@ namespace Emby.Server.Implementations.Library.Validators } catch (Exception ex) { - _logger.LogError("Error refreshing {0}", ex, name); + _logger.LogError(ex, "Error refreshing {GenreName}", name); } numComplete++; diff --git a/Emby.Server.Implementations/Library/Validators/PeopleValidator.cs b/Emby.Server.Implementations/Library/Validators/PeopleValidator.cs index 80e3965830..50c7cfbc61 100644 --- a/Emby.Server.Implementations/Library/Validators/PeopleValidator.cs +++ b/Emby.Server.Implementations/Library/Validators/PeopleValidator.cs @@ -78,7 +78,7 @@ namespace Emby.Server.Implementations.Library.Validators } catch (Exception ex) { - _logger.LogError("Error validating IBN entry {0}", ex, person); + _logger.LogError(ex, "Error validating IBN entry {person}", person); } // Update progress diff --git a/Emby.Server.Implementations/Library/Validators/StudiosValidator.cs b/Emby.Server.Implementations/Library/Validators/StudiosValidator.cs index fec9890328..1a5ebac54e 100644 --- a/Emby.Server.Implementations/Library/Validators/StudiosValidator.cs +++ b/Emby.Server.Implementations/Library/Validators/StudiosValidator.cs @@ -57,7 +57,7 @@ namespace Emby.Server.Implementations.Library.Validators } catch (Exception ex) { - _logger.LogError("Error refreshing {0}", ex, name); + _logger.LogError(ex, "Error refreshing {StudioName}", name); } numComplete++; diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index b9b8802a82..ef96510bda 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -170,7 +170,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error creating virtual folder", ex); + _logger.LogError(ex, "Error creating virtual folder"); } pathsAdded.AddRange(pathsToCreate); @@ -196,7 +196,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error creating recording folders", ex); + _logger.LogError(ex, "Error creating recording folders"); } } @@ -224,7 +224,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error removing virtual folder", ex); + _logger.LogError(ex, "Error removing virtual folder"); } } else @@ -236,14 +236,14 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error removing media path", ex); + _logger.LogError(ex, "Error removing media path"); } } } if (requiresRefresh) { - _libraryManager.ValidateMediaLibrary(new SimpleProgress(), CancellationToken.None); + await _libraryManager.ValidateMediaLibrary(new SimpleProgress(), CancellationToken.None); } } @@ -342,7 +342,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error getting channels", ex); + _logger.LogError(ex, "Error getting channels"); } } @@ -364,7 +364,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error adding metadata", ex); + _logger.LogError(ex, "Error adding metadata"); } } } @@ -595,7 +595,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error getting channels", ex); + _logger.LogError(ex, "Error getting channels"); } } @@ -1217,7 +1217,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error recording stream", ex); + _logger.LogError(ex, "Error recording stream"); } } @@ -1414,16 +1414,16 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV await recorder.Record(directStreamProvider, mediaStreamInfo, recordPath, duration, onStarted, activeRecordingInfo.CancellationTokenSource.Token).ConfigureAwait(false); recordingStatus = RecordingStatus.Completed; - _logger.LogInformation("Recording completed: {0}", recordPath); + _logger.LogInformation("Recording completed: {recordPath}", recordPath); } catch (OperationCanceledException) { - _logger.LogInformation("Recording stopped: {0}", recordPath); + _logger.LogInformation("Recording stopped: {recordPath}", recordPath); recordingStatus = RecordingStatus.Completed; } catch (Exception ex) { - _logger.LogError("Error recording to {0}", ex, recordPath); + _logger.LogError(ex, "Error recording to {recordPath}", recordPath); recordingStatus = RecordingStatus.Error; } @@ -1435,7 +1435,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error closing live stream", ex); + _logger.LogError(ex, "Error closing live stream"); } } @@ -1511,20 +1511,20 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error deleting 0-byte failed recording file {0}", ex, path); + _logger.LogError(ex, "Error deleting 0-byte failed recording file {path}", path); } } } private void TriggerRefresh(string path) { - _logger.LogInformation("Triggering refresh on {0}", path); + _logger.LogInformation("Triggering refresh on {path}", path); var item = GetAffectedBaseItem(_fileSystem.GetDirectoryName(path)); if (item != null) { - _logger.LogInformation("Refreshing recording parent {0}", item.Path); + _logger.LogInformation("Refreshing recording parent {path}", item.Path); _providerManager.QueueRefresh(item.Id, new MetadataRefreshOptions(new DirectoryService(_logger, _fileSystem)) { @@ -1642,7 +1642,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error deleting item", ex); + _logger.LogError(ex, "Error deleting item"); } } } @@ -1668,7 +1668,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error deleting recording", ex); + _logger.LogError(ex, "Error deleting recording"); } } } @@ -1780,7 +1780,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error running recording post processor", ex); + _logger.LogError(ex, "Error running recording post processor"); } } @@ -1794,7 +1794,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV var process = (IProcess)sender; try { - _logger.LogInformation("Recording post-processing script completed with exit code {0}", process.ExitCode); + _logger.LogInformation("Recording post-processing script completed with exit code {ExitCode}", process.ExitCode); } catch { @@ -1875,7 +1875,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error saving recording image", ex); + _logger.LogError(ex, "Error saving recording image"); } } @@ -1890,7 +1890,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error saving recording image", ex); + _logger.LogError(ex, "Error saving recording image"); } } @@ -1903,7 +1903,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error saving recording image", ex); + _logger.LogError(ex, "Error saving recording image"); } } @@ -1916,7 +1916,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error saving recording image", ex); + _logger.LogError(ex, "Error saving recording image"); } } } @@ -1984,7 +1984,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error saving nfo", ex); + _logger.LogError(ex, "Error saving nfo"); } } @@ -2814,7 +2814,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error discovering tuner devices", ex); + _logger.LogError(ex, "Error discovering tuner devices"); return new List(); } diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs index af5e96c057..4ea83b7acd 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs @@ -269,14 +269,14 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { try { - _logger.LogInformation("Stopping ffmpeg recording process for {0}", _targetPath); + _logger.LogInformation("Stopping ffmpeg recording process for {path}", _targetPath); //process.Kill(); _process.StandardInput.WriteLine("q"); } catch (Exception ex) { - _logger.LogError("Error stopping recording transcoding job for {0}", ex, _targetPath); + _logger.LogError(ex, "Error stopping recording transcoding job for {path}", _targetPath); } if (_hasExited) @@ -286,7 +286,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV try { - _logger.LogInformation("Calling recording process.WaitForExit for {0}", _targetPath); + _logger.LogInformation("Calling recording process.WaitForExit for {path}", _targetPath); if (_process.WaitForExit(10000)) { @@ -295,7 +295,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error waiting for recording process to exit for {0}", ex, _targetPath); + _logger.LogError(ex, "Error waiting for recording process to exit for {path}", _targetPath); } if (_hasExited) @@ -305,13 +305,13 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV try { - _logger.LogInformation("Killing ffmpeg recording process for {0}", _targetPath); + _logger.LogInformation("Killing ffmpeg recording process for {path}", _targetPath); _process.Kill(); } catch (Exception ex) { - _logger.LogError("Error killing recording transcoding job for {0}", ex, _targetPath); + _logger.LogError(ex, "Error killing recording transcoding job for {path}", _targetPath); } } } @@ -329,7 +329,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { var exitCode = process.ExitCode; - _logger.LogInformation("FFMpeg recording exited with code {0} for {1}", exitCode, _targetPath); + _logger.LogInformation("FFMpeg recording exited with code {ExitCode} for {path}", exitCode, _targetPath); if (exitCode == 0) { @@ -337,13 +337,13 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } else { - _taskCompletionSource.TrySetException(new Exception(string.Format("Recording for {0} failed. Exit code {1}", _targetPath, exitCode))); + _taskCompletionSource.TrySetException(new Exception(string.Format("Recording for {path} failed. Exit code {ExitCode}", _targetPath, exitCode))); } } catch { - _logger.LogError("FFMpeg recording exited with an error for {0}.", _targetPath); - _taskCompletionSource.TrySetException(new Exception(string.Format("Recording for {0} failed", _targetPath))); + _logger.LogError("FFMpeg recording exited with an error for {path}.", _targetPath); + _taskCompletionSource.TrySetException(new Exception(string.Format("Recording for {path} failed", _targetPath))); } } @@ -357,7 +357,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error disposing recording log stream", ex); + _logger.LogError(ex, "Error disposing recording log stream"); } _logFileStream = null; @@ -387,7 +387,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error reading ffmpeg recording log", ex); + _logger.LogError(ex, "Error reading ffmpeg recording log"); } } } diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs index 813a7a5f9a..9f179dc2ce 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs @@ -59,7 +59,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - Logger.LogError("Error deserializing {0}", ex, jsonFile); + Logger.LogError(ex, "Error deserializing {jsonFile}", jsonFile); } return new List(); } diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs index f00a54c7f3..5618579f6f 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs @@ -143,7 +143,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (Exception ex) { - _logger.LogError("Error scheduling wake timer", ex); + _logger.LogError(ex, "Error scheduling wake timer"); } } @@ -153,12 +153,12 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV if (_timers.TryAdd(item.Id, timer)) { - _logger.LogInformation("Creating recording timer for {0}, {1}. Timer will fire in {2} minutes", item.Id, item.Name, dueTime.TotalMinutes.ToString(CultureInfo.InvariantCulture)); + _logger.LogInformation("Creating recording timer for {id}, {name}. Timer will fire in {minutes} minutes", item.Id, item.Name, dueTime.TotalMinutes.ToString(CultureInfo.InvariantCulture)); } else { timer.Dispose(); - _logger.LogWarning("Timer already exists for item {0}", item.Id); + _logger.LogWarning("Timer already exists for item {id}", item.Id); } } diff --git a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs index 48b4e58339..8fb3af2113 100644 --- a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs +++ b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs @@ -527,7 +527,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings } catch (Exception ex) { - _logger.LogError("Error getting image info from schedules direct", ex); + _logger.LogError(ex, "Error getting image info from schedules direct"); return new List(); } @@ -557,35 +557,33 @@ namespace Emby.Server.Implementations.LiveTv.Listings try { using (var httpResponse = await Get(options, false, info).ConfigureAwait(false)) + using (Stream responce = httpResponse.Content) { - using (Stream responce = httpResponse.Content) - { - var root = await _jsonSerializer.DeserializeFromStreamAsync>(responce).ConfigureAwait(false); + var root = await _jsonSerializer.DeserializeFromStreamAsync>(responce).ConfigureAwait(false); - if (root != null) + if (root != null) + { + foreach (ScheduleDirect.Headends headend in root) { - foreach (ScheduleDirect.Headends headend in root) + foreach (ScheduleDirect.Lineup lineup in headend.lineups) { - foreach (ScheduleDirect.Lineup lineup in headend.lineups) + lineups.Add(new NameIdPair { - lineups.Add(new NameIdPair - { - Name = string.IsNullOrWhiteSpace(lineup.name) ? lineup.lineup : lineup.name, - Id = lineup.uri.Substring(18) - }); - } + Name = string.IsNullOrWhiteSpace(lineup.name) ? lineup.lineup : lineup.name, + Id = lineup.uri.Substring(18) + }); } } - else - { - _logger.LogInformation("No lineups available"); - } + } + else + { + _logger.LogInformation("No lineups available"); } } } catch (Exception ex) { - _logger.LogError("Error getting headends", ex); + _logger.LogError(ex, "Error getting headends"); } return lineups; diff --git a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs index cc8840e14a..6fe5787158 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs @@ -170,6 +170,7 @@ namespace Emby.Server.Implementations.LiveTv } catch (Exception ex) { + _logger.LogError(ex, "Error"); } } image = librarySeries.GetImageInfo(ImageType.Backdrop, 0); @@ -185,6 +186,7 @@ namespace Emby.Server.Implementations.LiveTv } catch (Exception ex) { + _logger.LogError(ex, "Error"); } } } @@ -212,6 +214,7 @@ namespace Emby.Server.Implementations.LiveTv } catch (Exception ex) { + _logger.LogError(ex, "Error"); } } @@ -230,6 +233,7 @@ namespace Emby.Server.Implementations.LiveTv } catch (Exception ex) { + _logger.LogError(ex, "Error"); } } } @@ -260,6 +264,7 @@ namespace Emby.Server.Implementations.LiveTv } catch (Exception ex) { + _logger.LogError(ex, "Error"); } } image = librarySeries.GetImageInfo(ImageType.Backdrop, 0); @@ -275,6 +280,7 @@ namespace Emby.Server.Implementations.LiveTv } catch (Exception ex) { + _logger.LogError(ex, "Error"); } } } @@ -333,6 +339,7 @@ namespace Emby.Server.Implementations.LiveTv } catch (Exception ex) { + _logger.LogError(ex, "Error"); } } } @@ -376,7 +383,7 @@ namespace Emby.Server.Implementations.LiveTv } catch (Exception ex) { - _logger.LogError("Error getting image info for {0}", ex, info.Name); + _logger.LogError(ex, "Error getting image info for {name}", info.Name); } return null; diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index 679f8668b4..ee2a9fe4b3 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -1089,7 +1089,7 @@ namespace Emby.Server.Implementations.LiveTv { cancellationToken.ThrowIfCancellationRequested(); - _logger.LogDebug("Refreshing guide from {0}", service.Name); + _logger.LogDebug("Refreshing guide from {name}", service.Name); try { @@ -1108,7 +1108,7 @@ namespace Emby.Server.Implementations.LiveTv catch (Exception ex) { cleanDatabase = false; - _logger.LogError("Error refreshing channels for service", ex); + _logger.LogError(ex, "Error refreshing channels for service"); } numComplete++; @@ -1171,7 +1171,7 @@ namespace Emby.Server.Implementations.LiveTv } catch (Exception ex) { - _logger.LogError("Error getting channel information for {0}", ex, channelInfo.Item2.Name); + _logger.LogError(ex, "Error getting channel information for {name}", channelInfo.Item2.Name); } numComplete++; @@ -1300,7 +1300,7 @@ namespace Emby.Server.Implementations.LiveTv } catch (Exception ex) { - _logger.LogError("Error getting programs for channel {0}", ex, currentChannel.Name); + _logger.LogError(ex, "Error getting programs for channel {name}", currentChannel.Name); } numComplete++; @@ -1645,7 +1645,7 @@ namespace Emby.Server.Implementations.LiveTv } catch (Exception ex) { - _logger.LogError("Error getting recordings", ex); + _logger.LogError(ex, "Error getting recordings"); return new List>(); } }); @@ -1721,7 +1721,7 @@ namespace Emby.Server.Implementations.LiveTv } catch (Exception ex) { - _logger.LogError("Error getting recordings", ex); + _logger.LogError(ex, "Error getting recordings"); return new List>(); } }); @@ -1876,7 +1876,7 @@ namespace Emby.Server.Implementations.LiveTv } catch (Exception ex) { - _logger.LogError("Error getting recordings", ex); + _logger.LogError(ex, "Error getting recordings"); return new List>(); } }); @@ -1922,7 +1922,7 @@ namespace Emby.Server.Implementations.LiveTv } catch (Exception ex) { - _logger.LogError("Error getting recordings", ex); + _logger.LogError(ex, "Error getting recordings"); return new List>(); } }); diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs index 97c33f1fa8..ef2010ba64 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs @@ -114,7 +114,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } catch (Exception ex) { - Logger.LogError("Error getting channel list", ex); + Logger.LogError(ex, "Error getting channel list"); if (enableCache) { @@ -161,7 +161,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } catch (Exception ex) { - Logger.LogError("Error getting channels", ex); + Logger.LogError(ex, "Error getting channels"); } } } @@ -201,7 +201,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } catch (Exception ex) { - Logger.LogError("Error getting channels", ex); + Logger.LogError(ex, "Error getting channels"); } } @@ -221,7 +221,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } catch (Exception ex) { - Logger.LogError("Error opening tuner", ex); + Logger.LogError(ex, "Error opening tuner"); } } diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs index a8d1dcaa31..be090df0c9 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs @@ -303,7 +303,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun } catch (Exception ex) { - Logger.LogError("Error getting tuner info", ex); + Logger.LogError(ex, "Error getting tuner info"); } } diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs index 933c341242..c781bccbb7 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs @@ -56,7 +56,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun FileSystem.CreateDirectory(FileSystem.GetDirectoryName(TempFilePath)); - Logger.LogInformation("Opening HDHR UDP Live stream from {0}", uri.Host); + Logger.LogInformation("Opening HDHR UDP Live stream from {host}", uri.Host); var remoteAddress = IPAddress.Parse(uri.Host); var embyRemoteAddress = _networkManager.ParseIpAddress(uri.Host); @@ -69,9 +69,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun localAddress = ((IPEndPoint)tcpSocket.LocalEndPoint).Address; tcpSocket.Close(); } - catch (Exception) + catch (Exception ex) { - Logger.LogError("Unable to determine local ip address for Legacy HDHomerun stream."); + Logger.LogError(ex, "Unable to determine local ip address for Legacy HDHomerun stream."); return; } } @@ -87,21 +87,19 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun catch (Exception ex) { using (udpClient) + using (hdHomerunManager) { - using (hdHomerunManager) + if (!(ex is OperationCanceledException)) { - if (!(ex is OperationCanceledException)) - { - Logger.LogError("Error opening live stream:", ex); - } - throw; + Logger.LogError(ex, "Error opening live stream:"); } + throw; } } var taskCompletionSource = new TaskCompletionSource(); - StartStreaming(udpClient, hdHomerunManager, remoteAddress, taskCompletionSource, LiveStreamCancellationTokenSource.Token); + await StartStreaming(udpClient, hdHomerunManager, remoteAddress, taskCompletionSource, LiveStreamCancellationTokenSource.Token); //OpenedMediaSource.Protocol = MediaProtocol.File; //OpenedMediaSource.Path = tempFile; @@ -122,26 +120,24 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun return Task.Run(async () => { using (udpClient) + using (hdHomerunManager) { - using (hdHomerunManager) + try { - try - { - await CopyTo(udpClient, TempFilePath, openTaskCompletionSource, cancellationToken).ConfigureAwait(false); - } - catch (OperationCanceledException ex) - { - Logger.LogInformation("HDHR UDP stream cancelled or timed out from {0}", remoteAddress); - openTaskCompletionSource.TrySetException(ex); - } - catch (Exception ex) - { - Logger.LogError("Error opening live stream:", ex); - openTaskCompletionSource.TrySetException(ex); - } - - EnableStreamSharing = false; + await CopyTo(udpClient, TempFilePath, openTaskCompletionSource, cancellationToken).ConfigureAwait(false); } + catch (OperationCanceledException ex) + { + Logger.LogInformation("HDHR UDP stream cancelled or timed out from {0}", remoteAddress); + openTaskCompletionSource.TrySetException(ex); + } + catch (Exception ex) + { + Logger.LogError(ex, "Error opening live stream:"); + openTaskCompletionSource.TrySetException(ex); + } + + EnableStreamSharing = false; } await DeleteTempFiles(new List { TempFilePath }).ConfigureAwait(false); @@ -166,30 +162,28 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun var resolved = false; using (var source = _socketFactory.CreateNetworkStream(udpClient, false)) + using (var fileStream = FileSystem.GetFileStream(file, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, FileOpenOptions.None)) { - using (var fileStream = FileSystem.GetFileStream(file, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, FileOpenOptions.None)) - { - var currentCancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, new CancellationTokenSource(TimeSpan.FromSeconds(30)).Token).Token; + var currentCancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, new CancellationTokenSource(TimeSpan.FromSeconds(30)).Token).Token; - while ((read = await source.ReadAsync(buffer, 0, buffer.Length, currentCancellationToken).ConfigureAwait(false)) != 0) - { - cancellationToken.ThrowIfCancellationRequested(); + while ((read = await source.ReadAsync(buffer, 0, buffer.Length, currentCancellationToken).ConfigureAwait(false)) != 0) + { + cancellationToken.ThrowIfCancellationRequested(); - currentCancellationToken = cancellationToken; + currentCancellationToken = cancellationToken; - read -= RtpHeaderBytes; + read -= RtpHeaderBytes; - if (read > 0) - { - fileStream.Write(buffer, RtpHeaderBytes, read); - } + if (read > 0) + { + fileStream.Write(buffer, RtpHeaderBytes, read); + } - if (!resolved) - { - resolved = true; - DateOpened = DateTime.UtcNow; - Resolve(openTaskCompletionSource); - } + if (!resolved) + { + resolved = true; + DateOpened = DateTime.UtcNow; + Resolve(openTaskCompletionSource); } } } diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs index b1eda3b7f2..4a2b4ebb22 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs @@ -95,7 +95,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } catch (Exception ex) { - Logger.LogError("Error closing live stream", ex); + Logger.LogError(ex, "Error closing live stream"); } } @@ -139,7 +139,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } catch (Exception ex) { - //Logger.LogError("Error deleting file {0}", ex, path); + Logger.LogError(ex, "Error deleting file {path}", path); failedFiles.Add(path); } } @@ -242,7 +242,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } catch (Exception ex) { - Logger.LogError("Error seeking stream", ex); + Logger.LogError(ex, "Error seeking stream"); } } } diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs index ca53036a41..9b10daba0d 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs @@ -138,7 +138,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } catch (Exception ex) { - Logger.LogError("Error copying live stream.", ex); + Logger.LogError(ex, "Error copying live stream."); } EnableStreamSharing = false; await DeleteTempFiles(new List { TempFilePath }).ConfigureAwait(false); diff --git a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs index 3c72635817..792ffb3c4f 100644 --- a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs +++ b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs @@ -166,7 +166,7 @@ namespace Emby.Server.Implementations.MediaEncoder } catch (Exception ex) { - _logger.LogError("Error extracting chapter images for {0}", ex, string.Join(",", video.Path)); + _logger.LogError(ex, "Error extracting chapter images for {0}", string.Join(",", video.Path)); success = false; break; } @@ -226,7 +226,7 @@ namespace Emby.Server.Implementations.MediaEncoder foreach (var image in deadImages) { - _logger.LogDebug("Deleting dead chapter image {0}", image); + _logger.LogDebug("Deleting dead chapter image {path}", image); try { @@ -234,7 +234,7 @@ namespace Emby.Server.Implementations.MediaEncoder } catch (IOException ex) { - _logger.LogError("Error deleting {0}.", ex, image); + _logger.LogError(ex, "Error deleting {path}.", image); } } } diff --git a/Emby.Server.Implementations/Networking/NetworkManager.cs b/Emby.Server.Implementations/Networking/NetworkManager.cs index 7945680b36..260d20e35b 100644 --- a/Emby.Server.Implementations/Networking/NetworkManager.cs +++ b/Emby.Server.Implementations/Networking/NetworkManager.cs @@ -36,7 +36,7 @@ namespace Emby.Server.Implementations.Networking } catch (Exception ex) { - Logger.LogError("Error binding to NetworkAddressChanged event", ex); + Logger.LogError(ex, "Error binding to NetworkAddressChanged event"); } try @@ -45,7 +45,7 @@ namespace Emby.Server.Implementations.Networking } catch (Exception ex) { - Logger.LogError("Error binding to NetworkChange_NetworkAvailabilityChanged event", ex); + Logger.LogError(ex, "Error binding to NetworkChange_NetworkAvailabilityChanged event"); } } } @@ -372,7 +372,7 @@ namespace Emby.Server.Implementations.Networking } catch (Exception ex) { - Logger.LogError("Error resovling hostname", ex); + Logger.LogError(ex, "Error resolving hostname"); } } } @@ -399,7 +399,7 @@ namespace Emby.Server.Implementations.Networking } catch (Exception ex) { - Logger.LogError("Error in GetAllNetworkInterfaces", ex); + Logger.LogError(ex, "Error in GetAllNetworkInterfaces"); return new List(); } @@ -428,7 +428,7 @@ namespace Emby.Server.Implementations.Networking } catch (Exception ex) { - Logger.LogError("Error querying network interface", ex); + Logger.LogError(ex, "Error querying network interface"); return new List(); } diff --git a/Emby.Server.Implementations/News/NewsEntryPoint.cs b/Emby.Server.Implementations/News/NewsEntryPoint.cs index 95ec2a672c..ce6fe6630b 100644 --- a/Emby.Server.Implementations/News/NewsEntryPoint.cs +++ b/Emby.Server.Implementations/News/NewsEntryPoint.cs @@ -67,7 +67,7 @@ namespace Emby.Server.Implementations.News } catch (Exception ex) { - _logger.LogError("Error downloading news", ex); + _logger.LogError(ex, "Error downloading news"); } } diff --git a/Emby.Server.Implementations/ResourceFileManager.cs b/Emby.Server.Implementations/ResourceFileManager.cs index b268e00db9..04cf0632c3 100644 --- a/Emby.Server.Implementations/ResourceFileManager.cs +++ b/Emby.Server.Implementations/ResourceFileManager.cs @@ -59,7 +59,7 @@ namespace Emby.Server.Implementations } catch (Exception ex) { - _logger.LogError("Error in Path.GetFullPath", ex); + _logger.LogError(ex, "Error in Path.GetFullPath"); } // Don't allow file system access outside of the source folder diff --git a/Emby.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs b/Emby.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs index c77efb5cdb..46a7f1f277 100644 --- a/Emby.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs @@ -89,11 +89,11 @@ namespace Emby.Server.Implementations.ScheduledTasks } catch (HttpException ex) { - _logger.LogError("Error downloading {0}", ex, package.name); + _logger.LogError(ex, "Error downloading {name}", package.name); } catch (IOException ex) { - _logger.LogError("Error updating {0}", ex, package.name); + _logger.LogError(ex, "Error updating {name}", package.name); } // Update progress diff --git a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs index 93e02063b7..7c2ce4af3a 100644 --- a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs +++ b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs @@ -146,7 +146,7 @@ namespace Emby.Server.Implementations.ScheduledTasks } catch (Exception ex) { - Logger.LogError("Error deserializing {0}", ex, path); + Logger.LogError(ex, "Error deserializing {path}", path); } _readFromFile = true; } @@ -436,7 +436,7 @@ namespace Emby.Server.Implementations.ScheduledTasks } catch (Exception ex) { - Logger.LogError("Error", ex); + Logger.LogError(ex, "Error"); failureException = ex; @@ -669,7 +669,7 @@ namespace Emby.Server.Implementations.ScheduledTasks } catch (Exception ex) { - Logger.LogError("Error calling CancellationToken.Cancel();", ex); + Logger.LogError(ex, "Error calling CancellationToken.Cancel();"); } } var task = _currentTask; @@ -691,7 +691,7 @@ namespace Emby.Server.Implementations.ScheduledTasks } catch (Exception ex) { - Logger.LogError("Error calling Task.WaitAll();", ex); + Logger.LogError(ex, "Error calling Task.WaitAll();"); } } @@ -704,7 +704,7 @@ namespace Emby.Server.Implementations.ScheduledTasks } catch (Exception ex) { - Logger.LogError("Error calling CancellationToken.Dispose();", ex); + Logger.LogError(ex, "Error calling CancellationToken.Dispose();"); } } if (wassRunning) diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs index efadd71111..c60f59ce47 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs @@ -132,11 +132,11 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks } catch (UnauthorizedAccessException ex) { - _logger.LogError("Error deleting directory {0}", ex, directory); + _logger.LogError(ex, "Error deleting directory {path}", directory); } catch (IOException ex) { - _logger.LogError("Error deleting directory {0}", ex, directory); + _logger.LogError(ex, "Error deleting directory {path}", directory); } } } @@ -150,11 +150,11 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks } catch (UnauthorizedAccessException ex) { - _logger.LogError("Error deleting file {0}", ex, path); + _logger.LogError(ex, "Error deleting file {path}", path); } catch (IOException ex) { - _logger.LogError("Error deleting file {0}", ex, path); + _logger.LogError(ex, "Error deleting file {path}", path); } } diff --git a/Emby.Server.Implementations/Security/AuthenticationRepository.cs b/Emby.Server.Implementations/Security/AuthenticationRepository.cs index d2c6ed33ba..228d511ce6 100644 --- a/Emby.Server.Implementations/Security/AuthenticationRepository.cs +++ b/Emby.Server.Implementations/Security/AuthenticationRepository.cs @@ -83,7 +83,7 @@ namespace Emby.Server.Implementations.Security } catch (Exception ex) { - Logger.LogError("Error migrating authentication database", ex); + Logger.LogError(ex, "Error migrating authentication database"); } } diff --git a/Emby.Server.Implementations/Security/PluginSecurityManager.cs b/Emby.Server.Implementations/Security/PluginSecurityManager.cs index aa0f390307..2b1494c397 100644 --- a/Emby.Server.Implementations/Security/PluginSecurityManager.cs +++ b/Emby.Server.Implementations/Security/PluginSecurityManager.cs @@ -150,18 +150,15 @@ namespace Emby.Server.Implementations.Security SaveAppStoreInfo(parameters); throw; } - catch (HttpException e) + catch (HttpException ex) { - _logger.LogError("Error registering appstore purchase {0}", e, parameters ?? "NO PARMS SENT"); + _logger.LogError(ex, "Error registering appstore purchase {parameters}", parameters ?? "NO PARMS SENT"); - if (e.StatusCode.HasValue && e.StatusCode.Value == HttpStatusCode.PaymentRequired) - { - } throw new Exception("Error registering store sale"); } - catch (Exception e) + catch (Exception ex) { - _logger.LogError("Error registering appstore purchase {0}", e, parameters ?? "NO PARMS SENT"); + _logger.LogError(ex, "Error registering appstore purchase {parameters}", parameters ?? "NO PARMS SENT"); SaveAppStoreInfo(parameters); //TODO - could create a re-try routine on start-up if this file is there. For now we can handle manually. throw new Exception("Error registering store sale"); diff --git a/Emby.Server.Implementations/Udp/UdpServer.cs b/Emby.Server.Implementations/Udp/UdpServer.cs index 222ec7dd05..8cacc1124d 100644 --- a/Emby.Server.Implementations/Udp/UdpServer.cs +++ b/Emby.Server.Implementations/Udp/UdpServer.cs @@ -79,7 +79,7 @@ namespace Emby.Server.Implementations.Udp } catch (Exception ex) { - _logger.LogError("Error in OnMessageReceived", ex); + _logger.LogError(ex, "Error in OnMessageReceived"); } } } @@ -171,7 +171,7 @@ namespace Emby.Server.Implementations.Udp } catch (Exception ex) { - _logger.LogError("Error receiving udp message", ex); + _logger.LogError(ex, "Error receiving udp message"); } } @@ -193,7 +193,7 @@ namespace Emby.Server.Implementations.Udp } catch (Exception ex) { - _logger.LogError("Error receiving udp message", ex); + _logger.LogError(ex, "Error receiving udp message"); } BeginReceive(); @@ -224,7 +224,7 @@ namespace Emby.Server.Implementations.Udp } catch (Exception ex) { - _logger.LogError("Error handling UDP message", ex); + _logger.LogError(ex, "Error handling UDP message"); } } @@ -274,7 +274,7 @@ namespace Emby.Server.Implementations.Udp { await _udpClient.SendToAsync(bytes, 0, bytes.Length, remoteEndPoint, cancellationToken).ConfigureAwait(false); - _logger.LogInformation("Udp message sent to {0}", remoteEndPoint); + _logger.LogInformation("Udp message sent to {remoteEndPoint}", remoteEndPoint); } catch (OperationCanceledException) { @@ -282,7 +282,7 @@ namespace Emby.Server.Implementations.Udp } catch (Exception ex) { - _logger.LogError("Error sending message to {0}", ex, remoteEndPoint); + _logger.LogError(ex, "Error sending message to {remoteEndPoint}", remoteEndPoint); } } } diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index f864b079ab..b4d18b69cf 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -499,7 +499,7 @@ namespace Emby.Server.Implementations.Updates } catch (Exception ex) { - _logger.LogError("Package installation failed", ex); + _logger.LogError(ex, "Package installation failed"); lock (CurrentInstallations) { @@ -610,9 +610,9 @@ namespace Emby.Server.Implementations.Updates _fileSystem.WriteAllText(target + ".ver", package.versionStr); } } - catch (IOException e) + catch (IOException ex) { - _logger.LogError("Error attempting to move file from {0} to {1}", e, tempFile, target); + _logger.LogError(ex, "Error attempting to move file from {TempFile} to {TargetFile}", tempFile, target); throw; } @@ -620,10 +620,10 @@ namespace Emby.Server.Implementations.Updates { _fileSystem.DeleteFile(tempFile); } - catch (IOException e) + catch (IOException ex) { // Don't fail because of this - _logger.LogError("Error deleting temp file {0]", e, tempFile); + _logger.LogError(ex, "Error deleting temp file {TempFile}", tempFile); } } diff --git a/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs b/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs index bbcd1eed35..d96c391fb0 100644 --- a/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs +++ b/Emby.XmlTv/Emby.XmlTv/Classes/XmlTvReader.cs @@ -87,7 +87,7 @@ namespace Emby.XmlTv.Classes if (string.IsNullOrEmpty(id)) { - //LLogError("No id found for channel row"); + // LogError("No id found for channel row"); // Log.Error(" channel#{0} doesnt contain an id", iChannel); return null; } @@ -130,7 +130,7 @@ namespace Emby.XmlTv.Classes if (string.IsNullOrEmpty(result.DisplayName)) { - //LLogError("No display-name found for channel {0}", id); + // LogError("No display-name found for channel {0}", id); return null; } diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs index b51bdf6fd5..ed0a0c81a9 100644 --- a/MediaBrowser.Api/ApiEntryPoint.cs +++ b/MediaBrowser.Api/ApiEntryPoint.cs @@ -147,7 +147,7 @@ namespace MediaBrowser.Api } catch (Exception ex) { - Logger.LogError("Error deleting encoded media cache", ex); + Logger.LogError(ex, "Error deleting encoded media cache"); } } @@ -557,7 +557,7 @@ namespace MediaBrowser.Api { try { - Logger.LogInformation("Stopping ffmpeg process with q command for {0}", job.Path); + Logger.LogInformation("Stopping ffmpeg process with q command for {path}", job.Path); //process.Kill(); process.StandardInput.WriteLine("q"); @@ -565,13 +565,13 @@ namespace MediaBrowser.Api // Need to wait because killing is asynchronous if (!process.WaitForExit(5000)) { - Logger.LogInformation("Killing ffmpeg process for {0}", job.Path); + Logger.LogInformation("Killing ffmpeg process for {path}", job.Path); process.Kill(); } } catch (Exception ex) { - Logger.LogError("Error killing transcoding job for {0}", ex, job.Path); + Logger.LogError(ex, "Error killing transcoding job for {path}", job.Path); } } } @@ -589,7 +589,7 @@ namespace MediaBrowser.Api } catch (Exception ex) { - Logger.LogError("Error closing live stream for {0}", ex, job.Path); + Logger.LogError(ex, "Error closing live stream for {path}", job.Path); } } } @@ -620,15 +620,15 @@ namespace MediaBrowser.Api { } - catch (IOException) + catch (IOException ex) { - //Logger.LogError("Error deleting partial stream file(s) {0}", ex, path); + Logger.LogError(ex, "Error deleting partial stream file(s) {path}", path); DeletePartialStreamFiles(path, jobType, retryCount + 1, 500); } - catch + catch (Exception ex) { - //Logger.LogError("Error deleting partial stream file(s) {0}", ex, path); + Logger.LogError(ex, "Error deleting partial stream file(s) {path}", path); } } @@ -670,7 +670,7 @@ namespace MediaBrowser.Api catch (IOException ex) { e = ex; - //Logger.LogError("Error deleting HLS file {0}", ex, file); + Logger.LogError(ex, "Error deleting HLS file {path}", file); } } diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs index 28a4245123..17c6d5dc5e 100644 --- a/MediaBrowser.Api/Images/ImageService.cs +++ b/MediaBrowser.Api/Images/ImageService.cs @@ -362,7 +362,7 @@ namespace MediaBrowser.Api.Images } catch (Exception ex) { - Logger.LogError("Error getting image information for {0}", ex, info.Path); + Logger.LogError(ex, "Error getting image information for {path}", info.Path); return null; } diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index cf5014328f..ecf3eb7dbd 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -1001,7 +1001,7 @@ namespace MediaBrowser.Api.Library } catch (Exception ex) { - Logger.LogError("Error refreshing library", ex); + Logger.LogError(ex, "Error refreshing library"); } }); } diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 37cc8d2d76..af56f63826 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -278,7 +278,7 @@ namespace MediaBrowser.Api.Playback } catch (Exception ex) { - Logger.LogError("Error starting ffmpeg", ex); + Logger.LogError(ex, "Error starting ffmpeg"); ApiEntryPoint.Instance.OnTranscodeFailedToStart(outputPath, TranscodingJobType, state); @@ -372,7 +372,7 @@ namespace MediaBrowser.Api.Playback //} //catch (Exception ex) //{ - // Logger.LogError("Error disposing ffmpeg.", ex); + // Logger.LogError(ex, "Error disposing ffmpeg."); //} } diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index 7dda91e5a9..5361e313cb 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -367,7 +367,7 @@ namespace MediaBrowser.Api.Playback.Hls } catch (IOException ex) { - Logger.LogError("Error deleting partial stream file(s) {0}", ex, path); + Logger.LogError(ex, "Error deleting partial stream file(s) {path}", path); var task = Task.Delay(100); Task.WaitAll(task); @@ -375,7 +375,7 @@ namespace MediaBrowser.Api.Playback.Hls } catch (Exception ex) { - Logger.LogError("Error deleting partial stream file(s) {0}", ex, path); + Logger.LogError(ex, "Error deleting partial stream file(s) {path}", path); } } diff --git a/MediaBrowser.Api/Playback/StreamState.cs b/MediaBrowser.Api/Playback/StreamState.cs index 981a4725d1..67fb04d0c2 100644 --- a/MediaBrowser.Api/Playback/StreamState.cs +++ b/MediaBrowser.Api/Playback/StreamState.cs @@ -162,7 +162,7 @@ namespace MediaBrowser.Api.Playback } catch (Exception ex) { - _logger.LogError("Error disposing log stream", ex); + _logger.LogError(ex, "Error disposing log stream"); } LogFileStream = null; @@ -179,7 +179,7 @@ namespace MediaBrowser.Api.Playback } catch (Exception ex) { - _logger.LogError("Error disposing TranscodingThrottler", ex); + _logger.LogError(ex, "Error disposing TranscodingThrottler"); } TranscodingThrottler = null; @@ -196,7 +196,7 @@ namespace MediaBrowser.Api.Playback } catch (Exception ex) { - _logger.LogError("Error closing media source", ex); + _logger.LogError(ex, "Error closing media source"); } } } diff --git a/MediaBrowser.Api/Playback/TranscodingThrottler.cs b/MediaBrowser.Api/Playback/TranscodingThrottler.cs index 47f1f777af..5852852f69 100644 --- a/MediaBrowser.Api/Playback/TranscodingThrottler.cs +++ b/MediaBrowser.Api/Playback/TranscodingThrottler.cs @@ -69,7 +69,7 @@ namespace MediaBrowser.Api.Playback } catch (Exception ex) { - _logger.LogError("Error pausing transcoding", ex); + _logger.LogError(ex, "Error pausing transcoding"); } } } @@ -78,7 +78,7 @@ namespace MediaBrowser.Api.Playback { if (_isPaused) { - _logger.LogDebug("Sending unpause command to ffmpeg"); + _logger.LogDebug("Sending resume command to ffmpeg"); try { @@ -87,7 +87,7 @@ namespace MediaBrowser.Api.Playback } catch (Exception ex) { - _logger.LogError("Error unpausing transcoding", ex); + _logger.LogError(ex, "Error resuming transcoding"); } } } @@ -110,11 +110,11 @@ namespace MediaBrowser.Api.Playback if (gap < targetGap) { - //_logger.LogDebug("Not throttling transcoder gap {0} target gap {1}", gap, targetGap); + _logger.LogDebug("Not throttling transcoder gap {0} target gap {1}", gap, targetGap); return false; } - //_logger.LogDebug("Throttling transcoder gap {0} target gap {1}", gap, targetGap); + _logger.LogDebug("Throttling transcoder gap {0} target gap {1}", gap, targetGap); return true; } @@ -135,21 +135,21 @@ namespace MediaBrowser.Api.Playback if (gap < targetGap) { - //_logger.LogDebug("Not throttling transcoder gap {0} target gap {1} bytes downloaded {2}", gap, targetGap, bytesDownloaded); + _logger.LogDebug("Not throttling transcoder gap {0} target gap {1} bytes downloaded {2}", gap, targetGap, bytesDownloaded); return false; } - //_logger.LogDebug("Throttling transcoder gap {0} target gap {1} bytes downloaded {2}", gap, targetGap, bytesDownloaded); + _logger.LogDebug("Throttling transcoder gap {0} target gap {1} bytes downloaded {2}", gap, targetGap, bytesDownloaded); return true; } - catch + catch (Exception ex) { - //_logger.LogError("Error getting output size"); + _logger.LogError(ex, "Error getting output size"); return false; } } - //_logger.LogDebug("No throttle data for " + path); + _logger.LogDebug("No throttle data for " + path); return false; } diff --git a/MediaBrowser.Api/PluginService.cs b/MediaBrowser.Api/PluginService.cs index 33e6b20207..1f1bb36144 100644 --- a/MediaBrowser.Api/PluginService.cs +++ b/MediaBrowser.Api/PluginService.cs @@ -8,13 +8,13 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Serialization; using System; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.Services; using MediaBrowser.Common.Plugins; +using Microsoft.Extensions.Logging; namespace MediaBrowser.Api { @@ -230,9 +230,9 @@ namespace MediaBrowser.Api .ToArray(); } } - catch + catch (Exception ex) { - //Logger.LogError("Error getting plugin list", ex); + Logger.LogError(ex, "Error getting plugin list"); // Play it safe here if (requireAppStoreEnabled) { diff --git a/MediaBrowser.Api/Subtitles/SubtitleService.cs b/MediaBrowser.Api/Subtitles/SubtitleService.cs index 9a149dc923..0e5b0a9640 100644 --- a/MediaBrowser.Api/Subtitles/SubtitleService.cs +++ b/MediaBrowser.Api/Subtitles/SubtitleService.cs @@ -278,7 +278,7 @@ namespace MediaBrowser.Api.Subtitles } catch (Exception ex) { - Logger.LogError("Error downloading subtitles", ex); + Logger.LogError(ex, "Error downloading subtitles"); } }); diff --git a/MediaBrowser.Common/Events/EventHelper.cs b/MediaBrowser.Common/Events/EventHelper.cs index 96d0fcae89..04a2270e3d 100644 --- a/MediaBrowser.Common/Events/EventHelper.cs +++ b/MediaBrowser.Common/Events/EventHelper.cs @@ -28,7 +28,7 @@ namespace MediaBrowser.Common.Events } catch (Exception ex) { - logger.LogError("Error in event handler", ex); + logger.LogError(ex, "Error in event handler"); } }); } @@ -54,7 +54,7 @@ namespace MediaBrowser.Common.Events } catch (Exception ex) { - logger.LogError("Error in event handler", ex); + logger.LogError(ex, "Error in event handler"); } }); } @@ -77,7 +77,7 @@ namespace MediaBrowser.Common.Events } catch (Exception ex) { - logger.LogError("Error in event handler", ex); + logger.LogError(ex, "Error in event handler"); } } } @@ -100,7 +100,7 @@ namespace MediaBrowser.Common.Events } catch (Exception ex) { - logger.LogError("Error in event handler", ex); + logger.LogError(ex, "Error in event handler"); } } } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 9ba80da698..6393a9f193 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1414,7 +1414,7 @@ namespace MediaBrowser.Controller.Entities } catch (Exception ex) { - Logger.LogError("Error refreshing owned items for {0}", ex, Path ?? Name); + Logger.LogError(ex, "Error refreshing owned items for {path}", Path ?? Name); } } diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index dbec03a212..7292b166a0 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -105,7 +105,7 @@ namespace MediaBrowser.Controller.Entities } catch (Exception ex) { - Logger.LogError("Error loading library options", ex); + Logger.LogError(ex, "Error loading library options"); return new LibraryOptions(); } diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index e9352ce400..dbe30f9a51 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -303,7 +303,7 @@ namespace MediaBrowser.Controller.Entities var id = child.Id; if (dictionary.ContainsKey(id)) { - Logger.LogError("Found folder containing items with duplicate id. Path: {0}, Child Name: {1}", + Logger.LogError("Found folder containing items with duplicate id. Path: {path}, Child Name: {ChildName}", Path ?? Name, child.Path ?? child.Name); } diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index 6d5126a445..b50a12d520 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -259,10 +259,9 @@ namespace MediaBrowser.Controller.Entities { return _libraryManager.GetGenre(i); } - catch + catch (Exception ex) { - // Full exception logged at lower levels - _logger.LogError("Error getting genre"); + _logger.LogError(ex, "Error getting genre"); return null; } @@ -383,10 +382,9 @@ namespace MediaBrowser.Controller.Entities { return _libraryManager.GetGenre(i); } - catch + catch (Exception ex) { - // Full exception logged at lower levels - _logger.LogError("Error getting genre"); + _logger.LogError(ex, "Error getting genre"); return null; } diff --git a/MediaBrowser.Controller/IO/FileData.cs b/MediaBrowser.Controller/IO/FileData.cs index 37d507753c..c0cf51ab24 100644 --- a/MediaBrowser.Controller/IO/FileData.cs +++ b/MediaBrowser.Controller/IO/FileData.cs @@ -91,7 +91,7 @@ namespace MediaBrowser.Controller.IO } catch (Exception ex) { - logger.LogError("Error resolving shortcut from {0}", ex, fullName); + logger.LogError(ex, "Error resolving shortcut from {path}", fullName); } } else if (flattenFolderDepth > 0 && isDirectory) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs index 3ec4e3bb7b..c8c2367e68 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs @@ -727,7 +727,6 @@ namespace MediaBrowser.Controller.MediaEncoding return count; } - protected void DisposeIsoMount() { if (IsoMount != null) diff --git a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs index bac7e0184c..5abbadcc72 100644 --- a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs +++ b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs @@ -232,7 +232,7 @@ namespace MediaBrowser.Controller.Net } catch (Exception ex) { - Logger.LogError("Error sending web socket message {0}", ex, Name); + Logger.LogError(ex, "Error sending web socket message {Name}", Name); DisposeConnection(tuple); } } diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index 65ff43cf95..98848a4402 100644 --- a/MediaBrowser.Controller/Session/SessionInfo.cs +++ b/MediaBrowser.Controller/Session/SessionInfo.cs @@ -337,7 +337,7 @@ namespace MediaBrowser.Controller.Session } catch (Exception ex) { - _logger.LogError("Error reporting playback progress", ex); + _logger.LogError(ex, "Error reporting playback progress"); } } @@ -379,7 +379,7 @@ namespace MediaBrowser.Controller.Session } catch (Exception ex) { - _logger.LogError("Error disposing session controller", ex); + _logger.LogError(ex, "Error disposing session controller"); } } } diff --git a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs index 4e7a7a1685..9666c82661 100644 --- a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs +++ b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs @@ -135,7 +135,7 @@ namespace MediaBrowser.LocalMetadata.Savers } catch (Exception ex) { - Logger.LogError("Error setting hidden attribute on {0} - {1}", path, ex.Message); + Logger.LogError(ex, "Error setting hidden attribute on {path}", path); } } diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index 1fd34c8fdf..187f350b8e 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -124,7 +124,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } catch (Exception ex) { - Logger.LogError("Error starting ffmpeg", ex); + Logger.LogError(ex, "Error starting ffmpeg"); OnTranscodeFailedToStart(encodingJob.OutputFilePath, encodingJob); @@ -179,9 +179,9 @@ namespace MediaBrowser.MediaEncoding.Encoder isSuccesful = exitCode == 0; } - catch + catch (Exception ex) { - Logger.LogError("FFMpeg exited with an error."); + Logger.LogError(ex, "FFMpeg exited with an error."); } if (isSuccesful && !job.IsCancelled) diff --git a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs index 9653e561c0..fb131f304c 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs @@ -41,7 +41,7 @@ namespace MediaBrowser.MediaEncoding.Encoder { if (logOutput) { - _logger.LogError("Error validating encoder", ex); + _logger.LogError(ex, "Error validating encoder"); } } @@ -78,9 +78,9 @@ namespace MediaBrowser.MediaEncoding.Encoder { output = GetProcessOutput(encoderAppPath, "-decoders"); } - catch (Exception ) + catch (Exception ex) { - //_logger.LogError("Error detecting available decoders", ex); + _logger.LogError(ex, "Error detecting available decoders"); } var found = new List(); @@ -187,7 +187,7 @@ namespace MediaBrowser.MediaEncoding.Encoder RedirectStandardOutput = true }); - _logger.LogInformation("Running {0} {1}", path, arguments); + _logger.LogInformation("Running {path} {arguments}", path, arguments); using (process) { @@ -199,16 +199,16 @@ namespace MediaBrowser.MediaEncoding.Encoder } catch { - _logger.LogInformation("Killing process {0} {1}", path, arguments); + _logger.LogInformation("Killing process {path} {arguments}", path, arguments); // Hate having to do this try { process.Kill(); } - catch (Exception ex1) + catch (Exception ex) { - _logger.LogError("Error killing process", ex1); + _logger.LogError(ex, "Error killing process"); } throw; diff --git a/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs b/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs index dcaf4a2b17..e97898ac53 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs @@ -81,7 +81,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } catch (Exception ex) { - _logger.LogError("Error disposing log stream", ex); + _logger.LogError(ex, "Error disposing log stream"); } LogFileStream = null; @@ -98,7 +98,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } catch (Exception ex) { - _logger.LogError("Error closing media source", ex); + _logger.LogError(ex, "Error closing media source"); } } } diff --git a/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs b/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs index 2f0161962e..d2cf7f3950 100644 --- a/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs +++ b/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs @@ -72,12 +72,12 @@ namespace MediaBrowser.MediaEncoding.Encoder catch (HttpException ex) { // Don't let the server crash because of this - _logger.LogError("Error downloading ffmpeg font files", ex); + _logger.LogError(ex, "Error downloading ffmpeg font files"); } catch (Exception ex) { // Don't let the server crash because of this - _logger.LogError("Error writing ffmpeg font files", ex); + _logger.LogError(ex, "Error writing ffmpeg font files"); } } @@ -103,7 +103,7 @@ namespace MediaBrowser.MediaEncoding.Encoder catch (IOException ex) { // Log this, but don't let it fail the operation - _logger.LogError("Error copying file", ex); + _logger.LogError(ex, "Error copying file"); } } @@ -127,7 +127,7 @@ namespace MediaBrowser.MediaEncoding.Encoder catch (Exception ex) { // The core can function without the font file, so handle this - _logger.LogError("Failed to download ffmpeg font file from {0}", ex, url); + _logger.LogError(ex, "Failed to download ffmpeg font file from {url}", url); } } @@ -145,12 +145,12 @@ namespace MediaBrowser.MediaEncoding.Encoder catch (IOException ex) { // Log this, but don't let it fail the operation - _logger.LogError("Error deleting temp file {0}", ex, tempFile); + _logger.LogError(ex, "Error deleting temp file {path}", tempFile); } } private void Extract7zArchive(string archivePath, string targetPath) { - _logger.LogInformation("Extracting {0} to {1}", archivePath, targetPath); + _logger.LogInformation("Extracting {ArchivePath} to {TargetPath}", archivePath, targetPath); _zipClient.ExtractAllFrom7z(archivePath, targetPath, true); } diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index 4cd66e5ced..a661d76917 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -102,8 +102,6 @@ namespace MediaBrowser.MediaEncoding.Encoder _originalFFMpegPath = ffMpegPath; _hasExternalEncoder = hasExternalEncoder; - - SetEnvironmentVariable(); } private readonly object _logLock = new object(); @@ -117,7 +115,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } catch (Exception ex) { - _logger.LogError("Error setting FFREPORT environment variable", ex); + _logger.LogError(ex, "Error setting FFREPORT environment variable"); } } } @@ -132,31 +130,11 @@ namespace MediaBrowser.MediaEncoding.Encoder } catch (Exception ex) { - //_logger.LogError("Error setting FFREPORT environment variable", ex); + _logger.LogError(ex, "Error setting FFREPORT environment variable"); } } } - private void SetEnvironmentVariable() - { - try - { - //_environmentInfo.SetProcessEnvironmentVariable("FFREPORT", "file=program-YYYYMMDD-HHMMSS.txt:level=32"); - } - catch (Exception ex) - { - _logger.LogError("Error setting FFREPORT environment variable", ex); - } - try - { - //_environmentInfo.SetUserEnvironmentVariable("FFREPORT", "file=program-YYYYMMDD-HHMMSS.txt:level=32"); - } - catch (Exception ex) - { - _logger.LogError("Error setting FFREPORT environment variable", ex); - } - } - public string EncoderLocationType { get @@ -649,9 +627,9 @@ namespace MediaBrowser.MediaEncoding.Encoder { throw; } - catch + catch (Exception ex) { - _logger.LogError("I-frame image extraction failed, will attempt standard way. Input: {0}", inputArgument); + _logger.LogError(ex, "I-frame image extraction failed, will attempt standard way. Input: {arguments}", inputArgument); } } @@ -999,7 +977,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } catch (Exception ex) { - _logger.LogError("Error in WaitForExit", ex); + _logger.LogError(ex, "Error in WaitForExit"); } try @@ -1010,7 +988,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } catch (Exception ex) { - _logger.LogError("Error killing process", ex); + _logger.LogError(ex, "Error killing process"); } } diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs index c3cf61dc1e..d0ccef2f80 100644 --- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs +++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs @@ -1351,11 +1351,11 @@ namespace MediaBrowser.MediaEncoding.Probing { video.Timestamp = GetMpegTimestamp(video.Path); - _logger.LogDebug("Video has {0} timestamp", video.Timestamp); + _logger.LogDebug("Video has {timestamp} timestamp", video.Timestamp); } catch (Exception ex) { - _logger.LogError("Error extracting timestamp info from {0}", ex, video.Path); + _logger.LogError(ex, "Error extracting timestamp info from {path}", video.Path); video.Timestamp = null; } } diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs index a3e0f89a97..43f7753927 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs @@ -431,7 +431,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles } catch (Exception ex) { - _logger.LogError("Error starting ffmpeg", ex); + _logger.LogError(ex, "Error starting ffmpeg"); throw; } @@ -448,7 +448,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles } catch (Exception ex) { - _logger.LogError("Error killing subtitle conversion process", ex); + _logger.LogError(ex, "Error killing subtitle conversion process"); } } @@ -471,7 +471,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles } catch (IOException ex) { - _logger.LogError("Error deleting converted subtitle {0}", ex, outputPath); + _logger.LogError(ex, "Error deleting converted subtitle {0}", outputPath); } } } @@ -561,7 +561,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles } catch (Exception ex) { - _logger.LogError("Error starting ffmpeg", ex); + _logger.LogError(ex, "Error starting ffmpeg"); throw; } @@ -578,7 +578,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles } catch (Exception ex) { - _logger.LogError("Error killing subtitle extraction process", ex); + _logger.LogError(ex, "Error killing subtitle extraction process"); } } @@ -603,7 +603,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles } catch (IOException ex) { - _logger.LogError("Error deleting extracted subtitle {0}", ex, outputPath); + _logger.LogError(ex, "Error deleting extracted subtitle {0}", outputPath); } } else if (!_fileSystem.FileExists(outputPath)) diff --git a/MediaBrowser.Providers/Manager/ImageSaver.cs b/MediaBrowser.Providers/Manager/ImageSaver.cs index c1cb07a0e7..6790f9b331 100644 --- a/MediaBrowser.Providers/Manager/ImageSaver.cs +++ b/MediaBrowser.Providers/Manager/ImageSaver.cs @@ -211,7 +211,7 @@ namespace MediaBrowser.Providers.Manager if (retry) { - _logger.LogError("IOException saving to {0}. {2}. Will retry saving to {1}", path, retryPath, ex.Message); + _logger.LogError(ex, "IOException saving to {0}. Will retry saving to {1}", path, retryPath); } else { @@ -271,7 +271,7 @@ namespace MediaBrowser.Providers.Manager } catch (Exception ex) { - _logger.LogError("Error setting hidden attribute on {0} - {1}", path, ex.Message); + _logger.LogError(ex, "Error setting hidden attribute on {0}", path); } } diff --git a/MediaBrowser.Providers/Manager/ItemImageProvider.cs b/MediaBrowser.Providers/Manager/ItemImageProvider.cs index a11ccd6d6c..fc30374b3a 100644 --- a/MediaBrowser.Providers/Manager/ItemImageProvider.cs +++ b/MediaBrowser.Providers/Manager/ItemImageProvider.cs @@ -173,7 +173,7 @@ namespace MediaBrowser.Providers.Manager catch (Exception ex) { result.ErrorMessage = ex.Message; - _logger.LogError("Error in {0}", ex, provider.Name); + _logger.LogError(ex, "Error in {provider}", provider.Name); } } @@ -310,7 +310,7 @@ namespace MediaBrowser.Providers.Manager catch (Exception ex) { result.ErrorMessage = ex.Message; - _logger.LogError("Error in {0}", ex, provider.Name); + _logger.LogError(ex, "Error in {provider}", provider.Name); } } @@ -577,7 +577,7 @@ namespace MediaBrowser.Providers.Manager } catch (IOException ex) { - _logger.LogError("Error examining images", ex); + _logger.LogError(ex, "Error examining images"); } } @@ -586,7 +586,7 @@ namespace MediaBrowser.Providers.Manager } catch (HttpException ex) { - // Sometimes providers send back bad url's. Just move onto the next image + // Sometimes providers send back bad urls. Just move onto the next image if (ex.StatusCode.HasValue && ex.StatusCode.Value == HttpStatusCode.NotFound) { continue; diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index 5d607f5d67..e26004923d 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -46,7 +46,7 @@ namespace MediaBrowser.Providers.Manager } catch (Exception ex) { - Logger.LogError("Error getting file {0}", ex, path); + Logger.LogError(ex, "Error getting file {path}", path); return null; } } @@ -96,7 +96,7 @@ namespace MediaBrowser.Providers.Manager localImagesFailed = true; if (!(item is IItemByName)) { - Logger.LogError("Error validating images for {0}", ex, item.Path ?? item.Name ?? "Unknown name"); + Logger.LogError(ex, "Error validating images for {0}", item.Path ?? item.Name ?? "Unknown name"); } } @@ -268,7 +268,7 @@ namespace MediaBrowser.Providers.Manager // } // catch (Exception ex) // { - // Logger.LogError("Error in AddPersonImage", ex); + // Logger.LogError(ex, "Error in AddPersonImage"); // } //} @@ -767,7 +767,7 @@ namespace MediaBrowser.Providers.Manager } catch (Exception ex) { - Logger.LogError("Error in {0}", ex, provider.Name); + Logger.LogError(ex, "Error in {provider}", provider.Name); // If a local provider fails, consider that a failure refreshResult.ErrorMessage = ex.Message; @@ -839,7 +839,7 @@ namespace MediaBrowser.Providers.Manager catch (Exception ex) { refreshResult.ErrorMessage = ex.Message; - Logger.LogError("Error in {0}", ex, provider.Name); + Logger.LogError(ex, "Error in {provider}", provider.Name); } } @@ -891,7 +891,7 @@ namespace MediaBrowser.Providers.Manager { refreshResult.Failures++; refreshResult.ErrorMessage = ex.Message; - Logger.LogError("Error in {0}", ex, provider.Name); + Logger.LogError(ex, "Error in {provider}", provider.Name); } } @@ -951,7 +951,7 @@ namespace MediaBrowser.Providers.Manager } catch (Exception ex) { - Logger.LogError("Error in {0}.HasChanged", ex, changeMonitor.GetType().Name); + Logger.LogError(ex, "Error in {0}.HasChanged", changeMonitor.GetType().Name); return false; } } diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs index e3b23ce337..8a9aae1175 100644 --- a/MediaBrowser.Providers/Manager/ProviderManager.cs +++ b/MediaBrowser.Providers/Manager/ProviderManager.cs @@ -144,7 +144,7 @@ namespace MediaBrowser.Providers.Manager return service.RefreshMetadata(item, options, cancellationToken); } - _logger.LogError("Unable to find a metadata service for item of type " + item.GetType().Name); + _logger.LogError("Unable to find a metadata service for item of type {TypeName}", item.GetType().Name); return Task.FromResult(ItemUpdateType.None); } @@ -250,7 +250,7 @@ namespace MediaBrowser.Providers.Manager } catch (Exception ex) { - _logger.LogError("{0} failed in GetImageInfos for type {1}", ex, provider.GetType().Name, item.GetType().Name); + _logger.LogError(ex, "{0} failed in GetImageInfos for type {1}", provider.GetType().Name, item.GetType().Name); return new List(); } } @@ -400,7 +400,7 @@ namespace MediaBrowser.Providers.Manager } catch (Exception ex) { - _logger.LogError("{0} failed in Supports for type {1}", ex, provider.GetType().Name, item.GetType().Name); + _logger.LogError(ex, "{0} failed in Supports for type {1}", provider.GetType().Name, item.GetType().Name); return false; } } @@ -642,7 +642,7 @@ namespace MediaBrowser.Providers.Manager } catch (Exception ex) { - _logger.LogError("Error in {0} GetSavePath", ex, saver.Name); + _logger.LogError(ex, "Error in {0} GetSavePath", saver.Name); continue; } @@ -653,7 +653,7 @@ namespace MediaBrowser.Providers.Manager } catch (Exception ex) { - _logger.LogError("Error in metadata saver", ex); + _logger.LogError(ex, "Error in metadata saver"); } finally { @@ -668,7 +668,7 @@ namespace MediaBrowser.Providers.Manager } catch (Exception ex) { - _logger.LogError("Error in metadata saver", ex); + _logger.LogError(ex, "Error in metadata saver"); } } } @@ -731,7 +731,7 @@ namespace MediaBrowser.Providers.Manager } catch (Exception ex) { - _logger.LogError("Error in {0}.IsEnabledFor", ex, saver.Name); + _logger.LogError(ex, "Error in {0}.IsEnabledFor", saver.Name); return false; } } @@ -876,7 +876,7 @@ namespace MediaBrowser.Providers.Manager } catch (Exception ex) { - _logger.LogError("Error in {0}.Suports", ex, i.GetType().Name); + _logger.LogError(ex, "Error in {0}.Suports", i.GetType().Name); return false; } }); @@ -1070,7 +1070,7 @@ namespace MediaBrowser.Providers.Manager } catch (Exception ex) { - _logger.LogError("Error refreshing item", ex); + _logger.LogError(ex, "Error refreshing item"); } } @@ -1147,7 +1147,7 @@ namespace MediaBrowser.Providers.Manager } catch (Exception ex) { - _logger.LogError("Error refreshing library", ex); + _logger.LogError(ex, "Error refreshing library"); } } diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs index 4dc3849d9f..c2fe392ab2 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs @@ -342,7 +342,7 @@ namespace MediaBrowser.Providers.MediaInfo } catch (Exception ex) { - _logger.LogError("Error getting BDInfo", ex); + _logger.LogError(ex, "Error getting BDInfo"); return null; } } diff --git a/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs b/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs index 8d5f203170..4c66f2b0af 100644 --- a/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs +++ b/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs @@ -176,7 +176,7 @@ namespace MediaBrowser.Providers.MediaInfo } catch (Exception ex) { - _logger.LogError("Error downloading subtitles", ex); + _logger.LogError(ex, "Error downloading subtitles"); } return false; diff --git a/MediaBrowser.Providers/MediaInfo/SubtitleScheduledTask.cs b/MediaBrowser.Providers/MediaInfo/SubtitleScheduledTask.cs index 4fa6a05219..81abedeb95 100644 --- a/MediaBrowser.Providers/MediaInfo/SubtitleScheduledTask.cs +++ b/MediaBrowser.Providers/MediaInfo/SubtitleScheduledTask.cs @@ -148,7 +148,7 @@ namespace MediaBrowser.Providers.MediaInfo } catch (Exception ex) { - _logger.LogError("Error downloading subtitles for {0}", ex, video.Path); + _logger.LogError(ex, "Error downloading subtitles for {Path}", video.Path); } // Update progress diff --git a/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs b/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs index da0f40a5a1..0dbc433136 100644 --- a/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs +++ b/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs @@ -774,7 +774,7 @@ namespace MediaBrowser.Providers.Music } catch (Exception ex) { - _logger.LogError("Error getting music brainz info", ex); + _logger.LogError(ex, "Error getting music brainz info"); } } } diff --git a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs index 2006067b31..2cf737511d 100644 --- a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs +++ b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs @@ -101,7 +101,7 @@ namespace MediaBrowser.Providers.Subtitles } catch (Exception ex) { - _logger.LogError("Error downloading subtitles from {0}", ex, provider.Name); + _logger.LogError(ex, "Error downloading subtitles from {Provider}", provider.Name); } } return new RemoteSubtitleInfo[] { }; @@ -119,7 +119,7 @@ namespace MediaBrowser.Providers.Subtitles } catch (Exception ex) { - _logger.LogError("Error downloading subtitles from {0}", ex, i.Name); + _logger.LogError(ex, "Error downloading subtitles from {0}", i.Name); return new RemoteSubtitleInfo[] { }; } }); diff --git a/MediaBrowser.Providers/TV/SeriesMetadataService.cs b/MediaBrowser.Providers/TV/SeriesMetadataService.cs index a943e49c09..1cb06efdfe 100644 --- a/MediaBrowser.Providers/TV/SeriesMetadataService.cs +++ b/MediaBrowser.Providers/TV/SeriesMetadataService.cs @@ -46,7 +46,7 @@ namespace MediaBrowser.Providers.TV } catch (Exception ex) { - Logger.LogError("Error in DummySeasonProvider", ex); + Logger.LogError(ex, "Error in DummySeasonProvider"); } } diff --git a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeasonProvider.cs b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeasonProvider.cs index 8b09ee2fcf..217dab663c 100644 --- a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeasonProvider.cs +++ b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeasonProvider.cs @@ -97,7 +97,7 @@ namespace MediaBrowser.Providers.TV } catch (HttpException ex) { - _logger.LogError("No metadata found for {0}", seasonNumber.Value); + _logger.LogError(ex, "No metadata found for {0}", seasonNumber.Value); if (ex.StatusCode.HasValue && ex.StatusCode.Value == HttpStatusCode.NotFound) { diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbPrescanTask.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbPrescanTask.cs index 6bad5b9257..8bab595958 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbPrescanTask.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbPrescanTask.cs @@ -358,7 +358,7 @@ namespace MediaBrowser.Providers.TV } catch (HttpException ex) { - _logger.LogError("Error updating tvdb series id {0}, language {1}", ex, seriesId, language); + _logger.LogError(ex, "Error updating tvdb series id {ID}, language {Language}", seriesId, language); // Already logged at lower levels, but don't fail the whole operation, unless timed out // We have to fail this to make it run again otherwise new episode data could potentially be missing diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.cs index 9c6ee4dd22..cf61b79fe8 100644 --- a/MediaBrowser.Server.Mono/Program.cs +++ b/MediaBrowser.Server.Mono/Program.cs @@ -270,7 +270,7 @@ namespace MediaBrowser.Server.Mono } catch (Exception ex) { - _logger.LogError("Error getting unix name", ex); + _logger.LogError(ex, "Error getting unix name"); } _unixName = uname; } diff --git a/MediaBrowser.Server.Mono/SocketSharp/WebSocketSharpListener.cs b/MediaBrowser.Server.Mono/SocketSharp/WebSocketSharpListener.cs index e8557d1f99..993863e8c8 100644 --- a/MediaBrowser.Server.Mono/SocketSharp/WebSocketSharpListener.cs +++ b/MediaBrowser.Server.Mono/SocketSharp/WebSocketSharpListener.cs @@ -114,7 +114,7 @@ namespace EmbyServer.SocketSharp } catch (Exception ex) { - _logger.LogError("Error processing request", ex); + _logger.LogError(ex, "Error processing request"); httpReq = httpReq ?? GetRequest(context); return ErrorHandler(ex, httpReq, true, true); @@ -176,7 +176,7 @@ namespace EmbyServer.SocketSharp } catch (Exception ex) { - _logger.LogError("AcceptWebSocketAsync error", ex); + _logger.LogError(ex, "AcceptWebSocketAsync error"); ctx.Response.StatusCode = 500; ctx.Response.Close(); } @@ -206,7 +206,7 @@ namespace EmbyServer.SocketSharp } catch (Exception ex) { - _logger.LogError("Error closing web socket response", ex); + _logger.LogError(ex, "Error closing web socket response"); } } diff --git a/MediaBrowser.Server.Mono/SocketSharp/WebSocketSharpResponse.cs b/MediaBrowser.Server.Mono/SocketSharp/WebSocketSharpResponse.cs index d299c64ef0..08fa4cbd62 100644 --- a/MediaBrowser.Server.Mono/SocketSharp/WebSocketSharpResponse.cs +++ b/MediaBrowser.Server.Mono/SocketSharp/WebSocketSharpResponse.cs @@ -112,7 +112,7 @@ namespace EmbyServer.SocketSharp } catch (Exception ex) { - _logger.LogError("Error in HttpListenerResponseWrapper: " + ex.Message, ex); + _logger.LogError(ex, "Error in HttpListenerResponseWrapper"); } } } diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index 0327929a94..58d02ef044 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -245,7 +245,7 @@ namespace MediaBrowser.WebDashboard.Api } catch (Exception ex) { - _logger.LogError("Error getting plugin information from {0}", ex, p.GetType().Name); + _logger.LogError(ex, "Error getting plugin information from {Plugin}", p.GetType().Name); return null; } }) diff --git a/MediaBrowser.XbmcMetadata/EntryPoint.cs b/MediaBrowser.XbmcMetadata/EntryPoint.cs index 7461e952de..dac3f49676 100644 --- a/MediaBrowser.XbmcMetadata/EntryPoint.cs +++ b/MediaBrowser.XbmcMetadata/EntryPoint.cs @@ -72,7 +72,7 @@ namespace MediaBrowser.XbmcMetadata } catch (Exception ex) { - _logger.LogError("Error saving metadata for {0}", ex, item.Path ?? item.Name); + _logger.LogError(ex, "Error saving metadata for {path}", item.Path ?? item.Name); } } } diff --git a/MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs index 27f128fcec..e6b4eea1c6 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs @@ -81,7 +81,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers } catch (Exception ex) { - Logger.LogError("Error parsing set node", ex); + Logger.LogError(ex, "Error parsing set node"); } } } diff --git a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs index 74e7143625..131ce80d55 100644 --- a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs @@ -230,7 +230,7 @@ namespace MediaBrowser.XbmcMetadata.Savers } catch (Exception ex) { - Logger.LogError("Error setting hidden attribute on {path} - {ex}", path, ex.Message); + Logger.LogError(ex, "Error setting hidden attribute on {path}", path); } } @@ -283,7 +283,7 @@ namespace MediaBrowser.XbmcMetadata.Savers } catch (XmlException ex) { - Logger.LogError("Error reading existng nfo", ex); + Logger.LogError(ex, "Error reading existing nfo"); } writer.WriteEndElement(); @@ -1000,7 +1000,7 @@ namespace MediaBrowser.XbmcMetadata.Savers } catch (Exception ex) { - logger.LogError("Error reading existing xml tags from {0}.", ex, path); + logger.LogError(ex, "Error reading existing xml tags from {path}.", path); return; } diff --git a/Mono.Nat/Pmp/PmpNatDevice.cs b/Mono.Nat/Pmp/PmpNatDevice.cs index 99d030207b..fbf3032d47 100644 --- a/Mono.Nat/Pmp/PmpNatDevice.cs +++ b/Mono.Nat/Pmp/PmpNatDevice.cs @@ -198,7 +198,7 @@ namespace Mono.Nat.Pmp } catch (Exception ex) { - _logger.LogError("Error in CreatePortMapListen", ex); + _logger.LogError(ex, "Error in CreatePortMapListen"); return; } } diff --git a/Mono.Nat/Upnp/Searchers/UpnpSearcher.cs b/Mono.Nat/Upnp/Searchers/UpnpSearcher.cs index e9e47a91e9..bcf358d1ca 100644 --- a/Mono.Nat/Upnp/Searchers/UpnpSearcher.cs +++ b/Mono.Nat/Upnp/Searchers/UpnpSearcher.cs @@ -90,7 +90,7 @@ namespace Mono.Nat } catch (Exception ex) { - _logger.LogError("Error decoding device response", ex); + _logger.LogError(ex, "Error decoding device response"); } } diff --git a/RSSDP/SsdpCommunicationsServer.cs b/RSSDP/SsdpCommunicationsServer.cs index 921ef3e514..65ec0ca714 100644 --- a/RSSDP/SsdpCommunicationsServer.cs +++ b/RSSDP/SsdpCommunicationsServer.cs @@ -131,7 +131,7 @@ namespace Rssdp.Infrastructure } catch (Exception ex) { - _logger.LogError("Error in BeginListeningForBroadcasts", ex); + _logger.LogError(ex, "Error in BeginListeningForBroadcasts"); } } } @@ -197,7 +197,7 @@ namespace Rssdp.Infrastructure } catch (Exception ex) { - _logger.LogError("Error sending socket message from {0} to {1}", ex, socket.LocalIPAddress.ToString(), destination.ToString()); + _logger.LogError(ex, "Error sending socket message from {0} to {1}", socket.LocalIPAddress.ToString(), destination.ToString()); } } @@ -376,7 +376,7 @@ namespace Rssdp.Infrastructure } catch (Exception ex) { - _logger.LogError("Error in CreateSsdpUdpSocket. IPAddress: {0}", ex, address); + _logger.LogError(ex, "Error in CreateSsdpUdpSocket. IPAddress: {0}", address); } } } diff --git a/SocketHttpListener/Net/HttpEndPointListener.cs b/SocketHttpListener/Net/HttpEndPointListener.cs index 867012d051..fb093314c8 100644 --- a/SocketHttpListener/Net/HttpEndPointListener.cs +++ b/SocketHttpListener/Net/HttpEndPointListener.cs @@ -173,7 +173,7 @@ namespace SocketHttpListener.Net { HttpEndPointListener epl = (HttpEndPointListener)acceptEventArg.UserToken; - epl._logger.LogError("Error in socket.AcceptAsync", ex); + epl._logger.LogError(ex, "Error in socket.AcceptAsync"); } } @@ -238,7 +238,7 @@ namespace SocketHttpListener.Net } catch (Exception ex) { - epl._logger.LogError("Error in ProcessAccept", ex); + epl._logger.LogError(ex, "Error in ProcessAccept"); TryClose(accepted); epl.Accept(); -- cgit v1.2.3 From c99b45dbe0b6f0b02850eda5c9ece071c6c03e85 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Mon, 31 Dec 2018 00:28:23 +0100 Subject: Remove some warnings --- .../Serialization/JsonSerializer.cs | 8 +--- MediaBrowser.Common/Updates/GithubUpdater.cs | 24 ++++------ MediaBrowser.Controller/Entities/Game.cs | 7 ++- .../MediaEncoding/EncodingJobOptions.cs | 3 -- MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs | 53 ++++++++++------------ .../Encoder/FontConfigLoader.cs | 5 +- MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 3 +- .../Probing/ProbeResultNormalizer.cs | 13 ++---- MediaBrowser.Providers/Manager/ProviderManager.cs | 30 ++++++------ .../Providers/BaseNfoProvider.cs | 14 +++--- 10 files changed, 66 insertions(+), 94 deletions(-) (limited to 'MediaBrowser.Controller/MediaEncoding') diff --git a/Emby.Server.Implementations/Serialization/JsonSerializer.cs b/Emby.Server.Implementations/Serialization/JsonSerializer.cs index 423fe7b183..e28acd769f 100644 --- a/Emby.Server.Implementations/Serialization/JsonSerializer.cs +++ b/Emby.Server.Implementations/Serialization/JsonSerializer.cs @@ -136,19 +136,15 @@ namespace Emby.Common.Implementations.Serialization return ServiceStack.Text.JsonSerializer.DeserializeFromStream(stream); } - public async Task DeserializeFromStreamAsync(Stream stream) + public Task DeserializeFromStreamAsync(Stream stream) { if (stream == null) { throw new ArgumentNullException("stream"); } - using (var reader = new StreamReader(stream)) - { - var json = await reader.ReadToEndAsync().ConfigureAwait(false); - return ServiceStack.Text.JsonSerializer.DeserializeFromString(json); - } + return ServiceStack.Text.JsonSerializer.DeserializeFromStreamAsync(stream); } /// diff --git a/MediaBrowser.Common/Updates/GithubUpdater.cs b/MediaBrowser.Common/Updates/GithubUpdater.cs index 4275799a98..22ed788e0c 100644 --- a/MediaBrowser.Common/Updates/GithubUpdater.cs +++ b/MediaBrowser.Common/Updates/GithubUpdater.cs @@ -41,13 +41,11 @@ namespace MediaBrowser.Common.Updates } using (var response = await _httpClient.SendAsync(options, "GET").ConfigureAwait(false)) + using (var stream = response.Content) { - using (var stream = response.Content) - { - var obj = _jsonSerializer.DeserializeFromStream(stream); + var obj = await _jsonSerializer.DeserializeFromStreamAsync(stream).ConfigureAwait(false); - return CheckForUpdateResult(obj, minVersion, updateLevel, assetFilename, packageName, targetFilename); - } + return CheckForUpdateResult(obj, minVersion, updateLevel, assetFilename, packageName, targetFilename); } } @@ -114,19 +112,17 @@ namespace MediaBrowser.Common.Updates }; using (var response = await _httpClient.SendAsync(options, "GET").ConfigureAwait(false)) + using (var stream = response.Content) { - using (var stream = response.Content) - { - var obj = _jsonSerializer.DeserializeFromStream(stream); + var obj = await _jsonSerializer.DeserializeFromStreamAsync(stream).ConfigureAwait(false); - obj = obj.Where(i => (i.assets ?? new List()).Any(a => IsAsset(a, assetFilename, i.tag_name))).ToArray(); + obj = obj.Where(i => (i.assets ?? new List()).Any(a => IsAsset(a, assetFilename, i.tag_name))).ToArray(); - list.AddRange(obj.Where(i => MatchesUpdateLevel(i, PackageVersionClass.Release)).OrderByDescending(GetVersion).Take(1)); - list.AddRange(obj.Where(i => MatchesUpdateLevel(i, PackageVersionClass.Beta)).OrderByDescending(GetVersion).Take(1)); - list.AddRange(obj.Where(i => MatchesUpdateLevel(i, PackageVersionClass.Dev)).OrderByDescending(GetVersion).Take(1)); + list.AddRange(obj.Where(i => MatchesUpdateLevel(i, PackageVersionClass.Release)).OrderByDescending(GetVersion).Take(1)); + list.AddRange(obj.Where(i => MatchesUpdateLevel(i, PackageVersionClass.Beta)).OrderByDescending(GetVersion).Take(1)); + list.AddRange(obj.Where(i => MatchesUpdateLevel(i, PackageVersionClass.Dev)).OrderByDescending(GetVersion).Take(1)); - return list; - } + return list; } } diff --git a/MediaBrowser.Controller/Entities/Game.cs b/MediaBrowser.Controller/Entities/Game.cs index e4c417c8a9..3d006a699c 100644 --- a/MediaBrowser.Controller/Entities/Game.cs +++ b/MediaBrowser.Controller/Entities/Game.cs @@ -1,11 +1,10 @@ -using MediaBrowser.Controller.Providers; +using System; +using System.Collections.Generic; +using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; -using System; -using System.Collections.Generic; using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; -using System; namespace MediaBrowser.Controller.Entities { diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs b/MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs index 7333149c2b..befbb21404 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs @@ -11,13 +11,10 @@ namespace MediaBrowser.Controller.MediaEncoding { public string OutputDirectory { get; set; } - public string DeviceId { get; set; } public string ItemId { get; set; } public string MediaSourceId { get; set; } public string AudioCodec { get; set; } - public DeviceProfile DeviceProfile { get; set; } - public bool ReadInputAtNativeFramerate { get; set; } /// diff --git a/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs b/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs index e97898ac53..9761de98fb 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs @@ -1,18 +1,10 @@ -using MediaBrowser.Controller.Library; +using System; +using System.IO; +using System.Threading.Tasks; +using MediaBrowser.Controller.Library; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Model.Dlna; -using MediaBrowser.Model.Drawing; -using MediaBrowser.Model.Dto; -using MediaBrowser.Model.Entities; -using MediaBrowser.Model.IO; -using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.Net; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; using Microsoft.Extensions.Logging; namespace MediaBrowser.MediaEncoding.Encoder @@ -153,7 +145,7 @@ namespace MediaBrowser.MediaEncoding.Encoder { var ticks = transcodingPosition.HasValue ? transcodingPosition.Value.Ticks : (long?)null; - // job.Framerate = framerate; + //job.Framerate = framerate; if (!percentComplete.HasValue && ticks.HasValue && RunTimeTicks.HasValue) { @@ -166,8 +158,9 @@ namespace MediaBrowser.MediaEncoding.Encoder Progress.Report(percentComplete.Value); } - // job.TranscodingPositionTicks = ticks; - // job.BytesTranscoded = bytesTranscoded; + /* + job.TranscodingPositionTicks = ticks; + job.BytesTranscoded = bytesTranscoded; var deviceId = Options.DeviceId; @@ -176,21 +169,21 @@ namespace MediaBrowser.MediaEncoding.Encoder var audioCodec = ActualOutputVideoCodec; var videoCodec = ActualOutputVideoCodec; - // SessionManager.ReportTranscodingInfo(deviceId, new TranscodingInfo - // { - // Bitrate = job.TotalOutputBitrate, - // AudioCodec = audioCodec, - // VideoCodec = videoCodec, - // Container = job.Options.OutputContainer, - // Framerate = framerate, - // CompletionPercentage = percentComplete, - // Width = job.OutputWidth, - // Height = job.OutputHeight, - // AudioChannels = job.OutputAudioChannels, - // IsAudioDirect = string.Equals(job.OutputAudioCodec, "copy", StringComparison.OrdinalIgnoreCase), - // IsVideoDirect = string.Equals(job.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase) - // }); - } + SessionManager.ReportTranscodingInfo(deviceId, new TranscodingInfo + { + Bitrate = job.TotalOutputBitrate, + AudioCodec = audioCodec, + VideoCodec = videoCodec, + Container = job.Options.OutputContainer, + Framerate = framerate, + CompletionPercentage = percentComplete, + Width = job.OutputWidth, + Height = job.OutputHeight, + AudioChannels = job.OutputAudioChannels, + IsAudioDirect = string.Equals(job.OutputAudioCodec, "copy", StringComparison.OrdinalIgnoreCase), + IsVideoDirect = string.Equals(job.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase) + }); + }*/ } } } diff --git a/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs b/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs index d2cf7f3950..c62de0b113 100644 --- a/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs +++ b/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs @@ -3,15 +3,12 @@ using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; -using MediaBrowser.Model.IO; using MediaBrowser.Common.Configuration; - using MediaBrowser.Common.Net; using MediaBrowser.Common.Progress; -using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.Net; +using Microsoft.Extensions.Logging; namespace MediaBrowser.MediaEncoding.Encoder { diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index a661d76917..181fc0f655 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -6,7 +6,6 @@ using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.Session; using MediaBrowser.MediaEncoding.Probing; using MediaBrowser.Model.Dlna; -using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; using MediaBrowser.Model.MediaInfo; @@ -550,7 +549,7 @@ namespace MediaBrowser.MediaEncoding.Encoder { //process.BeginErrorReadLine(); - var result = _jsonSerializer.DeserializeFromStream(process.StandardOutput.BaseStream); + var result = await _jsonSerializer.DeserializeFromStreamAsync(process.StandardOutput.BaseStream).ConfigureAwait(false); if (result == null || (result.streams == null && result.format == null)) { diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs index d0ccef2f80..5367a87f7b 100644 --- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs +++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs @@ -1,20 +1,17 @@ -using MediaBrowser.Model.Dto; -using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Extensions; -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Text; using System.Xml; -using MediaBrowser.Model.IO; - -using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Library; +using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Extensions; using MediaBrowser.Model.IO; -using Microsoft.Extensions.Logging; using MediaBrowser.Model.MediaInfo; +using Microsoft.Extensions.Logging; namespace MediaBrowser.MediaEncoding.Probing { diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs index 8a9aae1175..8eed5e6266 100644 --- a/MediaBrowser.Providers/Manager/ProviderManager.cs +++ b/MediaBrowser.Providers/Manager/ProviderManager.cs @@ -1,31 +1,29 @@ -using MediaBrowser.Common.Net; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using MediaBrowser.Common.Net; +using MediaBrowser.Common.Progress; using MediaBrowser.Controller; using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; -using MediaBrowser.Controller.LiveTv; using MediaBrowser.Controller.Providers; +using MediaBrowser.Controller.Subtitles; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; -using Microsoft.Extensions.Logging; -using MediaBrowser.Model.Providers; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using MediaBrowser.Common.Progress; -using MediaBrowser.Model.IO; -using MediaBrowser.Controller.Dto; using MediaBrowser.Model.Events; +using MediaBrowser.Model.IO; +using MediaBrowser.Model.Providers; using MediaBrowser.Model.Serialization; +using Microsoft.Extensions.Logging; using Priority_Queue; -using MediaBrowser.Model.Extensions; -using MediaBrowser.Controller.Subtitles; namespace MediaBrowser.Providers.Manager { @@ -827,7 +825,7 @@ namespace MediaBrowser.Providers.Manager } } } - catch (Exception ex) + catch (Exception) { // Logged at lower levels } diff --git a/MediaBrowser.XbmcMetadata/Providers/BaseNfoProvider.cs b/MediaBrowser.XbmcMetadata/Providers/BaseNfoProvider.cs index 123c0493fb..ae8e638cbd 100644 --- a/MediaBrowser.XbmcMetadata/Providers/BaseNfoProvider.cs +++ b/MediaBrowser.XbmcMetadata/Providers/BaseNfoProvider.cs @@ -1,10 +1,10 @@ -using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Providers; -using MediaBrowser.XbmcMetadata.Savers; -using System.IO; +using System.IO; using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Providers; using MediaBrowser.Model.IO; +using MediaBrowser.XbmcMetadata.Savers; namespace MediaBrowser.XbmcMetadata.Providers { @@ -13,7 +13,7 @@ namespace MediaBrowser.XbmcMetadata.Providers { protected IFileSystem FileSystem; - public async Task> GetMetadata(ItemInfo info, + public Task> GetMetadata(ItemInfo info, IDirectoryService directoryService, CancellationToken cancellationToken) { @@ -23,7 +23,7 @@ namespace MediaBrowser.XbmcMetadata.Providers if (file == null) { - return result; + return Task.FromResult(result); } var path = file.FullName; @@ -44,7 +44,7 @@ namespace MediaBrowser.XbmcMetadata.Providers result.HasMetadata = false; } - return result; + return Task.FromResult(result); } protected abstract void Fetch(MetadataResult result, string path, CancellationToken cancellationToken); -- cgit v1.2.3 From 340a2c651276d911285a6ff09944c5eba2384a51 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Thu, 27 Dec 2018 22:43:48 +0100 Subject: Post GPL cleanup --- Emby.Server.Implementations/Library/UserManager.cs | 1 - MediaBrowser.Api/BaseApiService.cs | 3 +- MediaBrowser.Api/UserService.cs | 5 +- .../Authentication/IAuthenticationProvider.cs | 6 +- .../Chapters/IChapterManager.cs | 7 -- .../Collections/CollectionCreationOptions.cs | 4 +- MediaBrowser.Controller/Connect/IConnectManager.cs | 45 -------- MediaBrowser.Controller/Dto/IDtoService.cs | 1 - .../Entities/AggregateFolder.cs | 2 +- MediaBrowser.Controller/Entities/Audio/Audio.cs | 9 +- .../Entities/Audio/MusicAlbum.cs | 4 +- .../Entities/Audio/MusicArtist.cs | 3 +- MediaBrowser.Controller/Entities/BaseItem.cs | 40 ++++--- .../Entities/CollectionFolder.cs | 14 +-- MediaBrowser.Controller/Entities/Game.cs | 12 +-- .../Entities/InternalItemsQuery.cs | 66 ++++++------ .../Entities/InternalPeopleQuery.cs | 4 +- MediaBrowser.Controller/Entities/Movies/BoxSet.cs | 19 +--- MediaBrowser.Controller/Entities/Movies/Movie.cs | 9 +- MediaBrowser.Controller/Entities/MusicVideo.cs | 2 +- MediaBrowser.Controller/Entities/Photo.cs | 5 +- MediaBrowser.Controller/Entities/TV/Episode.cs | 12 +-- MediaBrowser.Controller/Entities/TV/Season.cs | 7 +- MediaBrowser.Controller/Entities/TV/Series.cs | 8 +- MediaBrowser.Controller/Entities/Trailer.cs | 9 +- MediaBrowser.Controller/Entities/UserView.cs | 19 +--- MediaBrowser.Controller/Entities/Video.cs | 28 ++--- .../Library/IUserDataManager.cs | 1 - MediaBrowser.Controller/Library/ItemResolveArgs.cs | 8 +- MediaBrowser.Controller/LiveTv/LiveTvProgram.cs | 43 ++------ MediaBrowser.Controller/LiveTv/TimerInfo.cs | 4 +- .../MediaEncoding/EncodingHelper.cs | 33 +++--- .../MediaEncoding/EncodingJobInfo.cs | 10 +- .../MediaEncoding/EncodingJobOptions.cs | 1 - .../MediaEncoding/MediaInfoRequest.cs | 2 +- MediaBrowser.Controller/Net/AuthorizationInfo.cs | 8 +- .../Net/WebSocketConnectEventArgs.cs | 2 - .../Playlists/IPlaylistManager.cs | 1 - MediaBrowser.Controller/Playlists/Playlist.cs | 29 +++-- MediaBrowser.Controller/Providers/AlbumInfo.cs | 4 +- .../Providers/ImageRefreshOptions.cs | 4 +- .../Providers/ItemLookupInfo.cs | 2 - .../Providers/MetadataRefreshOptions.cs | 4 +- .../Providers/MetadataResult.cs | 2 +- MediaBrowser.Controller/Providers/SongInfo.cs | 7 +- .../Session/AuthenticationRequest.cs | 2 - MediaBrowser.Controller/Session/ISessionManager.cs | 1 - MediaBrowser.Controller/Session/SessionInfo.cs | 8 +- .../Subtitles/SubtitleSearchRequest.cs | 6 +- .../Images/LocalImageProvider.cs | 6 +- MediaBrowser.Model/Channels/ChannelFeatures.cs | 9 +- MediaBrowser.Model/Configuration/LibraryOptions.cs | 21 ++-- .../Configuration/MetadataOptions.cs | 21 ++-- .../Configuration/MetadataPluginSummary.cs | 8 +- .../Configuration/ServerConfiguration.cs | 49 ++++----- .../Configuration/UserConfiguration.cs | 8 +- .../Connect/ConnectAuthenticationExchangeResult.cs | 17 --- .../Connect/ConnectAuthenticationResult.cs | 17 --- MediaBrowser.Model/Connect/ConnectAuthorization.cs | 4 +- .../Connect/ConnectAuthorizationRequest.cs | 19 ---- MediaBrowser.Model/Devices/DeviceInfo.cs | 16 --- MediaBrowser.Model/Devices/DeviceQuery.cs | 5 - MediaBrowser.Model/Devices/DevicesOptions.cs | 5 +- MediaBrowser.Model/Dlna/ContainerProfile.cs | 8 +- MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs | 3 +- MediaBrowser.Model/Dlna/ResolutionNormalizer.cs | 37 ++++--- MediaBrowser.Model/Dlna/StreamInfo.cs | 8 +- MediaBrowser.Model/Dlna/SubtitleProfile.cs | 4 +- MediaBrowser.Model/Dto/BaseItemDto.cs | 35 ------ MediaBrowser.Model/Dto/ChapterInfoDto.cs | 38 ------- MediaBrowser.Model/Dto/GameSystemSummary.cs | 5 +- MediaBrowser.Model/Dto/MediaSourceInfo.cs | 9 +- MediaBrowser.Model/Dto/MetadataEditorInfo.cs | 12 +-- MediaBrowser.Model/Dto/UserDto.cs | 1 - MediaBrowser.Model/Entities/LibraryUpdateInfo.cs | 12 +-- MediaBrowser.Model/Entities/VirtualFolderInfo.cs | 2 +- MediaBrowser.Model/Globalization/CultureDto.cs | 2 +- MediaBrowser.Model/Library/UserViewQuery.cs | 2 +- MediaBrowser.Model/LiveTv/LiveTvChannelQuery.cs | 2 +- MediaBrowser.Model/LiveTv/LiveTvInfo.cs | 6 +- MediaBrowser.Model/LiveTv/LiveTvOptions.cs | 18 ++-- MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs | 2 +- MediaBrowser.Model/LiveTv/ProgramQuery.cs | 117 --------------------- .../LiveTv/RecommendedProgramQuery.cs | 73 ------------- MediaBrowser.Model/MediaInfo/MediaInfo.cs | 16 ++- .../MediaInfo/PlaybackInfoRequest.cs | 1 - .../Notifications/NotificationOption.cs | 20 +--- .../Notifications/NotificationRequest.cs | 3 - .../Notifications/NotificationServiceInfo.cs | 8 -- .../Notifications/NotificationTypeInfo.cs | 16 +-- .../Playlists/PlaylistCreationRequest.cs | 5 +- MediaBrowser.Model/Providers/SubtitleOptions.cs | 4 +- MediaBrowser.Model/Querying/QueryFilters.cs | 12 +-- MediaBrowser.Model/Search/SearchQuery.cs | 6 +- MediaBrowser.Model/Session/ClientCapabilities.cs | 6 +- MediaBrowser.Model/Session/SessionInfoDto.cs | 117 --------------------- MediaBrowser.Model/Sync/SyncJob.cs | 4 +- MediaBrowser.Model/Users/UserPolicy.cs | 16 +-- MediaBrowser.Providers/Chapters/ChapterManager.cs | 11 +- 99 files changed, 323 insertions(+), 1049 deletions(-) delete mode 100644 MediaBrowser.Controller/Connect/IConnectManager.cs delete mode 100644 MediaBrowser.Model/Connect/ConnectAuthenticationExchangeResult.cs delete mode 100644 MediaBrowser.Model/Connect/ConnectAuthenticationResult.cs delete mode 100644 MediaBrowser.Model/Connect/ConnectAuthorizationRequest.cs delete mode 100644 MediaBrowser.Model/Dto/ChapterInfoDto.cs delete mode 100644 MediaBrowser.Model/LiveTv/ProgramQuery.cs delete mode 100644 MediaBrowser.Model/LiveTv/RecommendedProgramQuery.cs delete mode 100644 MediaBrowser.Model/Notifications/NotificationServiceInfo.cs delete mode 100644 MediaBrowser.Model/Session/SessionInfoDto.cs (limited to 'MediaBrowser.Controller/MediaEncoding') diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs index ae3577b7d0..ed1fe87917 100644 --- a/Emby.Server.Implementations/Library/UserManager.cs +++ b/Emby.Server.Implementations/Library/UserManager.cs @@ -2,7 +2,6 @@ using MediaBrowser.Common.Net; using MediaBrowser.Controller; using MediaBrowser.Controller.Configuration; -using MediaBrowser.Controller.Connect; using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index 07b8185c5c..ed31cbd1d8 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -55,12 +55,11 @@ namespace MediaBrowser.Api return Request.Headers[name]; } - private static readonly string[] EmptyStringArray = Array.Empty(); public static string[] SplitValue(string value, char delim) { if (string.IsNullOrWhiteSpace(value)) { - return EmptyStringArray; + return Array.Empty(); } return value.Split(new[] { delim }, StringSplitOptions.RemoveEmptyEntries); diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.cs index 29f3070a59..913a55b2b3 100644 --- a/MediaBrowser.Api/UserService.cs +++ b/MediaBrowser.Api/UserService.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Extensions; +using MediaBrowser.Controller.Authentication; +using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Devices; @@ -10,11 +11,9 @@ using MediaBrowser.Model.Connect; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Users; using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using MediaBrowser.Model.Services; -using MediaBrowser.Controller.Authentication; namespace MediaBrowser.Api { diff --git a/MediaBrowser.Controller/Authentication/IAuthenticationProvider.cs b/MediaBrowser.Controller/Authentication/IAuthenticationProvider.cs index becb3ea627..82308296f1 100644 --- a/MediaBrowser.Controller/Authentication/IAuthenticationProvider.cs +++ b/MediaBrowser.Controller/Authentication/IAuthenticationProvider.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; -using System.Threading.Tasks; +using System.Threading.Tasks; using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Users; diff --git a/MediaBrowser.Controller/Chapters/IChapterManager.cs b/MediaBrowser.Controller/Chapters/IChapterManager.cs index 2a20eb365d..161e87094a 100644 --- a/MediaBrowser.Controller/Chapters/IChapterManager.cs +++ b/MediaBrowser.Controller/Chapters/IChapterManager.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Threading.Tasks; using MediaBrowser.Model.Entities; namespace MediaBrowser.Controller.Chapters @@ -9,12 +8,6 @@ namespace MediaBrowser.Controller.Chapters /// public interface IChapterManager { - /// - /// Gets the chapters. - /// - /// The item identifier. - /// List{ChapterInfo}. - /// /// Saves the chapters. /// diff --git a/MediaBrowser.Controller/Collections/CollectionCreationOptions.cs b/MediaBrowser.Controller/Collections/CollectionCreationOptions.cs index 727b487a79..5363e035c3 100644 --- a/MediaBrowser.Controller/Collections/CollectionCreationOptions.cs +++ b/MediaBrowser.Controller/Collections/CollectionCreationOptions.cs @@ -20,8 +20,8 @@ namespace MediaBrowser.Controller.Collections public CollectionCreationOptions() { ProviderIds = new Dictionary(StringComparer.OrdinalIgnoreCase); - ItemIdList = new string[] {}; - UserIds = new Guid[] {}; + ItemIdList = Array.Empty(); + UserIds = Array.Empty(); } } } diff --git a/MediaBrowser.Controller/Connect/IConnectManager.cs b/MediaBrowser.Controller/Connect/IConnectManager.cs deleted file mode 100644 index 8ac61bf2b1..0000000000 --- a/MediaBrowser.Controller/Connect/IConnectManager.cs +++ /dev/null @@ -1,45 +0,0 @@ -using MediaBrowser.Controller.Entities; -using MediaBrowser.Model.Connect; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace MediaBrowser.Controller.Connect -{ - public interface IConnectManager - { - /// - /// Gets the wan API address. - /// - /// The wan API address. - string WanApiAddress { get; } - - /// - /// Links the user. - /// - /// The user identifier. - /// The connect username. - /// Task. - Task LinkUser(string userId, string connectUsername); - - /// - /// Removes the link. - /// - /// The user identifier. - /// Task. - Task RemoveConnect(string userId); - - User GetUserFromExchangeToken(string token); - - /// - /// Authenticates the specified username. - /// - Task Authenticate(string username, string password, string passwordMd5); - - /// - /// Determines whether [is authorization token valid] [the specified token]. - /// - /// The token. - /// true if [is authorization token valid] [the specified token]; otherwise, false. - bool IsAuthorizationTokenValid(string token); - } -} diff --git a/MediaBrowser.Controller/Dto/IDtoService.cs b/MediaBrowser.Controller/Dto/IDtoService.cs index 219b367891..37e83e45a2 100644 --- a/MediaBrowser.Controller/Dto/IDtoService.cs +++ b/MediaBrowser.Controller/Dto/IDtoService.cs @@ -2,7 +2,6 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Querying; using System.Collections.Generic; -using MediaBrowser.Controller.Sync; namespace MediaBrowser.Controller.Dto { diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.cs index 4f4b3483cf..a4601c270d 100644 --- a/MediaBrowser.Controller/Entities/AggregateFolder.cs +++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs @@ -20,7 +20,7 @@ namespace MediaBrowser.Controller.Entities { public AggregateFolder() { - PhysicalLocationsList = new string[] { }; + PhysicalLocationsList = Array.Empty(); } [IgnoreDataMember] diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index d07e31d8a4..1aeae6052f 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -2,13 +2,8 @@ using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; -using MediaBrowser.Model.MediaInfo; using System; using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Threading; -using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Persistence; using MediaBrowser.Model.Serialization; @@ -36,8 +31,8 @@ namespace MediaBrowser.Controller.Entities.Audio public Audio() { - Artists = new string[] {}; - AlbumArtists = new string[] {}; + Artists = Array.Empty(); + AlbumArtists = Array.Empty(); } public override double GetDefaultPrimaryImageAspectRatio() diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs index 48b5c64b21..870e6e07e1 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs @@ -23,8 +23,8 @@ namespace MediaBrowser.Controller.Entities.Audio public MusicAlbum() { - Artists = new string[] {}; - AlbumArtists = new string[] {}; + Artists = Array.Empty(); + AlbumArtists = Array.Empty(); } [IgnoreDataMember] diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index 2774dc9443..56ed10ced6 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -129,13 +129,12 @@ namespace MediaBrowser.Controller.Entities.Audio return base.IsSaveLocalMetadataEnabled(); } - private readonly Task _cachedTask = Task.FromResult(true); protected override Task ValidateChildrenInternal(IProgress progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService) { if (IsAccessedByName) { // Should never get in here anyway - return _cachedTask; + return Task.CompletedTask; } return base.ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService); diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index e80fe33875..a268e6d765 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -35,24 +35,24 @@ namespace MediaBrowser.Controller.Entities /// public abstract class BaseItem : IHasProviderIds, IHasLookupInfo { - protected static MetadataFields[] EmptyMetadataFieldsArray = new MetadataFields[] { }; - protected static MediaUrl[] EmptyMediaUrlArray = new MediaUrl[] { }; - protected static ItemImageInfo[] EmptyItemImageInfoArray = new ItemImageInfo[] { }; - public static readonly LinkedChild[] EmptyLinkedChildArray = new LinkedChild[] { }; + protected static MetadataFields[] EmptyMetadataFieldsArray = Array.Empty(); + protected static MediaUrl[] EmptyMediaUrlArray = Array.Empty(); + protected static ItemImageInfo[] EmptyItemImageInfoArray = Array.Empty(); + public static readonly LinkedChild[] EmptyLinkedChildArray = Array.Empty(); protected BaseItem() { - ThemeSongIds = new Guid[] {}; - ThemeVideoIds = new Guid[] {}; - Tags = new string[] {}; - Genres = new string[] {}; - Studios = new string[] {}; + ThemeSongIds = Array.Empty(); + ThemeVideoIds = Array.Empty(); + Tags = Array.Empty(); + Genres = Array.Empty(); + Studios = Array.Empty(); ProviderIds = new Dictionary(StringComparer.OrdinalIgnoreCase); LockedFields = EmptyMetadataFieldsArray; ImageInfos = EmptyItemImageInfoArray; - ProductionLocations = new string[] {}; - RemoteTrailers = new MediaUrl[] { }; - ExtraIds = new Guid[] {}; + ProductionLocations = Array.Empty(); + RemoteTrailers = Array.Empty(); + ExtraIds = Array.Empty(); } public static readonly char[] SlugReplaceChars = { '?', '/', '&' }; @@ -62,7 +62,6 @@ namespace MediaBrowser.Controller.Entities /// The supported image extensions /// public static readonly string[] SupportedImageExtensions = { ".png", ".jpg", ".jpeg", ".tbn", ".gif" }; - public static readonly List SupportedImageExtensionsList = SupportedImageExtensions.ToList(); /// /// The trailer folder name @@ -2895,6 +2894,10 @@ namespace MediaBrowser.Controller.Entities return ThemeVideoIds.Select(LibraryManager.GetItemById).Where(i => i.ExtraType.Equals(Model.Entities.ExtraType.ThemeVideo)).OrderBy(i => i.SortName); } + /// + /// Gets or sets the remote trailers. + /// + /// The remote trailers. public MediaUrl[] RemoteTrailers { get; set; } public IEnumerable GetExtras() @@ -2913,21 +2916,24 @@ namespace MediaBrowser.Controller.Entities } public virtual bool IsHD { - get{ + get + { return Height >= 720; - } + } } public bool IsShortcut{ get; set;} public string ShortcutPath{ get; set;} public int Width { get; set; } public int Height { get; set; } public Guid[] ExtraIds { get; set; } - public virtual long GetRunTimeTicksForPlayState() { + public virtual long GetRunTimeTicksForPlayState() + { return RunTimeTicks ?? 0; } // what does this do? public static ExtraType[] DisplayExtraTypes = new[] {Model.Entities.ExtraType.ThemeSong, Model.Entities.ExtraType.ThemeVideo }; - public virtual bool SupportsExternalTransfer { + public virtual bool SupportsExternalTransfer + { get { return false; } diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index 7292b166a0..75d6b93818 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -31,18 +31,10 @@ namespace MediaBrowser.Controller.Entities public CollectionFolder() { - PhysicalLocationsList = new string[] { }; - PhysicalFolderIds = new Guid[] { }; + PhysicalLocationsList = Array.Empty(); + PhysicalFolderIds = Array.Empty(); } - //public override double? GetDefaultPrimaryImageAspectRatio() - //{ - // double value = 16; - // value /= 9; - - // return value; - //} - [IgnoreDataMember] public override bool SupportsPlayedStatus { @@ -339,7 +331,7 @@ namespace MediaBrowser.Controller.Entities /// Task. protected override Task ValidateChildrenInternal(IProgress progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService) { - return Task.FromResult(true); + return Task.CompletedTask; } /// diff --git a/MediaBrowser.Controller/Entities/Game.cs b/MediaBrowser.Controller/Entities/Game.cs index 3d006a699c..4efc5648ea 100644 --- a/MediaBrowser.Controller/Entities/Game.cs +++ b/MediaBrowser.Controller/Entities/Game.cs @@ -12,10 +12,10 @@ namespace MediaBrowser.Controller.Entities { public Game() { - MultiPartGameFiles = new string[] {}; + MultiPartGameFiles = Array.Empty(); RemoteTrailers = EmptyMediaUrlArray; - LocalTrailerIds = new Guid[] {}; - RemoteTrailerIds = new Guid[] {}; + LocalTrailerIds = Array.Empty(); + RemoteTrailerIds = Array.Empty(); } public Guid[] LocalTrailerIds { get; set; } @@ -38,12 +38,6 @@ namespace MediaBrowser.Controller.Entities get { return false; } } - /// - /// Gets or sets the remote trailers. - /// - /// The remote trailers. - public MediaUrl[] RemoteTrailers { get; set; } - /// /// Gets the type of the media. /// diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index ff57c24714..bb99c0a84e 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using MediaBrowser.Model.Configuration; using System.Linq; using MediaBrowser.Controller.Dto; -using MediaBrowser.Model.Querying; namespace MediaBrowser.Controller.Entities { @@ -48,7 +47,6 @@ namespace MediaBrowser.Controller.Entities public string PresentationUniqueKey { get; set; } public string Path { get; set; } - public string PathNotStartsWith { get; set; } public string Name { get; set; } public string Person { get; set; } @@ -160,8 +158,6 @@ namespace MediaBrowser.Controller.Entities public bool EnableGroupByMetadataKey { get; set; } public bool? HasChapterImages { get; set; } - // why tuple vs value tuple? - //public Tuple[] OrderBy { get; set; } public ValueTuple[] OrderBy { get; set; } public DateTime? MinDateCreated { get; set; } @@ -180,44 +176,44 @@ namespace MediaBrowser.Controller.Entities public InternalItemsQuery() { - AlbumArtistIds = new Guid[] {}; - AlbumIds = new Guid[] {}; - AncestorIds = new Guid[] {}; - ArtistIds = new Guid[] {}; - BlockUnratedItems = new UnratedItem[] { }; - BoxSetLibraryFolders = new Guid[] {}; - ChannelIds = new Guid[] {}; - ContributingArtistIds = new Guid[] {}; + AlbumArtistIds = Array.Empty(); + AlbumIds = Array.Empty(); + AncestorIds = Array.Empty(); + ArtistIds = Array.Empty(); + BlockUnratedItems = Array.Empty(); + BoxSetLibraryFolders = Array.Empty(); + ChannelIds = Array.Empty(); + ContributingArtistIds = Array.Empty(); DtoOptions = new DtoOptions(); EnableTotalRecordCount = true; - ExcludeArtistIds = new Guid[] {}; - ExcludeInheritedTags = new string[] {}; - ExcludeItemIds = new Guid[] {}; - ExcludeItemTypes = new string[] {}; + ExcludeArtistIds = Array.Empty(); + ExcludeInheritedTags = Array.Empty(); + ExcludeItemIds = Array.Empty(); + ExcludeItemTypes = Array.Empty(); ExcludeProviderIds = new Dictionary(StringComparer.OrdinalIgnoreCase); - ExcludeTags = new string[] {}; - GenreIds = new Guid[] {}; - Genres = new string[] {}; + ExcludeTags = Array.Empty(); + GenreIds = Array.Empty(); + Genres = Array.Empty(); GroupByPresentationUniqueKey = true; HasAnyProviderId = new Dictionary(StringComparer.OrdinalIgnoreCase); - ImageTypes = new ImageType[] { }; - IncludeItemTypes = new string[] {}; - ItemIds = new Guid[] {}; - MediaTypes = new string[] {}; + ImageTypes = Array.Empty(); + IncludeItemTypes = Array.Empty(); + ItemIds = Array.Empty(); + MediaTypes = Array.Empty(); MinSimilarityScore = 20; - OfficialRatings = new string[] {}; + OfficialRatings = Array.Empty(); OrderBy = Array.Empty>(); - PersonIds = new Guid[] {}; - PersonTypes = new string[] {}; - PresetViews = new string[] {}; - SeriesStatuses = new SeriesStatus[] { }; - SourceTypes = new SourceType[] { }; - StudioIds = new Guid[] {}; - Tags = new string[] {}; - TopParentIds = new Guid[] {}; - TrailerTypes = new TrailerType[] { }; - VideoTypes = new VideoType[] { }; - Years = new int[] { }; + PersonIds = Array.Empty(); + PersonTypes = Array.Empty(); + PresetViews = Array.Empty(); + SeriesStatuses = Array.Empty(); + SourceTypes = Array.Empty(); + StudioIds = Array.Empty(); + Tags = Array.Empty(); + TopParentIds = Array.Empty(); + TrailerTypes = Array.Empty(); + VideoTypes = Array.Empty(); + Years = Array.Empty(); } public InternalItemsQuery(User user) diff --git a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs index 7e00834e30..ce3e9e070e 100644 --- a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs @@ -14,8 +14,8 @@ namespace MediaBrowser.Controller.Entities public InternalPeopleQuery() { - PersonTypes = new string[] { }; - ExcludePersonTypes = new string[] { }; + PersonTypes = Array.Empty(); + ExcludePersonTypes = Array.Empty(); } } } diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index 5918bf9811..e888a55825 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -19,8 +19,8 @@ namespace MediaBrowser.Controller.Entities.Movies public BoxSet() { RemoteTrailers = EmptyMediaUrlArray; - LocalTrailerIds = new Guid[] { }; - RemoteTrailerIds = new Guid[] { }; + LocalTrailerIds = Array.Empty(); + RemoteTrailerIds = Array.Empty(); DisplayOrder = ItemSortBy.PremiereDate; } @@ -52,12 +52,6 @@ namespace MediaBrowser.Controller.Entities.Movies public Guid[] LocalTrailerIds { get; set; } public Guid[] RemoteTrailerIds { get; set; } - /// - /// Gets or sets the remote trailers. - /// - /// The remote trailers. - public MediaUrl[] RemoteTrailers { get; set; } - /// /// Gets or sets the display order. /// @@ -70,12 +64,7 @@ namespace MediaBrowser.Controller.Entities.Movies } public override double GetDefaultPrimaryImageAspectRatio() - { - double value = 2; - value /= 3; - - return value; - } + => 2 / 3; public override UnratedItem GetBlockUnratedType() { @@ -254,7 +243,7 @@ namespace MediaBrowser.Controller.Entities.Movies return FlattenItems(boxset.GetLinkedChildren(), expandedFolders); } - return new BaseItem[] { }; + return Array.Empty(); } return new[] { item }; diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs index 878b1b860f..4f743991bc 100644 --- a/MediaBrowser.Controller/Entities/Movies/Movie.cs +++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs @@ -6,8 +6,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; - -using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; using MediaBrowser.Model.Providers; using MediaBrowser.Model.Serialization; @@ -32,8 +30,6 @@ namespace MediaBrowser.Controller.Entities.Movies public Guid[] LocalTrailerIds { get; set; } public Guid[] RemoteTrailerIds { get; set; } - public MediaUrl[] RemoteTrailers { get; set; } - /// /// Gets or sets the name of the TMDB collection. /// @@ -55,10 +51,7 @@ namespace MediaBrowser.Controller.Entities.Movies return 0; } - double value = 2; - value /= 3; - - return value; + return 2 / 3; } protected override async Task RefreshedOwnedItems(MetadataRefreshOptions options, List fileSystemChildren, CancellationToken cancellationToken) diff --git a/MediaBrowser.Controller/Entities/MusicVideo.cs b/MediaBrowser.Controller/Entities/MusicVideo.cs index 78f9d06718..4015a11780 100644 --- a/MediaBrowser.Controller/Entities/MusicVideo.cs +++ b/MediaBrowser.Controller/Entities/MusicVideo.cs @@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Entities public MusicVideo() { - Artists = new string[] {}; + Artists = Array.Empty(); } [IgnoreDataMember] diff --git a/MediaBrowser.Controller/Entities/Photo.cs b/MediaBrowser.Controller/Entities/Photo.cs index 01c10831dc..662aa42495 100644 --- a/MediaBrowser.Controller/Entities/Photo.cs +++ b/MediaBrowser.Controller/Entities/Photo.cs @@ -58,6 +58,7 @@ namespace MediaBrowser.Controller.Entities public override double GetDefaultPrimaryImageAspectRatio() { + // REVIEW: @bond if (Width.HasValue && Height.HasValue) { double width = Width.Value; @@ -85,8 +86,8 @@ namespace MediaBrowser.Controller.Entities return base.GetDefaultPrimaryImageAspectRatio(); } - public int? Width { get; set; } - public int? Height { get; set; } + public new int? Width { get; set; } + public new int? Height { get; set; } public string CameraMake { get; set; } public string CameraModel { get; set; } public string Software { get; set; } diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs index 3a3a902a35..00e055c51a 100644 --- a/MediaBrowser.Controller/Entities/TV/Episode.cs +++ b/MediaBrowser.Controller/Entities/TV/Episode.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Controller.Providers; +using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; using System; @@ -19,13 +19,12 @@ namespace MediaBrowser.Controller.Entities.TV public Episode() { RemoteTrailers = EmptyMediaUrlArray; - LocalTrailerIds = new Guid[] {}; - RemoteTrailerIds = new Guid[] {}; + LocalTrailerIds = Array.Empty(); + RemoteTrailerIds = Array.Empty(); } public Guid[] LocalTrailerIds { get; set; } public Guid[] RemoteTrailerIds { get; set; } - public MediaUrl[] RemoteTrailers { get; set; } /// /// Gets the season in which it aired. @@ -112,10 +111,7 @@ namespace MediaBrowser.Controller.Entities.TV return 0; } - double value = 16; - value /= 9; - - return value; + return 16 / 9; } public override List GetUserDataKeys() diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index b5f77df55a..cb3a7f3458 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -102,10 +102,11 @@ namespace MediaBrowser.Controller.Entities.TV get { var seriesId = SeriesId; - if (seriesId.Equals(Guid.Empty)) { + if (seriesId == Guid.Empty) + { seriesId = FindSeriesId(); } - return !seriesId.Equals(Guid.Empty) ? (LibraryManager.GetItemById(seriesId) as Series) : null; + return seriesId == Guid.Empty ? null : (LibraryManager.GetItemById(seriesId) as Series); } } @@ -227,7 +228,7 @@ namespace MediaBrowser.Controller.Entities.TV public Guid FindSeriesId() { var series = FindParent(); - return series == null ? Guid.Empty: series.Id; + return series == null ? Guid.Empty : series.Id; } /// diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index 88fde17608..d4a62626ed 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -23,9 +23,9 @@ namespace MediaBrowser.Controller.Entities.TV public Series() { RemoteTrailers = EmptyMediaUrlArray; - LocalTrailerIds = new Guid[] {}; - RemoteTrailerIds = new Guid[] {}; - AirDays = new DayOfWeek[] { }; + LocalTrailerIds = Array.Empty(); + RemoteTrailerIds = Array.Empty(); + AirDays = Array.Empty(); } public DayOfWeek[] AirDays { get; set; } @@ -73,8 +73,6 @@ namespace MediaBrowser.Controller.Entities.TV public Guid[] LocalTrailerIds { get; set; } public Guid[] RemoteTrailerIds { get; set; } - public MediaUrl[] RemoteTrailers { get; set; } - /// /// airdate, dvd or absolute /// diff --git a/MediaBrowser.Controller/Entities/Trailer.cs b/MediaBrowser.Controller/Entities/Trailer.cs index 4f2a5631bf..2ef268ed18 100644 --- a/MediaBrowser.Controller/Entities/Trailer.cs +++ b/MediaBrowser.Controller/Entities/Trailer.cs @@ -15,18 +15,13 @@ namespace MediaBrowser.Controller.Entities { public Trailer() { - TrailerTypes = new TrailerType[] { }; + TrailerTypes = Array.Empty(); } public TrailerType[] TrailerTypes { get; set; } public override double GetDefaultPrimaryImageAspectRatio() - { - double value = 2; - value /= 3; - - return value; - } + => 2 / 3; public override UnratedItem GetBlockUnratedType() { diff --git a/MediaBrowser.Controller/Entities/UserView.cs b/MediaBrowser.Controller/Entities/UserView.cs index 984cad481e..b7c9884ff1 100644 --- a/MediaBrowser.Controller/Entities/UserView.cs +++ b/MediaBrowser.Controller/Entities/UserView.cs @@ -1,21 +1,18 @@ using MediaBrowser.Controller.Playlists; using MediaBrowser.Controller.TV; -using MediaBrowser.Model.Entities; using MediaBrowser.Model.Querying; using System; using System.Collections.Generic; using System.Linq; using MediaBrowser.Model.Serialization; using System.Threading.Tasks; -using MediaBrowser.Controller.Dto; -using MediaBrowser.Controller.Collections; namespace MediaBrowser.Controller.Entities { public class UserView : Folder, IHasCollectionType { public string ViewType { get; set; } - public Guid DisplayParentId { get; set; } + public new Guid DisplayParentId { get; set; } public Guid? UserId { get; set; } @@ -68,14 +65,6 @@ namespace MediaBrowser.Controller.Entities } } - //public override double? GetDefaultPrimaryImageAspectRatio() - //{ - // double value = 16; - // value /= 9; - - // return value; - //} - public override int GetChildCount(User user) { return GetChildren(user, true).Count; @@ -161,8 +150,8 @@ namespace MediaBrowser.Controller.Entities public static bool IsEligibleForGrouping(Folder folder) { - var collectionFolder = folder as ICollectionFolder; - return collectionFolder != null && IsEligibleForGrouping(collectionFolder.CollectionType); + return folder is ICollectionFolder collectionFolder + && IsEligibleForGrouping(collectionFolder.CollectionType); } private static string[] ViewTypesEligibleForGrouping = new string[] @@ -195,7 +184,7 @@ namespace MediaBrowser.Controller.Entities protected override Task ValidateChildrenInternal(IProgress progress, System.Threading.CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, Providers.MetadataRefreshOptions refreshOptions, Providers.IDirectoryService directoryService) { - return Task.FromResult(true); + return Task.CompletedTask; } [IgnoreDataMember] diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 65f5b8382d..2db200ee27 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -10,7 +10,6 @@ using System.Globalization; using System.Linq; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Common.Extensions; using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Extensions; @@ -132,8 +131,6 @@ namespace MediaBrowser.Controller.Entities public bool HasSubtitles { get; set; } public bool IsPlaceHolder { get; set; } - public bool IsShortcut { get; set; } - public string ShortcutPath { get; set; } /// /// Gets or sets the default index of the video stream. @@ -173,7 +170,7 @@ namespace MediaBrowser.Controller.Entities } else { - return new string[] {}; + return Array.Empty(); } return mediaEncoder.GetPlayableStreamFileNames(Path, videoType); } @@ -186,9 +183,9 @@ namespace MediaBrowser.Controller.Entities public Video() { - AdditionalParts = new string[] {}; - LocalAlternateVersions = new string[] {}; - SubtitleFiles = new string[] {}; + AdditionalParts = Array.Empty(); + LocalAlternateVersions = Array.Empty(); + SubtitleFiles = Array.Empty(); LinkedAlternateVersions = EmptyLinkedChildArray; } @@ -215,10 +212,10 @@ namespace MediaBrowser.Controller.Entities { if (!string.IsNullOrEmpty(PrimaryVersionId)) { - var item = LibraryManager.GetItemById(PrimaryVersionId) as Video; - if (item != null) + var item = LibraryManager.GetItemById(PrimaryVersionId); + if (item is Video video) { - return item.MediaSourceCount; + return video.MediaSourceCount; } } return LinkedAlternateVersions.Length + LocalAlternateVersions.Length + 1; @@ -366,7 +363,7 @@ namespace MediaBrowser.Controller.Entities /// Gets the additional parts. /// /// IEnumerable{Video}. - public IEnumerable