21 #include <drizzled/plugin/logging.h>
22 #include <drizzled/gettext.h>
23 #include <drizzled/errmsg_print.h>
30 std::vector<plugin::Logging *> all_loggers;
32 bool plugin::Logging::addPlugin(plugin::Logging *handler)
35 all_loggers.push_back(handler);
39 void plugin::Logging::removePlugin(plugin::Logging *handler)
42 all_loggers.erase(std::find(all_loggers.begin(), all_loggers.end(), handler));
46 class PreIterate :
public std::unary_function<plugin::Logging *, bool>
51 std::unary_function<plugin::Logging *, bool>(),
52 session(session_arg) {}
54 inline result_type operator()(argument_type handler)
56 if (handler->pre(session))
60 errmsg_printf(error::ERROR,
61 _(
"logging '%s' pre() failed"),
62 handler->getName().c_str());
70 class PostIterate :
public std::unary_function<plugin::Logging *, bool>
75 std::unary_function<plugin::Logging *, bool>(),
76 session(session_arg) {}
79 inline result_type operator()(argument_type handler)
81 if (handler->post(session))
85 errmsg_printf(error::ERROR,
86 _(
"logging '%s' post() failed"),
87 handler->getName().c_str());
99 std::unary_function<plugin::Logging *, bool>(),
100 session(session_arg) {}
103 inline result_type operator()(argument_type handler)
105 if (handler->postEnd(session))
109 errmsg_printf(error::ERROR,
110 _(
"logging '%s' postEnd() failed"),
111 handler->getName().c_str());
118 class ResetIterate :
public std::unary_function<plugin::Logging *, bool>
123 std::unary_function<plugin::Logging *, bool>(),
124 session(session_arg) {}
126 inline result_type operator()(argument_type handler)
128 if (handler->resetGlobalScoreboard())
132 errmsg_printf(error::ERROR,
133 _(
"logging '%s' resetCurrentScoreboard() failed"),
134 handler->getName().c_str());
144 bool plugin::Logging::preDo(
Session *session)
147 std::vector<plugin::Logging *>::iterator iter=
148 std::find_if(all_loggers.begin(), all_loggers.end(),
154 return iter != all_loggers.end();
159 bool plugin::Logging::postDo(Session *session)
162 std::vector<plugin::Logging *>::iterator iter=
163 std::find_if(all_loggers.begin(), all_loggers.end(),
164 PostIterate(session));
169 return iter != all_loggers.end();
173 bool plugin::Logging::postEndDo(Session *session)
176 std::vector<plugin::Logging *>::iterator iter=
177 std::find_if(all_loggers.begin(), all_loggers.end(),
178 PostEndIterate(session));
183 return iter != all_loggers.end();
187 bool plugin::Logging::resetStats(Session *session)
189 std::vector<plugin::Logging *>::iterator iter=
190 std::find_if(all_loggers.begin(), all_loggers.end(),
191 ResetIterate(session));
193 return iter != all_loggers.end();