From 8c344b2917d48c60609971ec72f54c8d4d5fa61e Mon Sep 17 00:00:00 2001 From: Diego Heras Date: Sun, 23 Feb 2020 21:38:59 +0100 Subject: [PATCH] core: reduce log traces in info level. add start/stop log traces (#7305) --- .../Services/IndexerManagerService.cs | 4 ++-- src/Jackett.Server/Startup.cs | 16 ++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Jackett.Common/Services/IndexerManagerService.cs b/src/Jackett.Common/Services/IndexerManagerService.cs index 5eb5790bf..dad891b57 100644 --- a/src/Jackett.Common/Services/IndexerManagerService.cs +++ b/src/Jackett.Common/Services/IndexerManagerService.cs @@ -104,8 +104,7 @@ namespace Jackett.Common.Services var files = existingDirectories.SelectMany(d => d.GetFiles("*.yml")); var definitions = files.Select(file => { - logger.Info("Loading Cardigann definition " + file.FullName); - + logger.Debug("Loading Cardigann definition " + file.FullName); try { var DefinitionString = File.ReadAllText(file.FullName); @@ -147,6 +146,7 @@ namespace Jackett.Common.Services indexers.Add(indexer.ID, indexer); } + logger.Info("Cardigann definitions loaded: " + string.Join(", ", indexers.Keys)); } catch (Exception ex) { diff --git a/src/Jackett.Server/Startup.cs b/src/Jackett.Server/Startup.cs index 9906bd339..57ac1773f 100644 --- a/src/Jackett.Server/Startup.cs +++ b/src/Jackett.Server/Startup.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.IO; using System.Text; using Autofac; @@ -115,7 +116,8 @@ namespace Jackett.Server #if NET461 public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime applicationLifetime) { - applicationLifetime.ApplicationStopping.Register(OnShutdown); + applicationLifetime.ApplicationStarted.Register(OnStarted); + applicationLifetime.ApplicationStopped.Register(OnStopped); Helper.applicationLifetime = applicationLifetime; app.UseResponseCompression(); @@ -154,7 +156,8 @@ namespace Jackett.Server #else public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime applicationLifetime) { - applicationLifetime.ApplicationStopping.Register(OnShutdown); + applicationLifetime.ApplicationStarted.Register(OnStarted); + applicationLifetime.ApplicationStopped.Register(OnStopped); Helper.applicationLifetime = applicationLifetime; app.UseResponseCompression(); @@ -197,11 +200,12 @@ namespace Jackett.Server } #endif - - - private void OnShutdown() + private static void OnStarted() { - //this code is called when the application stops + var elapsed = (DateTime.Now - Process.GetCurrentProcess().StartTime).TotalSeconds; + Helper.Logger.Info($"Jackett startup finished in {elapsed:0.000} s"); } + + private static void OnStopped() => Helper.Logger.Info($"Jackett stopped"); } }