~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/logging.cc

  • Committer: Monty Taylor
  • Date: 2010-11-25 01:53:19 UTC
  • mto: (1953.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1955.
  • Revision ID: mordred@inaugust.com-20101125015319-ia85msn25uemopgc
Re-enabled -Wformat and then cleaned up the carnage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
class Session;
29
29
 
 
30
using namespace std;
 
31
 
30
32
namespace drizzled
31
33
{
32
34
 
33
 
std::vector<plugin::Logging *> all_loggers;
 
35
vector<plugin::Logging *> all_loggers;
34
36
 
35
37
 
36
38
bool plugin::Logging::addPlugin(plugin::Logging *handler)
43
45
void plugin::Logging::removePlugin(plugin::Logging *handler)
44
46
{
45
47
  if (handler != NULL)
46
 
    all_loggers.erase(std::find(all_loggers.begin(), all_loggers.end(), handler));
 
48
    all_loggers.erase(find(all_loggers.begin(), all_loggers.end(), handler));
47
49
}
48
50
 
49
51
 
50
 
class PreIterate : public std::unary_function<plugin::Logging *, bool>
 
52
class PreIterate : public unary_function<plugin::Logging *, bool>
51
53
{
52
54
  Session *session;
53
55
public:
54
56
  PreIterate(Session *session_arg) :
55
 
    std::unary_function<plugin::Logging *, bool>(),
 
57
    unary_function<plugin::Logging *, bool>(),
56
58
    session(session_arg) {}
57
59
 
58
60
  inline result_type operator()(argument_type handler)
71
73
};
72
74
 
73
75
 
74
 
class PostIterate : public std::unary_function<plugin::Logging *, bool>
 
76
class PostIterate : public unary_function<plugin::Logging *, bool>
75
77
{
76
78
  Session *session;
77
79
public:
78
80
  PostIterate(Session *session_arg) :
79
 
    std::unary_function<plugin::Logging *, bool>(),
 
81
    unary_function<plugin::Logging *, bool>(),
80
82
    session(session_arg) {}
81
83
 
82
84
  /* This gets called once for each loaded logging plugin */
95
97
  }
96
98
};
97
99
 
98
 
class PostEndIterate : public std::unary_function<plugin::Logging *, bool>
 
100
class PostEndIterate : public unary_function<plugin::Logging *, bool>
99
101
{
100
102
  Session *session;
101
103
public:
102
104
  PostEndIterate(Session *session_arg) :
103
 
    std::unary_function<plugin::Logging *, bool>(),
 
105
    unary_function<plugin::Logging *, bool>(),
104
106
    session(session_arg) {}
105
107
 
106
108
  /* This gets called once for each loaded logging plugin */
119
121
  }
120
122
};
121
123
 
122
 
class ResetIterate : public std::unary_function<plugin::Logging *, bool>
 
124
class ResetIterate : public unary_function<plugin::Logging *, bool>
123
125
{
124
126
  Session *session;
125
127
public:
126
128
  ResetIterate(Session *session_arg) :
127
 
    std::unary_function<plugin::Logging *, bool>(),
 
129
    unary_function<plugin::Logging *, bool>(),
128
130
    session(session_arg) {}
129
131
 
130
132
  inline result_type operator()(argument_type handler)
148
150
bool plugin::Logging::preDo(Session *session)
149
151
{
150
152
  /* Use find_if instead of foreach so that we can collect return codes */
151
 
  std::vector<plugin::Logging *>::iterator iter=
152
 
    std::find_if(all_loggers.begin(), all_loggers.end(),
153
 
                 PreIterate(session)); 
 
153
  vector<plugin::Logging *>::iterator iter=
 
154
    find_if(all_loggers.begin(), all_loggers.end(),
 
155
            PreIterate(session)); 
154
156
  /* If iter is == end() here, that means that all of the plugins returned
155
157
   * false, which in this case means they all succeeded. Since we want to 
156
158
   * return false on success, we return the value of the two being != 
163
165
bool plugin::Logging::postDo(Session *session)
164
166
{
165
167
  /* Use find_if instead of foreach so that we can collect return codes */
166
 
  std::vector<plugin::Logging *>::iterator iter=
167
 
    std::find_if(all_loggers.begin(), all_loggers.end(),
168
 
                 PostIterate(session)); 
 
168
  vector<plugin::Logging *>::iterator iter=
 
169
    find_if(all_loggers.begin(), all_loggers.end(),
 
170
            PostIterate(session)); 
169
171
  /* If iter is == end() here, that means that all of the plugins returned
170
172
   * false, which in this case means they all succeeded. Since we want to 
171
173
   * return false on success, we return the value of the two being != 
177
179
bool plugin::Logging::postEndDo(Session *session)
178
180
{
179
181
  /* Use find_if instead of foreach so that we can collect return codes */
180
 
  std::vector<plugin::Logging *>::iterator iter=
181
 
    std::find_if(all_loggers.begin(), all_loggers.end(),
182
 
                 PostEndIterate(session));
 
182
  vector<plugin::Logging *>::iterator iter=
 
183
    find_if(all_loggers.begin(), all_loggers.end(),
 
184
            PostEndIterate(session));
183
185
  /* If iter is == end() here, that means that all of the plugins returned
184
186
   * false, which in this case means they all succeeded. Since we want to
185
187
   * return false on success, we return the value of the two being !=
190
192
/* Resets global stats for logging plugin */
191
193
bool plugin::Logging::resetStats(Session *session)
192
194
{
193
 
  std::vector<plugin::Logging *>::iterator iter=
194
 
    std::find_if(all_loggers.begin(), all_loggers.end(),
195
 
                 ResetIterate(session));
 
195
  vector<plugin::Logging *>::iterator iter=
 
196
    find_if(all_loggers.begin(), all_loggers.end(),
 
197
            ResetIterate(session));
196
198
 
197
199
  return iter != all_loggers.end();
198
200
}