aboutsummaryrefslogtreecommitdiff
path: root/mod/tenant-service.hxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2024-03-22 16:04:51 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2024-03-25 11:20:37 +0300
commita7e49dbeab6c1a0500ca8fa3a1a6261b3740b6b0 (patch)
treeb18ab48616d3cd6d3ec919048fd5363e322d17e4 /mod/tenant-service.hxx
parent11369a47e37419a8ef71b99f221f6f1dabcbf6c9 (diff)
Add NOTIFICATION_DIAG macro to mod/tenant-service.hxx
Diffstat (limited to 'mod/tenant-service.hxx')
-rw-r--r--mod/tenant-service.hxx39
1 files changed, 36 insertions, 3 deletions
diff --git a/mod/tenant-service.hxx b/mod/tenant-service.hxx
index a7bc941..46f2822 100644
--- a/mod/tenant-service.hxx
+++ b/mod/tenant-service.hxx
@@ -11,6 +11,8 @@
#include <libbrep/build.hxx>
+#include <mod/diagnostics.hxx>
+
namespace brep
{
class tenant_service_base
@@ -82,26 +84,57 @@ namespace brep
virtual function<optional<string> (const tenant_service&)>
build_queued (const tenant_service&,
const vector<build>&,
- optional<build_state> initial_state) const = 0;
+ optional<build_state> initial_state,
+ const diag_epilogue& log_writer) const noexcept = 0;
};
class tenant_service_build_building: public virtual tenant_service_base
{
public:
virtual function<optional<string> (const tenant_service&)>
- build_building (const tenant_service&, const build&) const = 0;
+ build_building (const tenant_service&,
+ const build&,
+ const diag_epilogue& log_writer) const noexcept = 0;
};
class tenant_service_build_built: public virtual tenant_service_base
{
public:
virtual function<optional<string> (const tenant_service&)>
- build_built (const tenant_service&, const build&) const = 0;
+ build_built (const tenant_service&,
+ const build&,
+ const diag_epilogue& log_writer) const noexcept = 0;
};
// Map of service type (tenant_service::type) to service.
//
using tenant_service_map = std::map<string, shared_ptr<tenant_service_base>>;
+
+ // Every notification callback function that needs to produce any
+ // diagnostics shall begin with:
+ //
+ // NOTIFICATION_DIAG (log_writer);
+ //
+ // This will instantiate the error, warn, info, and trace diagnostics
+ // streams with the function's name.
+ //
+ // Note that a callback function is not expected to throw any exceptions.
+ // This is, in particular, why this macro doesn't instantiate the fail
+ // diagnostics stream.
+ //
+#define NOTIFICATION_DIAG(log_writer) \
+ const basic_mark error (severity::error, \
+ log_writer, \
+ __PRETTY_FUNCTION__); \
+ const basic_mark warn (severity::warning, \
+ log_writer, \
+ __PRETTY_FUNCTION__); \
+ const basic_mark info (severity::info, \
+ log_writer, \
+ __PRETTY_FUNCTION__); \
+ const basic_mark trace (severity::trace, \
+ log_writer, \
+ __PRETTY_FUNCTION__)
}
#endif // MOD_TENANT_SERVICE_HXX