diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-03-01 17:53:09 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-03-01 17:53:09 +0200 |
commit | 478f413b80204ac4097b8db8a6ae5056d14adb54 (patch) | |
tree | 19c4de26bc5bdde449a8b7f90063fc7a6a4525ee /butl/diagnostics.cxx | |
parent | eb1a8648ed7b84f311f5c5256847093aa2db523d (diff) |
Support fancier epilogues in diagnostics
Diffstat (limited to 'butl/diagnostics.cxx')
-rw-r--r-- | butl/diagnostics.cxx | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/butl/diagnostics.cxx b/butl/diagnostics.cxx index 4cd8515..7dc8bd0 100644 --- a/butl/diagnostics.cxx +++ b/butl/diagnostics.cxx @@ -17,14 +17,23 @@ namespace butl { if (!empty_) { - os.put ('\n'); - *diag_stream << os.str (); - diag_stream->flush (); - - empty_ = true; - - if (epilogue_ != nullptr) - epilogue_ (*this); // Can throw. + if (epilogue_ == nullptr) + { + os.put ('\n'); + *diag_stream << os.str (); + diag_stream->flush (); + + empty_ = true; + } + else + { + // Clear the epilogue in case it calls us back. + // + auto e (epilogue_); + epilogue_ = nullptr; + e (*this); // Can throw. + flush (); // Call ourselves to write the data in case it returns. + } } } |