From 86d794213a6de16ff2ed08c3ebb410533c099d56 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Tue, 19 Aug 2025 15:51:40 +0100 Subject: [PATCH] Save application and system information in the log file under all commands not just dump. --- Aaru.Core/Aaru.Core.csproj | 1 - Aaru.Core/Logging/DumpLog.cs | 37 ------------------------ Aaru.Localization/Core.Designer.cs | 6 ++++ Aaru.Localization/Core.resx | 3 ++ Aaru.Localization/UI.Designer.cs | 6 ++++ Aaru.Localization/UI.resx | 3 ++ Aaru/LoggingInterceptor.cs | 45 ++++++++++++++++++++++++++++-- Aaru/Main.cs | 6 ---- 8 files changed, 61 insertions(+), 46 deletions(-) diff --git a/Aaru.Core/Aaru.Core.csproj b/Aaru.Core/Aaru.Core.csproj index bddb7de1a..47ee2d8ad 100644 --- a/Aaru.Core/Aaru.Core.csproj +++ b/Aaru.Core/Aaru.Core.csproj @@ -49,7 +49,6 @@ - diff --git a/Aaru.Core/Logging/DumpLog.cs b/Aaru.Core/Logging/DumpLog.cs index fa3f29e2d..cad270f71 100644 --- a/Aaru.Core/Logging/DumpLog.cs +++ b/Aaru.Core/Logging/DumpLog.cs @@ -32,13 +32,9 @@ using System; using System.IO; -using System.Reflection; -using System.Runtime.InteropServices; using Aaru.CommonTypes.Interop; using Aaru.Devices; using Aaru.Logging; -using PlatformID = Aaru.CommonTypes.Interop.PlatformID; -using Version = Aaru.CommonTypes.Interop.Version; namespace Aaru.Core.Logging; @@ -50,39 +46,6 @@ public static class DumpLog /// Disable saving paths or serial numbers in log public static void StartLog(Device dev, bool @private) { - AaruLogging.Information(Localization.Core.Start_logging_at_0, DateTime.Now); - - PlatformID platId = DetectOS.GetRealPlatformID(); - string platVer = DetectOS.GetVersion(); - - var assemblyVersion = - Attribute.GetCustomAttribute(typeof(DumpLog).Assembly, typeof(AssemblyInformationalVersionAttribute)) as - AssemblyInformationalVersionAttribute; - - AaruLogging.Information(Localization.Core.System_information); - - AaruLogging.Information("{0} {1} ({2}-bit)", - DetectOS.GetPlatformName(platId, platVer), - platVer, - Environment.Is64BitOperatingSystem ? 64 : 32); - - if(DetectOS.IsMono) - AaruLogging.Information("Mono {0}", Version.GetMonoVersion()); - else if(DetectOS.IsNetCore) - AaruLogging.Information(".NET Core {0}", Version.GetNetCoreVersion()); - else - AaruLogging.Information(RuntimeInformation.FrameworkDescription); - - AaruLogging.Information(Localization.Core.Program_information); - AaruLogging.Information("Aaru {0}", assemblyVersion?.InformationalVersion); - AaruLogging.Information(Localization.Core.Running_in_0_bit, Environment.Is64BitProcess ? 64 : 32); - - AaruLogging.Information(DetectOS.IsAdmin - ? Localization.Core.Running_as_superuser_Yes - : Localization.Core.Running_as_superuser_No); -#if DEBUG - AaruLogging.Information(Localization.Core.DEBUG_version); -#endif if(@private) { string[] args = Environment.GetCommandLineArgs(); diff --git a/Aaru.Localization/Core.Designer.cs b/Aaru.Localization/Core.Designer.cs index 8a8086257..821e2340e 100644 --- a/Aaru.Localization/Core.Designer.cs +++ b/Aaru.Localization/Core.Designer.cs @@ -6868,5 +6868,11 @@ namespace Aaru.Localization { return ResourceManager.GetString("Blu_ray_type_BDR_setting_disc_type_BDR", resourceCulture); } } + + public static string Running_in_0_architecture { + get { + return ResourceManager.GetString("Running_in_0_architecture", resourceCulture); + } + } } } diff --git a/Aaru.Localization/Core.resx b/Aaru.Localization/Core.resx index 3d23ec445..97593c71d 100644 --- a/Aaru.Localization/Core.resx +++ b/Aaru.Localization/Core.resx @@ -3505,4 +3505,7 @@ It has no sense to do it, and it will put too much strain on the tape. Blu-ray type set to "BDR", setting disc type to BD-R. + + Running in {0} architecture + \ No newline at end of file diff --git a/Aaru.Localization/UI.Designer.cs b/Aaru.Localization/UI.Designer.cs index 6aabf91b2..9b1b1960b 100644 --- a/Aaru.Localization/UI.Designer.cs +++ b/Aaru.Localization/UI.Designer.cs @@ -6105,5 +6105,11 @@ namespace Aaru.Localization { return ResourceManager.GetString("Unable_to_get_separate_tracks_not_checksumming_them", resourceCulture); } } + + public static string Running_in_0_architecture { + get { + return ResourceManager.GetString("Running_in_0_architecture", resourceCulture); + } + } } } diff --git a/Aaru.Localization/UI.resx b/Aaru.Localization/UI.resx index 624b4f130..7d6d540f9 100644 --- a/Aaru.Localization/UI.resx +++ b/Aaru.Localization/UI.resx @@ -3129,4 +3129,7 @@ Do you want to continue? [yellow]Unable to get separate tracks, not checksumming them[/] + + Running in {0} architecture + \ No newline at end of file diff --git a/Aaru/LoggingInterceptor.cs b/Aaru/LoggingInterceptor.cs index f0efa01cc..4cded98e0 100644 --- a/Aaru/LoggingInterceptor.cs +++ b/Aaru/LoggingInterceptor.cs @@ -1,10 +1,16 @@ +using System; +using System.Reflection; +using System.Runtime.InteropServices; using Aaru.Commands; +using Aaru.CommonTypes.Interop; +using Aaru.Localization; using Serilog; using Serilog.Core; using Serilog.Events; using Serilog.Sinks.Spectre; using Spectre.Console; using Spectre.Console.Cli; +using PlatformID = Aaru.CommonTypes.Interop.PlatformID; public class LoggingInterceptor : ICommandInterceptor { @@ -47,8 +53,43 @@ public class LoggingInterceptor : ICommandInterceptor } Log.Logger = loggerConfig.CreateLogger(); - Log.Information("Log level set to {Level}", _levelSwitch.MinimumLevel); - if(global.LogFile != null) Log.Information("Logging to file: {Path}", global.LogFile); + + if(global.LogFile == null) return; + + Log.Information(Core.Start_logging_at_0, DateTime.Now); + + PlatformID platId = DetectOS.GetRealPlatformID(); + string platVer = DetectOS.GetVersion(); + + var assemblyVersion = + Attribute.GetCustomAttribute(typeof(LoggingInterceptor).Assembly, + typeof(AssemblyInformationalVersionAttribute)) as + AssemblyInformationalVersionAttribute; + + Log.Information(Core.Program_information); + Log.Information("Aaru Data Preservation Suite {InformationalVersion}", assemblyVersion?.InformationalVersion); + Log.Information(Core.Running_in_0_architecture, RuntimeInformation.ProcessArchitecture); + Log.Information(Core.Running_in_0_bit, Environment.Is64BitProcess ? 64 : 32); + + Log.Information(DetectOS.IsAdmin ? Core.Running_as_superuser_Yes : Core.Running_as_superuser_No); +#if DEBUG + Log.Information(Core.DEBUG_version); +#endif + Log.Information(Core.Log_section_separator); + Log.Information(""); + + Log.Information(Core.System_information); + + Log.Information("{PlatformName} {PlatformVersion} ({ProcessorArchitecture} {Bittage}-bit)", + DetectOS.GetPlatformName(platId, platVer), + platVer, + RuntimeInformation.OSArchitecture, + Environment.Is64BitOperatingSystem ? 64 : 32); + + Log.Information(RuntimeInformation.FrameworkDescription); + Log.Information(Core.Log_section_separator); + + Log.Information(""); } #endregion diff --git a/Aaru/Main.cs b/Aaru/Main.cs index e592ee929..a6e715276 100644 --- a/Aaru/Main.cs +++ b/Aaru/Main.cs @@ -424,11 +424,5 @@ class MainClass AnsiConsole.MarkupLine("[bold][blue]{0}[/][/]", _assemblyCopyright); AnsiConsole.WriteLine(); - - AaruLogging.Information("Aaru Data Preservation Suite {InformationalVersion}", - _assemblyVersion?.InformationalVersion); - - AaruLogging.Information("{AssemblyCopyright}", _assemblyCopyright); - AaruLogging.Information("Logging started"); } } \ No newline at end of file