From 7bc2514fd9713638de11a36682b73c679a5fa7ab Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Mon, 20 Feb 2023 11:37:53 +0100 Subject: [PATCH] Write Warn/Error traces to stderr by default (#1327) * Write Warn/Error traces to stderr by default * Update simple_logging pin --- alire.toml | 2 +- deps/simple_logging | 2 +- src/alire/alire.adb | 13 ++++++++----- src/alire/alire.ads | 2 +- src/alire/alire_early_elaboration.adb | 3 +++ 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/alire.toml b/alire.toml index be1d5447..8d381337 100644 --- a/alire.toml +++ b/alire.toml @@ -50,5 +50,5 @@ ada_toml = { url = "https://github.com/mosteo/ada-toml", commit = "da4e59c382ceb clic = { url = "https://github.com/alire-project/clic", commit = "102bc38c7e9469112145e12100449664b5c74764" } gnatcoll = { url = "https://github.com/alire-project/gnatcoll-core.git", commit = "92bb91130a9ec628b4c48b7ef9fe7f24d9dc25fa" } semantic_versioning = { url = "https://github.com/alire-project/semantic_versioning", commit = "c2345fca8b685d6d3fc9334fac81140a0cdbea89" } -simple_logging = { url = "https://github.com/alire-project/simple_logging", commit = "703b15ba6e2392951b65a484ce703209750dd0fc" } +simple_logging = { url = "https://github.com/alire-project/simple_logging", commit = "2b62010b6d66c106c65eb9ae604aabcf64522fac" } stopwatch = { url = "https://github.com/mosteo/stopwatch", commit = "f607a63b714f09bbf6126de9851cbc21cf8666c9" } diff --git a/deps/simple_logging b/deps/simple_logging index 703b15ba..2b62010b 160000 --- a/deps/simple_logging +++ b/deps/simple_logging @@ -1 +1 @@ -Subproject commit 703b15ba6e2392951b65a484ce703209750dd0fc +Subproject commit 2b62010b6d66c106c65eb9ae604aabcf64522fac diff --git a/src/alire/alire.adb b/src/alire/alire.adb index f8c332d4..240f7b71 100644 --- a/src/alire/alire.adb +++ b/src/alire/alire.adb @@ -115,15 +115,18 @@ package body Alire is ----------------- procedure Put_Warning (Text : String; - Level : Trace.Levels := Info; + Level : Trace.Levels := Warning; Disable_Config : String := "") is + Prefix : constant String := + (if Level = Warning + then "" -- because the logging will add its own "Warning:" + else TTY.Text_With_Fallback (TTY.Warn (U ("⚠ ")), + "Warning: ")); begin - Trace.Log (TTY.Text_With_Fallback (TTY.Warn (U ("⚠ ")), "warning: ") - & Text, - Level); + Trace.Log (Prefix & Text, Level); if Disable_Config /= "" then - Trace.Log (TTY.Text_With_Fallback (TTY.Warn (U ("⚠ ")), "warning: ") + Trace.Log (Prefix & "You can disable this warning with configuration key '" & TTY.Emph (Disable_Config) & "'", Level); diff --git a/src/alire/alire.ads b/src/alire/alire.ads index b41bd75e..4d09bef6 100644 --- a/src/alire/alire.ads +++ b/src/alire/alire.ads @@ -269,7 +269,7 @@ package Alire with Preelaborate is -- Prepend Text with a blue "🛈", or "Note: " & if no color/tty. procedure Put_Warning (Text : String; - Level : Trace.Levels := Info; + Level : Trace.Levels := Warning; Disable_Config : String := ""); -- Prepend Text with a yellow "⚠", or "Warning: " if no color/tty. If -- Disable_setting /= "", append a line informing about how to disable diff --git a/src/alire/alire_early_elaboration.adb b/src/alire/alire_early_elaboration.adb index 5eee5464..7755c0f3 100644 --- a/src/alire/alire_early_elaboration.adb +++ b/src/alire/alire_early_elaboration.adb @@ -160,6 +160,9 @@ package body Alire_Early_Elaboration is end TTY_Detection; begin + Simple_Logging.Stdout_Level := Simple_Logging.Info; + -- Display warnings and errors to stderr + TTY_Detection; Early_Switch_Detection; end Alire_Early_Elaboration; -- 2.39.5