diff options
author | Tom Tromey <tom@tromey.com> | 2021-12-31 11:44:19 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2022-03-28 14:13:28 -0600 |
commit | 3c6c449e304413f513db5635abd2181776f7db92 (patch) | |
tree | 5893f61deb6f79f3c3107c06c961ccc4cad8bb49 /gdb/ui-file.h | |
parent | 8b1931b39443acab9d1f8272a8a81b261f7ef29b (diff) | |
download | gdb-3c6c449e304413f513db5635abd2181776f7db92.zip gdb-3c6c449e304413f513db5635abd2181776f7db92.tar.gz gdb-3c6c449e304413f513db5635abd2181776f7db92.tar.bz2 |
Add new timestamped_file class
This adds a "timestamped_file" subclass of ui_file. This class adds a
timestamp to its output when appropriate. That is, it follows the
rule already used in vfprintf_unfiltered of adding a timestamp at most
once per write.
The new class is not yet used.
Diffstat (limited to 'gdb/ui-file.h')
-rw-r--r-- | gdb/ui-file.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/gdb/ui-file.h b/gdb/ui-file.h index d8bc3fb..8d41f6f 100644 --- a/gdb/ui-file.h +++ b/gdb/ui-file.h @@ -364,4 +364,28 @@ public: void puts (const char *linebuffer) override; }; +/* A ui_file that optionally puts a timestamp at the start of each + line of output. */ + +class timestamped_file : public ui_file +{ +public: + explicit timestamped_file (ui_file *stream) + : m_stream (stream) + { + } + + DISABLE_COPY_AND_ASSIGN (timestamped_file); + + void write (const char *buf, long len) override; + +private: + + /* Output is sent here. */ + ui_file *m_stream; + + /* True if the next output should be timestamped. */ + bool m_needs_timestamp = true; +}; + #endif |