aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2014-09-19 14:35:46 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2014-09-19 14:35:46 +0200
commit11eecb7f91a7cbbcde676727a2aba1b5838b83d9 (patch)
treebac9e8f613781a327c19227aa0fd3bf33ceb22fb
parent68444d048f2e4a6d2cb288d7fbcac80d6716cf53 (diff)
Add stderr_full_tracer that additionally traces statement preparation
-rw-r--r--odb/forward.hxx1
-rw-r--r--odb/tracer.cxx30
2 files changed, 30 insertions, 1 deletions
diff --git a/odb/forward.hxx b/odb/forward.hxx
index c727215..2e54471 100644
--- a/odb/forward.hxx
+++ b/odb/forward.hxx
@@ -59,6 +59,7 @@ namespace odb
//
class tracer; // Not in core.
extern LIBODB_EXPORT tracer& stderr_tracer;
+ extern LIBODB_EXPORT tracer& stderr_full_tracer;
namespace common
{
diff --git a/odb/tracer.cxx b/odb/tracer.cxx
index 6a617f4..ec79033 100644
--- a/odb/tracer.cxx
+++ b/odb/tracer.cxx
@@ -42,27 +42,55 @@ namespace odb
class stderr_tracer_type: public tracer
{
+ public:
+ stderr_tracer_type (bool full): full_ (full) {}
+
+ virtual void
+ prepare (connection&, const statement&);
+
virtual void
execute (connection&, const char* statement);
+ virtual void
+ deallocate (connection&, const statement&);
+
// Override the other version to get rid of a Sun CC warning.
//
virtual void
execute (connection&, const statement&);
+
+ private:
+ bool full_;
};
void stderr_tracer_type::
+ prepare (connection&, const statement& s)
+ {
+ if (full_)
+ cerr << "PREPARE " << s.text () << endl;
+ }
+
+ void stderr_tracer_type::
execute (connection&, const char* s)
{
cerr << s << endl;
}
void stderr_tracer_type::
+ deallocate (connection&, const statement& s)
+ {
+ if (full_)
+ cerr << "DEALLOCATE " << s.text () << endl;
+ }
+
+ void stderr_tracer_type::
execute (connection& c, const statement& s)
{
execute (c, s.text ());
}
- static stderr_tracer_type stderr_tracer_;
+ static stderr_tracer_type stderr_tracer_ (false);
+ static stderr_tracer_type stderr_full_tracer_ (true);
tracer& stderr_tracer = stderr_tracer_;
+ tracer& stderr_full_tracer = stderr_full_tracer_;
}