aboutsummaryrefslogtreecommitdiff
path: root/bpkg/diagnostics.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-01-18 17:33:13 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-01-18 17:33:13 +0200
commit1eea92f1750f0aa88f32c8935bf8d373ce9ea725 (patch)
tree5e179e4ee22c3bde45b170a88074832d1b38fb30 /bpkg/diagnostics.hxx
parentd1f58962fa9953a9ed0d2c72be5d86f3d6605804 (diff)
Next chunk of work on system package manager (still multi-version)
Diffstat (limited to 'bpkg/diagnostics.hxx')
-rw-r--r--bpkg/diagnostics.hxx28
1 files changed, 27 insertions, 1 deletions
diff --git a/bpkg/diagnostics.hxx b/bpkg/diagnostics.hxx
index e8d9f0a..9dcd9cb 100644
--- a/bpkg/diagnostics.hxx
+++ b/bpkg/diagnostics.hxx
@@ -118,9 +118,34 @@ namespace bpkg
//
using butl::diag_stream;
using butl::diag_epilogue;
+ using butl::diag_frame;
// Diagnostic facility, project specifics.
//
+ template <typename F>
+ struct diag_frame_impl: diag_frame
+ {
+ explicit
+ diag_frame_impl (F f): diag_frame (&thunk), func_ (move (f)) {}
+
+ private:
+ static void
+ thunk (const diag_frame& f, const butl::diag_record& r)
+ {
+ static_cast<const diag_frame_impl&> (f).func_ (
+ static_cast<const diag_record&> (r));
+ }
+
+ const F func_;
+ };
+
+ template <typename F>
+ inline diag_frame_impl<F>
+ make_diag_frame (F f)
+ {
+ return diag_frame_impl<F> (move (f));
+ }
+
struct simple_prologue_base
{
explicit
@@ -184,7 +209,7 @@ namespace bpkg
basic_mark_base (const char* type,
const char* name = nullptr,
const void* data = nullptr,
- diag_epilogue* epilogue = nullptr)
+ diag_epilogue* epilogue = &diag_frame::apply)
: type_ (type), name_ (name), data_ (data), epilogue_ (epilogue) {}
simple_prologue
@@ -288,6 +313,7 @@ namespace bpkg
data,
[](const diag_record& r, butl::diag_writer* w)
{
+ diag_frame::apply (r);
r.flush (w);
throw failed ();
}) {}