22 #include <drizzled/error.h>
23 #include <drizzled/gettext.h>
24 #include <drizzled/plugin/error_message.h>
33 std::vector<plugin::ErrorMessage *> all_errmsg_handler;
35 bool plugin::ErrorMessage::addPlugin(plugin::ErrorMessage *handler)
37 all_errmsg_handler.push_back(handler);
41 void plugin::ErrorMessage::removePlugin(plugin::ErrorMessage *)
43 all_errmsg_handler.clear();
47 class Print :
public std::unary_function<plugin::ErrorMessage *, bool>
49 error::priority_t priority;
54 Print(error::priority_t priority_arg,
55 const char *format_arg, va_list ap_arg) :
56 std::unary_function<plugin::ErrorMessage *, bool>(),
57 priority(priority_arg), format(format_arg)
62 ~
Print() { va_end(ap); }
64 inline result_type operator()(argument_type handler)
67 va_copy(handler_ap, ap);
68 if (handler->errmsg(priority, format, handler_ap))
76 _(
"errmsg plugin '%s' errmsg() failed"),
77 handler->getName().c_str());
88 bool plugin::ErrorMessage::vprintf(error::priority_t priority,
char const *format, va_list ap)
90 if (priority > error::verbosity())
99 if (all_errmsg_handler.size() == 0)
106 vfprintf(stderr, format, ap);
113 std::vector<plugin::ErrorMessage *>::iterator iter=
114 std::find_if(all_errmsg_handler.begin(), all_errmsg_handler.end(),
115 Print(priority, format, ap));
121 return iter != all_errmsg_handler.end();