aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbutl/diagnostics.cxx10
-rw-r--r--libbutl/diagnostics.hxx11
2 files changed, 13 insertions, 8 deletions
diff --git a/libbutl/diagnostics.cxx b/libbutl/diagnostics.cxx
index f574fd6..3254e27 100644
--- a/libbutl/diagnostics.cxx
+++ b/libbutl/diagnostics.cxx
@@ -157,14 +157,14 @@ namespace butl
void (*diag_record::writer) (const diag_record&) = &default_writer;
void diag_record::
- flush () const
+ flush (void (*w) (const diag_record&)) const
{
if (!empty_)
{
if (epilogue_ == nullptr)
{
- if (writer != nullptr)
- writer (*this);
+ if (w != nullptr || (w = writer) != nullptr)
+ w (*this);
empty_ = true;
}
@@ -174,8 +174,8 @@ namespace butl
//
auto e (epilogue_);
epilogue_ = nullptr;
- e (*this); // Can throw.
- flush (); // Call ourselves to write the data in case it returns.
+ e (*this); // Can throw. @@ TODO: pass writer.
+ flush (w); // Call ourselves to write the data in case it returns.
}
}
}
diff --git a/libbutl/diagnostics.hxx b/libbutl/diagnostics.hxx
index 23aa14f..574695c 100644
--- a/libbutl/diagnostics.hxx
+++ b/libbutl/diagnostics.hxx
@@ -27,8 +27,11 @@ namespace butl
LIBBUTL_SYMEXPORT extern std::ostream* diag_stream;
// Acquire the diagnostics exclusive access mutex in ctor, release in dtor.
- // An object of the type must be created prior to writing to diag_stream (see
- // above).
+ // An object of the type must be created prior to writing to diag_stream
+ // (see above).
+ //
+ // Note that this class also manages the interaction with the progress
+ // printing (see below).
//
struct LIBBUTL_SYMEXPORT diag_stream_lock
{
@@ -128,8 +131,10 @@ namespace butl
bool
full () const {return !empty_;}
+ // Note that currently the passed writer is not passed to the epilogue.
+ //
void
- flush () const;
+ flush (void (*writer) (const diag_record&) = nullptr) const;
void
append (const char* indent, diag_epilogue* e) const