1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// file : odb/tracer.cxx
// copyright : Copyright (c) 2009-2017 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <iostream>
#include <odb/tracer.hxx>
#include <odb/statement.hxx>
using namespace std;
namespace odb
{
//
// tracer
//
tracer::
~tracer ()
{
}
void tracer::
prepare (connection&, const statement&)
{
}
void tracer::
execute (connection& c, const statement& s)
{
execute (c, s.text ());
}
void tracer::
deallocate (connection&, const statement&)
{
}
//
// stderr_tracer
//
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_ (false);
static stderr_tracer_type stderr_full_tracer_ (true);
tracer& stderr_tracer = stderr_tracer_;
tracer& stderr_full_tracer = stderr_full_tracer_;
}
|