aboutsummaryrefslogtreecommitdiff
path: root/brep/module.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-04-10 16:29:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-04-10 16:29:15 +0200
commitd5a8c51d4010285be02f3252520300a737799872 (patch)
tree50c1ea90ce3d7a23c6c8400b4d982aa158485a5f /brep/module.cxx
parent2d89c9d6aa0f2fcdd6403c4973f7e7005a6796a0 (diff)
Add diagnostics support
Diffstat (limited to 'brep/module.cxx')
-rw-r--r--brep/module.cxx30
1 files changed, 29 insertions, 1 deletions
diff --git a/brep/module.cxx b/brep/module.cxx
index 1837ccd..31e5f99 100644
--- a/brep/module.cxx
+++ b/brep/module.cxx
@@ -4,10 +4,13 @@
#include <brep/module>
+#include <functional> // bind()
+
using namespace std;
namespace brep
{
+
void module::
handle (request& rq, response& rs, log& l)
{
@@ -19,10 +22,16 @@ namespace brep
}
catch (const invalid_request& e)
{
- // @@ Format as HTML in proper style.
+ // @@ Both log and format as HTML in proper style, etc.
//
rs.content (e.status, "text/html;charset=utf-8") << e.description;
}
+ catch (const server_error& e)
+ {
+ // @@ Both log and return as 505.
+ //
+ write (move (e.data));
+ }
catch (const exception& e)
{
// @@ Exception: log e.what () & 505.
@@ -36,4 +45,23 @@ namespace brep
rs.status (505);
}
}
+
+ module::
+ module ()
+ : error (severity::error, log_writer_),
+ warn (severity::warn, log_writer_),
+ info (severity::info, log_writer_),
+ log_writer_ (bind (&module::write, this, _1))
+ {
+ }
+
+ void module::
+ log_write (diag_data&& d) const
+ {
+ if (log_ == nullptr)
+ return; // No backend yet.
+
+ //@@ Cast log_ to apache::log and write the records.
+ //
+ }
}