Skip to content

Commit

Permalink
Exclude Always from stderr
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mosteo committed Feb 16, 2023
1 parent bcd9d80 commit 2b62010
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/simple_logging.adb
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion src/simple_logging.ads
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2b62010

Please sign in to comment.