From 11eecb7f91a7cbbcde676727a2aba1b5838b83d9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 19 Sep 2014 14:35:46 +0200 Subject: Add stderr_full_tracer that additionally traces statement preparation --- odb/forward.hxx | 1 + odb/tracer.cxx | 30 +++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'odb') 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_; } -- cgit v1.1