~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/errmsg_stderr/errmsg_stderr.cc

  • Committer: Brian Aker
  • Date: 2009-10-02 21:34:26 UTC
  • mfrom: (1134.1.4 bug426504)
  • Revision ID: brian@gaz-20091002213426-7ojknrpknoedaprl
Merge Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
 
20
#include <drizzled/server_includes.h>
21
21
#include <drizzled/plugin/error_message.h>
22
22
#include <drizzled/gettext.h>
23
 
#include <drizzled/plugin.h>
24
23
 
25
24
#include <stdio.h>  /* for vsnprintf */
26
25
#include <stdarg.h>  /* for va_list */
27
26
#include <unistd.h>  /* for write(2) */
28
27
 
29
 
using namespace drizzled;
30
 
 
31
28
/* todo, make this dynamic as needed */
32
29
#define MAX_MSG_LEN 8192
33
30
 
34
 
class Error_message_stderr : public plugin::ErrorMessage
 
31
class Error_message_stderr : public drizzled::plugin::ErrorMessage
35
32
{
36
33
public:
37
 
  Error_message_stderr()
38
 
   : plugin::ErrorMessage("Error_message_stderr") {}
 
34
  Error_message_stderr() : Error_message_handler("Error_message_stderr") {}
39
35
  virtual bool errmsg(Session *, int , const char *format, va_list ap)
40
36
  {
41
37
    char msgbuf[MAX_MSG_LEN];
55
51
};
56
52
 
57
53
static Error_message_stderr *handler= NULL;
58
 
static int errmsg_stderr_plugin_init(module::Context &context)
 
54
static int errmsg_stderr_plugin_init(drizzled::plugin::Registry &registry)
59
55
{
60
56
  handler= new Error_message_stderr();
61
 
  context.add(handler);
62
 
 
63
 
  return 0;
64
 
}
65
 
 
66
 
DRIZZLE_DECLARE_PLUGIN
67
 
{
68
 
  DRIZZLE_VERSION_ID,
 
57
  registry.add(handler);
 
58
 
 
59
  return 0;
 
60
}
 
61
 
 
62
static int errmsg_stderr_plugin_deinit(drizzled::plugin::Registry &registry)
 
63
{
 
64
 
 
65
  if (handler)
 
66
  {
 
67
    registry.remove(handler);
 
68
    delete handler;
 
69
  }
 
70
  return 0;
 
71
}
 
72
 
 
73
drizzle_declare_plugin(errmsg_stderr)
 
74
{
69
75
  "errmsg_stderr",
70
76
  "0.1",
71
77
  "Mark Atwood <mark@fallenpegasus.com>",
72
78
  N_("Error Messages to stderr"),
73
79
  PLUGIN_LICENSE_GPL,
74
80
  errmsg_stderr_plugin_init,
 
81
  errmsg_stderr_plugin_deinit,
 
82
  NULL, /* status variables */
75
83
  NULL, /* system variables */
76
84
  NULL
77
85
}
78
 
DRIZZLE_DECLARE_PLUGIN_END;
 
86
drizzle_declare_plugin_end;