From 2b62010b6d66c106c65eb9ae604aabcf64522fac Mon Sep 17 00:00:00 2001 From: "Alejandro R. Mosteo" Date: Thu, 16 Feb 2023 12:08:33 +0100 Subject: [PATCH] Exclude Always from stderr We are using Always not for errors, but for output we don't want the user to be able to mute. So it makes some sense to still output it to stdout. --- src/simple_logging.adb | 4 +++- src/simple_logging.ads | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/simple_logging.adb b/src/simple_logging.adb index 78f75c9..b4f7ad5 100644 --- a/src/simple_logging.adb +++ b/src/simple_logging.adb @@ -36,7 +36,9 @@ package body Simple_Logging is (Level, Message)); begin - if Level < Stdout_Level then + if Level < Stdout_Level and then + (Level /= Always or else Treat_Always_As_Error) + then GNAT.IO.Put_Line (GNAT.IO.Standard_Error, Line); else GNAT.IO.Put_Line (GNAT.IO.Standard_Output, Line); diff --git a/src/simple_logging.ads b/src/simple_logging.ads index 02f7358..80ff47c 100644 --- a/src/simple_logging.ads +++ b/src/simple_logging.ads @@ -42,7 +42,11 @@ package Simple_Logging with Preelaborate is -- busy status spinner). Stdout_Level : Levels := Always; - -- Any level < Stdout_Level will be output to stderr + -- Any level < Stdout_Level will be output to stderr, except for Always + -- (see below). + + Treat_Always_As_Error : Boolean := False; + -- When True, Stdout_Level also applies to the Always level procedure Log (Message : String; Level : Levels := Info;