aboutsummaryrefslogtreecommitdiff
path: root/bpkg/diagnostics.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-02-01 11:42:31 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-02-01 11:42:31 +0200
commit546391dab6173660acceba6404136e9411ce1388 (patch)
tree79da333fd1f7447c6b9490565f520d1d79a329b7 /bpkg/diagnostics.hxx
parent724131b7e03934664621f86df2dc2285ff43dba8 (diff)
Implement system package manager query and install support for Debian
Diffstat (limited to 'bpkg/diagnostics.hxx')
-rw-r--r--bpkg/diagnostics.hxx31
1 files changed, 30 insertions, 1 deletions
diff --git a/bpkg/diagnostics.hxx b/bpkg/diagnostics.hxx
index e8d9f0a..a01d90c 100644
--- a/bpkg/diagnostics.hxx
+++ b/bpkg/diagnostics.hxx
@@ -118,9 +118,37 @@ namespace bpkg
//
using butl::diag_stream;
using butl::diag_epilogue;
+ using butl::diag_frame;
// Diagnostic facility, project specifics.
//
+
+ // Note: diag frames are not applied to text/trace diagnostics.
+ //
+ 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_ (
+ const_cast<diag_record&> (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 +212,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 +316,7 @@ namespace bpkg
data,
[](const diag_record& r, butl::diag_writer* w)
{
+ diag_frame::apply (r);
r.flush (w);
throw failed ();
}) {}