Browse Source

limit console log output on windows (#1212)

pull/1216/head
Jason Dove 2 years ago committed by GitHub
parent
commit
fdab54a055
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      CHANGELOG.md
  2. 24
      ErsatzTV.Application/MediaCollections/Commands/TraktCommandBase.cs
  3. 6
      ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs
  4. 2
      ErsatzTV.Infrastructure/Plex/PlexServerApiClient.cs
  5. 21
      ErsatzTV/Program.cs
  6. 1
      ErsatzTV/Services/WorkerService.cs
  7. 11
      ErsatzTV/appsettings.Development.json
  8. 11
      ErsatzTV/appsettings.json

3
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 - 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 - 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 - 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 ## [0.7.5-beta] - 2023-03-05
### Added ### Added

24
ErsatzTV.Application/MediaCollections/Commands/TraktCommandBase.cs

@ -208,7 +208,7 @@ public abstract class TraktCommandBase
foreach (int movieId in maybeMovieByGuid) 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; return movieId;
} }
@ -221,11 +221,11 @@ public abstract class TraktCommandBase
foreach (int movieId in maybeMovieByTitleYear) 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; return movieId;
} }
_logger.LogDebug("Unable to locate trakt movie {Title}", item.DisplayTitle); // _logger.LogDebug("Unable to locate trakt movie {Title}", item.DisplayTitle);
return None; return None;
} }
@ -243,7 +243,7 @@ public abstract class TraktCommandBase
foreach (int showId in maybeShowByGuid) 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; return showId;
} }
@ -256,11 +256,11 @@ public abstract class TraktCommandBase
foreach (int showId in maybeShowByTitleYear) 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; return showId;
} }
_logger.LogDebug("Unable to locate trakt show {Title}", item.DisplayTitle); // _logger.LogDebug("Unable to locate trakt show {Title}", item.DisplayTitle);
return None; return None;
} }
@ -278,7 +278,7 @@ public abstract class TraktCommandBase
foreach (int seasonId in maybeSeasonByGuid) 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; return seasonId;
} }
@ -292,11 +292,11 @@ public abstract class TraktCommandBase
foreach (int seasonId in maybeSeasonByTitleYear) 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; return seasonId;
} }
_logger.LogDebug("Unable to locate trakt season {Title}", item.DisplayTitle); // _logger.LogDebug("Unable to locate trakt season {Title}", item.DisplayTitle);
return None; return None;
} }
@ -314,7 +314,7 @@ public abstract class TraktCommandBase
foreach (int episodeId in maybeEpisodeByGuid) 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; return episodeId;
} }
@ -329,11 +329,11 @@ public abstract class TraktCommandBase
foreach (int episodeId in maybeEpisodeByTitleYear) 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; return episodeId;
} }
_logger.LogDebug("Unable to locate trakt episode {Title}", item.DisplayTitle); // _logger.LogDebug("Unable to locate trakt episode {Title}", item.DisplayTitle);
return None; return None;
} }

6
ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs

@ -149,8 +149,10 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService
videoPath == audioPath ? playbackSettings.AudioDuration : Option<TimeSpan>.None, videoPath == audioPath ? playbackSettings.AudioDuration : Option<TimeSpan>.None,
playbackSettings.NormalizeLoudness); playbackSettings.NormalizeLoudness);
// don't log generated images which are expected to have unknown format // don't log generated images, or hls direct, which are expected to have unknown format
ILogger<FFmpegLibraryProcessService> pixelFormatLogger = videoPath == audioPath ? _logger : null; bool isUnknownPixelFormatExpected =
videoPath != audioPath || channel.StreamingMode == StreamingMode.HttpLiveStreamingDirect;
ILogger<FFmpegLibraryProcessService> pixelFormatLogger = isUnknownPixelFormatExpected ? null : _logger;
IPixelFormat pixelFormat = await AvailablePixelFormats.ForPixelFormat(videoStream.PixelFormat, pixelFormatLogger) IPixelFormat pixelFormat = await AvailablePixelFormats.ForPixelFormat(videoStream.PixelFormat, pixelFormatLogger)
.IfNoneAsync( .IfNoneAsync(

2
ErsatzTV.Infrastructure/Plex/PlexServerApiClient.cs

@ -994,7 +994,7 @@ public class PlexServerApiClient : IPlexServerApiClient
if (guid.StartsWith("local://")) if (guid.StartsWith("local://"))
{ {
_logger.LogDebug("Ignoring local Plex guid: {Guid}", guid); // _logger.LogDebug("Ignoring local Plex guid: {Guid}", guid);
} }
else else
{ {

21
ErsatzTV/Program.cs

@ -1,8 +1,10 @@
using System.Runtime.InteropServices;
using Destructurama; using Destructurama;
using ErsatzTV.Core; using ErsatzTV.Core;
using Serilog; using Serilog;
using Serilog.Core; using Serilog.Core;
using Serilog.Events; using Serilog.Events;
using Serilog.Sinks.SystemConsole.Themes;
namespace ErsatzTV; namespace ErsatzTV;
@ -42,13 +44,26 @@ public class Program
{ {
LoggingLevelSwitch.MinimumLevel = LogEventLevel.Information; LoggingLevelSwitch.MinimumLevel = LogEventLevel.Information;
Log.Logger = new LoggerConfiguration() LoggerConfiguration loggerConfiguration = new LoggerConfiguration()
.ReadFrom.Configuration(Configuration) .ReadFrom.Configuration(Configuration)
.MinimumLevel.ControlledBy(LoggingLevelSwitch) .MinimumLevel.ControlledBy(LoggingLevelSwitch)
.Destructure.UsingAttributes() .Destructure.UsingAttributes()
.Enrich.FromLogContext() .Enrich.FromLogContext()
.WriteTo.File(FileSystemLayout.LogFilePath, rollingInterval: RollingInterval.Day) .WriteTo.File(FileSystemLayout.LogFilePath, rollingInterval: RollingInterval.Day);
.CreateLogger();
// 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 try
{ {

1
ErsatzTV/Services/WorkerService.cs

@ -59,7 +59,6 @@ public class WorkerService : BackgroundService
error.Value)); error.Value));
break; break;
case DeleteOrphanedArtwork deleteOrphanedArtwork: case DeleteOrphanedArtwork deleteOrphanedArtwork:
_logger.LogInformation("Deleting orphaned artwork from the database");
await mediator.Send(deleteOrphanedArtwork, cancellationToken); await mediator.Send(deleteOrphanedArtwork, cancellationToken);
break; break;
case AddTraktList addTraktList: case AddTraktList addTraktList:

11
ErsatzTV/appsettings.Development.json

@ -1,19 +1,8 @@
{ {
"Serilog": { "Serilog": {
"Using": [
"Serilog.Sinks.Console"
],
"MinimumLevel": { "MinimumLevel": {
"Default": "Debug" "Default": "Debug"
}, },
"WriteTo": [
{
"Name": "Console",
"Args": {
"theme": "Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme::Code, Serilog.Sinks.Console"
}
}
],
"Enrich": [ "Enrich": [
"FromLogContext", "FromLogContext",
"WithMachineName", "WithMachineName",

11
ErsatzTV/appsettings.json

@ -1,8 +1,5 @@
{ {
"Serilog": { "Serilog": {
"Using": [
"Serilog.Sinks.Console"
],
"MinimumLevel": { "MinimumLevel": {
"Default": "Information", "Default": "Information",
"Override": { "Override": {
@ -11,14 +8,6 @@
"System.Net.Http.HttpClient": "Warning" "System.Net.Http.HttpClient": "Warning"
} }
}, },
"WriteTo": [
{
"Name": "Console",
"Args": {
"theme": "Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme::Code, Serilog.Sinks.Console"
}
}
],
"Enrich": [ "Enrich": [
"FromLogContext", "FromLogContext",
"WithMachineName", "WithMachineName",

Loading…
Cancel
Save