1
/* drizzle/plugin/errmsg_stderr/errmsg_stderr.cc */
3
/* need to define DRIZZLE_SERVER to get inside the THD */
4
#define DRIZZLE_SERVER 1
5
#include <drizzled/server_includes.h>
6
#include <drizzled/plugin_errmsg.h>
8
#include <stdio.h> /* for vsnprintf */
9
#include <stdarg.h> /* for va_list */
10
#include <unistd.h> /* for write(2) */
12
bool errmsg_stderr_func (THD *thd, int priority, const char *format, va_list ap)
14
char msgbuf[MAX_MSG_LEN];
18
prv = vsnprintf(msgbuf, MAX_MSG_LEN, format, ap);
19
if (prv < 0) return true;
21
/* a single write has a OS level thread lock
22
so there is no need to have mutexes guarding this write,
24
wrv= write(2, msgbuf, prv);
25
if ((wrv < 0) || (wrv != prv)) return true;
30
static int errmsg_stderr_plugin_init(void *p)
32
errmsg_t *l= (errmsg_t *) p;
34
l->errmsg_func= errmsg_stderr_func;
39
static int errmsg_stderr_plugin_deinit(void *p)
41
errmsg_st *l= (errmsg_st *) p;
48
mysql_declare_plugin(errmsg_stderr)
50
DRIZZLE_LOGGER_PLUGIN,
53
"Mark Atwood <mark@fallenpegasus.com>",
54
"Error Messages to stderr",
56
errmsg_stderr_plugin_init,
57
errmsg_stderr_plugin_deinit,
58
NULL, /* status variables */
59
NULL, /* system variables */
62
mysql_declare_plugin_end;