~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/error_message.cc

  • Committer: Andrew Hutchings
  • Date: 2011-02-07 17:20:59 UTC
  • mfrom: (2148 staging)
  • mto: (2148.2.3 build)
  • mto: This revision was merged to the branch mainline in revision 2149.
  • Revision ID: andrew@linuxjedi.co.uk-20110207172059-dyeahrgzrlincoe3
Merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
{
31
31
 
32
32
std::vector<plugin::ErrorMessage *> all_errmsg_handler;
33
 
bool errmsg_has= false;
34
 
 
35
33
 
36
34
bool plugin::ErrorMessage::addPlugin(plugin::ErrorMessage *handler)
37
35
{
38
36
  all_errmsg_handler.push_back(handler);
39
 
  errmsg_has= true;
40
37
  return false;
41
38
}
42
39
 
43
 
void plugin::ErrorMessage::removePlugin(plugin::ErrorMessage *handler)
 
40
void plugin::ErrorMessage::removePlugin(plugin::ErrorMessage *)
44
41
{
45
 
  all_errmsg_handler.erase(std::find(all_errmsg_handler.begin(),
46
 
                                     all_errmsg_handler.end(), handler));
 
42
  all_errmsg_handler.clear();
47
43
}
48
44
 
49
45
 
90
86
bool plugin::ErrorMessage::vprintf(error::level_t priority, char const *format, va_list ap)
91
87
{
92
88
 
93
 
  /* check to see if any errmsg plugin has been loaded
94
 
     if not, just fall back to emitting the message to stderr */
95
 
  if (not errmsg_has)
 
89
  /* 
 
90
    Check to see if any errmsg plugin has been loaded
 
91
    if not, just fall back to emitting the message to stderr.
 
92
  */
 
93
  if (not all_errmsg_handler.size())
96
94
  {
97
95
    /* if it turns out that the vfprintf doesnt do one single write
98
96
       (single writes are atomic), then this needs to be rewritten to
99
97
       vsprintf into a char buffer, and then write() that char buffer
100
98
       to stderr */
101
99
    vfprintf(stderr, format, ap);
 
100
    fputc('\n', stderr);
102
101
    return false;
103
102
  }
104
103