From d1b60704e8607070086e4c23314badc624ce1a86 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 14 Apr 2015 15:38:25 +0200 Subject: Next iteration on diagnostics --- brep/module | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'brep/module') 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 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 fail; - // Trace verbosity level. // // 0 - tracing disabled. @@ -62,14 +80,6 @@ namespace brep template static void level1 (const F& f) {if (verb_ >= 1) f ();} template 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; - using tracer = trace_mark; - // Implementation details. // protected: -- cgit v1.1