Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH v3 20/21] Style filenames in cli-logging.c
Date: Fri, 30 Jan 2026 06:17:34 -0700	[thread overview]
Message-ID: <20260130-pr-28948-logging-5-v3-20-3eec47ef3cba@tromey.com> (raw)
In-Reply-To: <20260130-pr-28948-logging-5-v3-0-3eec47ef3cba@tromey.com>

Andrew pointed out that some code in cli-logging.c should use the
filename style.  This patch fixes these spots.
---
 gdb/cli/cli-logging.c            | 37 +++++++++++++++++++++++--------------
 gdb/testsuite/gdb.base/style.exp | 20 ++++++++++++++++++++
 2 files changed, 43 insertions(+), 14 deletions(-)

diff --git a/gdb/cli/cli-logging.c b/gdb/cli/cli-logging.c
index 836c24445bc..38c16fbf18f 100644
--- a/gdb/cli/cli-logging.c
+++ b/gdb/cli/cli-logging.c
@@ -30,8 +30,10 @@ static void
 maybe_warn_already_logging ()
 {
   if (!saved_filename.empty ())
-    warning (_("Currently logging to %s.  Turn the logging off and on to "
-	       "make the new setting effective."), saved_filename.c_str ());
+    warning (_("Currently logging to %ps.  Turn the logging off and on to "
+	       "make the new setting effective."),
+	     styled_string (file_name_style.style (),
+			    saved_filename.c_str ()));
 }
 
 static std::string logging_filename = "gdb.txt";
@@ -227,8 +229,9 @@ handle_redirections (int from_tty)
 {
   if (!saved_filename.empty ())
     {
-      gdb_printf ("Already logging to %s.\n",
-		  saved_filename.c_str ());
+      gdb_printf ("Already logging to %ps.\n",
+		  styled_string (file_name_style.style (),
+				 saved_filename.c_str ()));
       return;
     }
 
@@ -240,18 +243,22 @@ handle_redirections (int from_tty)
   if (from_tty)
     {
       if (!logging_redirect)
-	gdb_printf ("Copying output to %s.\n",
-		    logging_filename.c_str ());
+	gdb_printf ("Copying output to %ps.\n",
+		    styled_string (file_name_style.style (),
+				   logging_filename.c_str ()));
       else
-	gdb_printf ("Redirecting output to %s.\n",
-		    logging_filename.c_str ());
+	gdb_printf ("Redirecting output to %ps.\n",
+		    styled_string (file_name_style.style (),
+				   logging_filename.c_str ()));
 
       if (!debug_redirect)
-	gdb_printf ("Copying debug output to %s.\n",
-		    logging_filename.c_str ());
+	gdb_printf ("Copying debug output to %ps.\n",
+		    styled_string (file_name_style.style (),
+				   logging_filename.c_str ()));
       else
-	gdb_printf ("Redirecting debug output to %s.\n",
-		    logging_filename.c_str ());
+	gdb_printf ("Redirecting debug output to %ps.\n",
+		    styled_string (file_name_style.style (),
+				   logging_filename.c_str ()));
     }
 
   saved_filename = logging_filename;
@@ -279,8 +286,10 @@ set_logging_off (const char *args, int from_tty)
 
   log_file.reset ();
   if (from_tty)
-    gdb_printf ("Done logging to %s.\n",
-		saved_filename.c_str ());
+    gdb_printf ("Done logging to %ps.\n",
+		styled_string (file_name_style.style (),
+			       saved_filename.c_str ()));
+
   saved_filename.clear ();
 }
 
diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp
index 23d50f4cfad..5c07541b18b 100644
--- a/gdb/testsuite/gdb.base/style.exp
+++ b/gdb/testsuite/gdb.base/style.exp
@@ -1047,6 +1047,25 @@ proc test_finish_styling {} {
     gdb_test "finish" "Value returned is [style \\\$$::decimal variable] = 0"
 }
 
+# Test some logging styling.
+proc test_logging_styling {} {
+    with_ansi_styling_terminal {
+	clean_restart
+    }
+
+    set filename [standard_output_file logging.txt]
+    gdb_test_no_output "set logging file $filename" \
+	"set logging file"
+    gdb_test "set logging enabled on" \
+	[multi_line \
+	     "Copying output to [style $filename file]\\." \
+	     "Copying debug output to [style $filename file]\\."] \
+	"logging filenames are styled"
+    gdb_test "set logging enabled off" \
+	"Done logging to [style $filename file]\\." \
+	"filename styled when logging disabled"
+}
+
 # Check to see if the Python styling of disassembler output is
 # expected or not, this styling requires Python support in GDB, and
 # the Python pygments module to be available.
@@ -1093,3 +1112,4 @@ test_pagination_cmd_after_quit_styling
 test_pagination_prompt_styling
 test_pagination_continue_styling
 test_finish_styling
+test_logging_styling

-- 
2.49.0


  parent reply	other threads:[~2026-01-30 13:23 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-30 13:17 [PATCH v3 00/21] Rework gdb logging and output redirection Tom Tromey
2026-01-30 13:17 ` [PATCH v3 01/21] Remove unnecessary override of write_async_safe Tom Tromey
2026-01-30 13:17 ` [PATCH v3 02/21] Move stdtarg to ui Tom Tromey
2026-01-30 13:17 ` [PATCH v3 03/21] Turn wrapped_file into a template Tom Tromey
2026-01-30 13:17 ` [PATCH v3 04/21] Small rewrite of get_unbuffered Tom Tromey
2026-01-30 13:17 ` [PATCH v3 05/21] Move buffered stream to new files Tom Tromey
2026-01-30 13:17 ` [PATCH v3 06/21] Remove TYPE_FN_FIELD_STUB and associated code Tom Tromey
2026-01-30 13:17 ` [PATCH v3 07/21] Change how stdin is handled in the UI Tom Tromey
2026-01-30 13:17 ` [PATCH v3 08/21] Remove gdb_stdtargin Tom Tromey
2026-01-30 13:17 ` [PATCH v3 09/21] Improve fputs_highlighted by using ui_file::write Tom Tromey
2026-01-30 13:17 ` [PATCH v3 10/21] Add stream to buffer_group::output_unit constructor Tom Tromey
2026-01-30 13:17 ` [PATCH v3 11/21] Restore ui_file::can_page Tom Tromey
2026-01-30 13:17 ` [PATCH v3 12/21] Rewrite cli-style.c:do_show Tom Tromey
2026-01-30 13:17 ` [PATCH v3 13/21] Remove m_applied_style from ui_file Tom Tromey
2026-01-30 13:17 ` [PATCH v3 14/21] Add a new logging_file implementation Tom Tromey
2026-01-30 13:17 ` [PATCH v3 15/21] Rewrite output redirection and logging Tom Tromey
2026-01-30 13:17 ` [PATCH v3 16/21] Remove tee_file Tom Tromey
2026-01-30 13:17 ` [PATCH v3 17/21] Warn if log file changed while logging Tom Tromey
2026-01-30 13:17 ` [PATCH v3 18/21] Fix leaks with timestamped_file Tom Tromey
2026-01-30 13:17 ` [PATCH v3 19/21] Use std::make_unique with ui_files Tom Tromey
2026-01-30 13:17 ` Tom Tromey [this message]
2026-01-30 13:17 ` [PATCH v3 21/21] Update gdb.execute documentation Tom Tromey
2026-01-30 13:35   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260130-pr-28948-logging-5-v3-20-3eec47ef3cba@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox