~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/errmsg_stderr/errmsg_stderr.cc

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include <drizzled/plugin/error_message.h>
22
22
#include <drizzled/gettext.h>
23
23
#include <drizzled/plugin.h>
24
 
#include <drizzled/plugin/registry.h>
25
24
 
26
25
#include <stdio.h>  /* for vsnprintf */
27
26
#include <stdarg.h>  /* for va_list */
37
36
public:
38
37
  Error_message_stderr()
39
38
   : plugin::ErrorMessage("Error_message_stderr") {}
40
 
  virtual bool errmsg(Session *, int , const char *format, va_list ap)
 
39
  virtual bool errmsg(error::level_t , const char *format, va_list ap)
41
40
  {
42
41
    char msgbuf[MAX_MSG_LEN];
43
42
    int prv, wrv;
48
47
    /* a single write has a OS level thread lock
49
48
       so there is no need to have mutexes guarding this write,
50
49
    */
51
 
    wrv= write(2, msgbuf, prv);
52
 
    if ((wrv < 0) || (wrv != prv)) return true;
 
50
    wrv= write(fileno(stderr), msgbuf, prv);
 
51
    fputc('\n', stderr);
 
52
    if ((wrv < 0) || (wrv != prv))
 
53
      return true;
53
54
 
54
55
    return false;
55
56
  }
56
57
};
57
58
 
58
59
static Error_message_stderr *handler= NULL;
59
 
static int errmsg_stderr_plugin_init(plugin::Registry &registry)
 
60
static int errmsg_stderr_plugin_init(module::Context &context)
60
61
{
61
62
  handler= new Error_message_stderr();
62
 
  registry.add(handler);
63
 
 
64
 
  return 0;
65
 
}
66
 
 
67
 
static int errmsg_stderr_plugin_deinit(plugin::Registry &registry)
68
 
{
69
 
 
70
 
  if (handler)
71
 
  {
72
 
    registry.remove(handler);
73
 
    delete handler;
74
 
  }
 
63
  context.add(handler);
 
64
 
75
65
  return 0;
76
66
}
77
67
 
84
74
  N_("Error Messages to stderr"),
85
75
  PLUGIN_LICENSE_GPL,
86
76
  errmsg_stderr_plugin_init,
87
 
  errmsg_stderr_plugin_deinit,
88
 
  NULL, /* system variables */
 
77
  NULL, /* depends */
89
78
  NULL
90
79
}
91
80
DRIZZLE_DECLARE_PLUGIN_END;