1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems, Inc.
4
* Copyright (C) 2008 Sun Microsystems
6
6
* This program is free software; you can redistribute it and/or modify
7
7
* it under the terms of the GNU General Public License as published by
43
45
void plugin::Logging::removePlugin(plugin::Logging *handler)
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));
50
class PreIterate : public std::unary_function<plugin::Logging *, bool>
52
class PreIterate : public unary_function<plugin::Logging *, bool>
54
56
PreIterate(Session *session_arg) :
55
std::unary_function<plugin::Logging *, bool>(),
57
unary_function<plugin::Logging *, bool>(),
56
58
session(session_arg) {}
58
60
inline result_type operator()(argument_type handler)
62
64
/* TRANSLATORS: The leading word "logging" is the name
63
65
of the plugin api, and so should not be translated. */
64
errmsg_printf(error::ERROR,
66
errmsg_printf(ERRMSG_LVL_ERROR,
65
67
_("logging '%s' pre() failed"),
66
68
handler->getName().c_str());
74
class PostIterate : public std::unary_function<plugin::Logging *, bool>
76
class PostIterate : public unary_function<plugin::Logging *, bool>
78
80
PostIterate(Session *session_arg) :
79
std::unary_function<plugin::Logging *, bool>(),
81
unary_function<plugin::Logging *, bool>(),
80
82
session(session_arg) {}
82
84
/* This gets called once for each loaded logging plugin */
87
89
/* TRANSLATORS: The leading word "logging" is the name
88
90
of the plugin api, and so should not be translated. */
89
errmsg_printf(error::ERROR,
91
errmsg_printf(ERRMSG_LVL_ERROR,
90
92
_("logging '%s' post() failed"),
91
93
handler->getName().c_str());
98
class PostEndIterate : public std::unary_function<plugin::Logging *, bool>
100
class PostEndIterate : public unary_function<plugin::Logging *, bool>
100
102
Session *session;
102
104
PostEndIterate(Session *session_arg) :
103
std::unary_function<plugin::Logging *, bool>(),
105
unary_function<plugin::Logging *, bool>(),
104
106
session(session_arg) {}
106
108
/* This gets called once for each loaded logging plugin */
111
113
/* TRANSLATORS: The leading word "logging" is the name
112
114
of the plugin api, and so should not be translated. */
113
errmsg_printf(error::ERROR,
115
errmsg_printf(ERRMSG_LVL_ERROR,
114
116
_("logging '%s' postEnd() failed"),
115
117
handler->getName().c_str());
122
class ResetIterate : public std::unary_function<plugin::Logging *, bool>
126
ResetIterate(Session *session_arg) :
127
std::unary_function<plugin::Logging *, bool>(),
128
session(session_arg) {}
130
inline result_type operator()(argument_type handler)
132
if (handler->resetGlobalScoreboard())
134
/* TRANSLATORS: The leading word "logging" is the name
135
of the plugin api, and so should not be translated. */
136
errmsg_printf(error::ERROR,
137
_("logging '%s' resetCurrentScoreboard() failed"),
138
handler->getName().c_str());
146
124
/* This is the Logging::preDo entry point.
147
125
This gets called by the rest of the Drizzle server code */
148
126
bool plugin::Logging::preDo(Session *session)
150
128
/* 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));
129
vector<plugin::Logging *>::iterator iter=
130
find_if(all_loggers.begin(), all_loggers.end(),
131
PreIterate(session));
154
132
/* If iter is == end() here, that means that all of the plugins returned
155
133
* false, which in this case means they all succeeded. Since we want to
156
134
* return false on success, we return the value of the two being !=
163
141
bool plugin::Logging::postDo(Session *session)
165
143
/* 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));
144
vector<plugin::Logging *>::iterator iter=
145
find_if(all_loggers.begin(), all_loggers.end(),
146
PostIterate(session));
169
147
/* If iter is == end() here, that means that all of the plugins returned
170
148
* false, which in this case means they all succeeded. Since we want to
171
149
* return false on success, we return the value of the two being !=
177
155
bool plugin::Logging::postEndDo(Session *session)
179
157
/* 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));
158
vector<plugin::Logging *>::iterator iter=
159
find_if(all_loggers.begin(), all_loggers.end(),
160
PostEndIterate(session));
183
161
/* If iter is == end() here, that means that all of the plugins returned
184
162
* false, which in this case means they all succeeded. Since we want to
185
163
* return false on success, we return the value of the two being !=
187
165
return iter != all_loggers.end();
190
/* Resets global stats for logging plugin */
191
bool plugin::Logging::resetStats(Session *session)
193
std::vector<plugin::Logging *>::iterator iter=
194
std::find_if(all_loggers.begin(), all_loggers.end(),
195
ResetIterate(session));
197
return iter != all_loggers.end();
200
168
} /* namespace drizzled */