diff --git a/CHANGELOG.md b/CHANGELOG.md index 34fe56ab..5a8a1fb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Emby collection scanning will no longer happen after every (automatic or forced) library scan - Automatic/periodic scans will check collections one time after all libraries have been scanned - There is a new table in the `Media` > `Libraries` page with a button to manually re-scan Emby collections as needed +- For performance reasons, limit console log output to errors on Windows + - Other platforms are unchanged + - Log file behavior is unchanged ## [0.7.5-beta] - 2023-03-05 ### Added diff --git a/ErsatzTV.Application/MediaCollections/Commands/TraktCommandBase.cs b/ErsatzTV.Application/MediaCollections/Commands/TraktCommandBase.cs index 6ed15b3d..ed309621 100644 --- a/ErsatzTV.Application/MediaCollections/Commands/TraktCommandBase.cs +++ b/ErsatzTV.Application/MediaCollections/Commands/TraktCommandBase.cs @@ -208,7 +208,7 @@ public abstract class TraktCommandBase foreach (int movieId in maybeMovieByGuid) { - _logger.LogDebug("Located trakt movie {Title} by id", item.DisplayTitle); + // _logger.LogDebug("Located trakt movie {Title} by id", item.DisplayTitle); return movieId; } @@ -221,11 +221,11 @@ public abstract class TraktCommandBase foreach (int movieId in maybeMovieByTitleYear) { - _logger.LogDebug("Located trakt movie {Title} by title/year", item.DisplayTitle); + // _logger.LogDebug("Located trakt movie {Title} by title/year", item.DisplayTitle); return movieId; } - _logger.LogDebug("Unable to locate trakt movie {Title}", item.DisplayTitle); + // _logger.LogDebug("Unable to locate trakt movie {Title}", item.DisplayTitle); return None; } @@ -243,7 +243,7 @@ public abstract class TraktCommandBase foreach (int showId in maybeShowByGuid) { - _logger.LogDebug("Located trakt show {Title} by id", item.DisplayTitle); + // _logger.LogDebug("Located trakt show {Title} by id", item.DisplayTitle); return showId; } @@ -256,11 +256,11 @@ public abstract class TraktCommandBase foreach (int showId in maybeShowByTitleYear) { - _logger.LogDebug("Located trakt show {Title} by title/year", item.Title); + // _logger.LogDebug("Located trakt show {Title} by title/year", item.Title); return showId; } - _logger.LogDebug("Unable to locate trakt show {Title}", item.DisplayTitle); + // _logger.LogDebug("Unable to locate trakt show {Title}", item.DisplayTitle); return None; } @@ -278,7 +278,7 @@ public abstract class TraktCommandBase foreach (int seasonId in maybeSeasonByGuid) { - _logger.LogDebug("Located trakt season {Title} by id", item.DisplayTitle); + // _logger.LogDebug("Located trakt season {Title} by id", item.DisplayTitle); return seasonId; } @@ -292,11 +292,11 @@ public abstract class TraktCommandBase foreach (int seasonId in maybeSeasonByTitleYear) { - _logger.LogDebug("Located trakt season {Title} by title/year/season", item.DisplayTitle); + // _logger.LogDebug("Located trakt season {Title} by title/year/season", item.DisplayTitle); return seasonId; } - _logger.LogDebug("Unable to locate trakt season {Title}", item.DisplayTitle); + // _logger.LogDebug("Unable to locate trakt season {Title}", item.DisplayTitle); return None; } @@ -314,7 +314,7 @@ public abstract class TraktCommandBase foreach (int episodeId in maybeEpisodeByGuid) { - _logger.LogDebug("Located trakt episode {Title} by id", item.DisplayTitle); + // _logger.LogDebug("Located trakt episode {Title} by id", item.DisplayTitle); return episodeId; } @@ -329,11 +329,11 @@ public abstract class TraktCommandBase foreach (int episodeId in maybeEpisodeByTitleYear) { - _logger.LogDebug("Located trakt episode {Title} by title/year/season/episode", item.DisplayTitle); + // _logger.LogDebug("Located trakt episode {Title} by title/year/season/episode", item.DisplayTitle); return episodeId; } - _logger.LogDebug("Unable to locate trakt episode {Title}", item.DisplayTitle); + // _logger.LogDebug("Unable to locate trakt episode {Title}", item.DisplayTitle); return None; } diff --git a/ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs b/ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs index c8ae253a..8675df3b 100644 --- a/ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs +++ b/ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs @@ -149,8 +149,10 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService videoPath == audioPath ? playbackSettings.AudioDuration : Option.None, playbackSettings.NormalizeLoudness); - // don't log generated images which are expected to have unknown format - ILogger pixelFormatLogger = videoPath == audioPath ? _logger : null; + // don't log generated images, or hls direct, which are expected to have unknown format + bool isUnknownPixelFormatExpected = + videoPath != audioPath || channel.StreamingMode == StreamingMode.HttpLiveStreamingDirect; + ILogger pixelFormatLogger = isUnknownPixelFormatExpected ? null : _logger; IPixelFormat pixelFormat = await AvailablePixelFormats.ForPixelFormat(videoStream.PixelFormat, pixelFormatLogger) .IfNoneAsync( diff --git a/ErsatzTV.Infrastructure/Plex/PlexServerApiClient.cs b/ErsatzTV.Infrastructure/Plex/PlexServerApiClient.cs index a2f888a4..5b2cd72a 100644 --- a/ErsatzTV.Infrastructure/Plex/PlexServerApiClient.cs +++ b/ErsatzTV.Infrastructure/Plex/PlexServerApiClient.cs @@ -994,7 +994,7 @@ public class PlexServerApiClient : IPlexServerApiClient if (guid.StartsWith("local://")) { - _logger.LogDebug("Ignoring local Plex guid: {Guid}", guid); + // _logger.LogDebug("Ignoring local Plex guid: {Guid}", guid); } else { diff --git a/ErsatzTV/Program.cs b/ErsatzTV/Program.cs index 8937b0bb..b5948e00 100644 --- a/ErsatzTV/Program.cs +++ b/ErsatzTV/Program.cs @@ -1,8 +1,10 @@ +using System.Runtime.InteropServices; using Destructurama; using ErsatzTV.Core; using Serilog; using Serilog.Core; using Serilog.Events; +using Serilog.Sinks.SystemConsole.Themes; namespace ErsatzTV; @@ -42,13 +44,26 @@ public class Program { LoggingLevelSwitch.MinimumLevel = LogEventLevel.Information; - Log.Logger = new LoggerConfiguration() + LoggerConfiguration loggerConfiguration = new LoggerConfiguration() .ReadFrom.Configuration(Configuration) .MinimumLevel.ControlledBy(LoggingLevelSwitch) .Destructure.UsingAttributes() .Enrich.FromLogContext() - .WriteTo.File(FileSystemLayout.LogFilePath, rollingInterval: RollingInterval.Day) - .CreateLogger(); + .WriteTo.File(FileSystemLayout.LogFilePath, rollingInterval: RollingInterval.Day); + + // for performance reasons, restrict windows console to error logs + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + loggerConfiguration = loggerConfiguration.WriteTo.Console( + restrictedToMinimumLevel: LogEventLevel.Error, + theme: AnsiConsoleTheme.Code); + } + else + { + loggerConfiguration = loggerConfiguration.WriteTo.Console(theme: AnsiConsoleTheme.Code); + } + + Log.Logger = loggerConfiguration.CreateLogger(); try { diff --git a/ErsatzTV/Services/WorkerService.cs b/ErsatzTV/Services/WorkerService.cs index b72509b6..8fe13355 100644 --- a/ErsatzTV/Services/WorkerService.cs +++ b/ErsatzTV/Services/WorkerService.cs @@ -59,7 +59,6 @@ public class WorkerService : BackgroundService error.Value)); break; case DeleteOrphanedArtwork deleteOrphanedArtwork: - _logger.LogInformation("Deleting orphaned artwork from the database"); await mediator.Send(deleteOrphanedArtwork, cancellationToken); break; case AddTraktList addTraktList: diff --git a/ErsatzTV/appsettings.Development.json b/ErsatzTV/appsettings.Development.json index bdb741b4..e4a46308 100644 --- a/ErsatzTV/appsettings.Development.json +++ b/ErsatzTV/appsettings.Development.json @@ -1,19 +1,8 @@ { "Serilog": { - "Using": [ - "Serilog.Sinks.Console" - ], "MinimumLevel": { "Default": "Debug" }, - "WriteTo": [ - { - "Name": "Console", - "Args": { - "theme": "Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme::Code, Serilog.Sinks.Console" - } - } - ], "Enrich": [ "FromLogContext", "WithMachineName", diff --git a/ErsatzTV/appsettings.json b/ErsatzTV/appsettings.json index 051d7c12..596eddba 100644 --- a/ErsatzTV/appsettings.json +++ b/ErsatzTV/appsettings.json @@ -1,8 +1,5 @@ { "Serilog": { - "Using": [ - "Serilog.Sinks.Console" - ], "MinimumLevel": { "Default": "Information", "Override": { @@ -11,14 +8,6 @@ "System.Net.Http.HttpClient": "Warning" } }, - "WriteTo": [ - { - "Name": "Console", - "Args": { - "theme": "Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme::Code, Serilog.Sinks.Console" - } - } - ], "Enrich": [ "FromLogContext", "WithMachineName",