aboutsummaryrefslogtreecommitdiff
path: root/brep/module
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-04-14 15:38:25 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-04-14 15:38:25 +0200
commitd1b60704e8607070086e4c23314badc624ce1a86 (patch)
tree3b2987833e677bcdaf65b18d534df6fb7a4748ae /brep/module
parent79cb830c94b19e987dfa7202f304a9235c378279 (diff)
Next iteration on diagnostics
Diffstat (limited to 'brep/module')
-rw-r--r--brep/module36
1 files changed, 23 insertions, 13 deletions
diff --git a/brep/module b/brep/module
index 0b69aaf..1803ee8 100644
--- a/brep/module
+++ b/brep/module
@@ -33,6 +33,29 @@ namespace brep
diag_data data;
};
+ // Every module member function that needs to produce any diagnostics
+ // shall begin with:
+ //
+ // MODULE_DIAG;
+ //
+ // This will instantiate the fail, error, warn, info, and trace
+ // diagnostics streams with the function's name.
+ //
+#define MODULE_DIAG \
+ const fail_mark<server_error> fail (__PRETTY_FUNCTION__); \
+ const basic_mark error (severity::error, \
+ this->log_writer_, \
+ __PRETTY_FUNCTION__); \
+ const basic_mark warn (severity::warn, \
+ this->log_writer_, \
+ __PRETTY_FUNCTION__); \
+ const basic_mark info (severity::info, \
+ this->log_writer_, \
+ __PRETTY_FUNCTION__); \
+ const basic_mark trace (severity::info, \
+ this->log_writer_, \
+ __PRETTY_FUNCTION__)
+
// Adaptation of the web::module to our needs.
//
class module: public web::module
@@ -44,11 +67,6 @@ namespace brep
// Diagnostics.
//
protected:
- const basic_mark error;
- const basic_mark warn;
- const basic_mark info;
- const fail_mark<server_error> fail;
-
// Trace verbosity level.
//
// 0 - tracing disabled.
@@ -62,14 +80,6 @@ namespace brep
template <class F> static void level1 (const F& f) {if (verb_ >= 1) f ();}
template <class F> static void level2 (const F& f) {if (verb_ >= 2) f ();}
- struct trace_mark_base: basic_mark_base
- {
- trace_mark_base (const module* this_, const char* name)
- : basic_mark_base (severity::trace, this_->log_writer_, name) {}
- };
- using trace_mark = diag_mark<trace_mark_base>;
- using tracer = trace_mark;
-
// Implementation details.
//
protected: