499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
499.2.10
by Mark Atwood
add editor format hints, and other useful metadata comments |
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
3 |
*
|
499.2.10
by Mark Atwood
add editor format hints, and other useful metadata comments |
4 |
* Copyright (C) 2008 Mark Atwood
|
5 |
*
|
|
6 |
* This program is free software; you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License as published by
|
|
8 |
* the Free Software Foundation; version 2 of the License.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
18 |
*/
|
|
499.2.6
by Mark Atwood
an implemention of the errmsg plugin |
19 |
|
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
20 |
#include <config.h> |
1130.1.1
by Monty Taylor
Merged in plugin-slot-reorg patches. |
21 |
#include <drizzled/plugin/error_message.h> |
549
by Monty Taylor
Took gettext.h out of header files. |
22 |
#include <drizzled/gettext.h> |
1237.9.6
by Padraig O'Sullivan
Resolved some conflicts that appeared after merging with trunk. |
23 |
#include <drizzled/plugin.h> |
499.2.6
by Mark Atwood
an implemention of the errmsg plugin |
24 |
|
25 |
#include <stdio.h> /* for vsnprintf */ |
|
26 |
#include <stdarg.h> /* for va_list */ |
|
27 |
#include <unistd.h> /* for write(2) */ |
|
28 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
29 |
using namespace drizzled; |
30 |
||
499.2.10
by Mark Atwood
add editor format hints, and other useful metadata comments |
31 |
/* todo, make this dynamic as needed */
|
499.2.7
by Mark Atwood
some bugs in errmsg plugin |
32 |
#define MAX_MSG_LEN 8192
|
33 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
34 |
class Error_message_stderr : public plugin::ErrorMessage |
499.2.6
by Mark Atwood
an implemention of the errmsg plugin |
35 |
{
|
942.1.16
by Monty Taylor
Converted error message plugin to class. |
36 |
public: |
1228.1.9
by Monty Taylor
Replication and error messages. |
37 |
Error_message_stderr() |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
38 |
: plugin::ErrorMessage("Error_message_stderr") {} |
2126.3.3
by Brian Aker
Merge in error message rework. Many error messages are fixed in this patch. |
39 |
virtual bool errmsg(error::level_t , const char *format, va_list ap) |
942.1.16
by Monty Taylor
Converted error message plugin to class. |
40 |
{
|
41 |
char msgbuf[MAX_MSG_LEN]; |
|
42 |
int prv, wrv; |
|
43 |
||
44 |
prv= vsnprintf(msgbuf, MAX_MSG_LEN, format, ap); |
|
45 |
if (prv < 0) return true; |
|
46 |
||
47 |
/* a single write has a OS level thread lock
|
|
48 |
so there is no need to have mutexes guarding this write,
|
|
49 |
*/
|
|
2139.3.11
by Brian Aker
Error log messages from Inno, most, not all are sent to the correct error |
50 |
wrv= write(fileno(stderr), msgbuf, prv); |
51 |
fputc('\n', stderr); |
|
52 |
if ((wrv < 0) || (wrv != prv)) |
|
53 |
return true; |
|
942.1.16
by Monty Taylor
Converted error message plugin to class. |
54 |
|
55 |
return false; |
|
56 |
}
|
|
57 |
};
|
|
499.2.6
by Mark Atwood
an implemention of the errmsg plugin |
58 |
|
971.1.51
by Monty Taylor
New-style plugin registration now works. |
59 |
static Error_message_stderr *handler= NULL; |
1530.2.6
by Monty Taylor
Moved plugin::Context to module::Context. |
60 |
static int errmsg_stderr_plugin_init(module::Context &context) |
499.2.6
by Mark Atwood
an implemention of the errmsg plugin |
61 |
{
|
971.1.51
by Monty Taylor
New-style plugin registration now works. |
62 |
handler= new Error_message_stderr(); |
1324.2.2
by Monty Taylor
Use the plugin::Context everywhere. |
63 |
context.add(handler); |
499.2.6
by Mark Atwood
an implemention of the errmsg plugin |
64 |
|
65 |
return 0; |
|
66 |
}
|
|
67 |
||
1228.1.5
by Monty Taylor
Merged in some naming things. |
68 |
DRIZZLE_DECLARE_PLUGIN
|
499.2.6
by Mark Atwood
an implemention of the errmsg plugin |
69 |
{
|
1241.10.2
by Monty Taylor
Added support for embedding the drizzle version number in the plugin file. |
70 |
DRIZZLE_VERSION_ID, |
499.2.6
by Mark Atwood
an implemention of the errmsg plugin |
71 |
"errmsg_stderr", |
72 |
"0.1", |
|
73 |
"Mark Atwood <mark@fallenpegasus.com>", |
|
499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
74 |
N_("Error Messages to stderr"), |
499.2.6
by Mark Atwood
an implemention of the errmsg plugin |
75 |
PLUGIN_LICENSE_GPL, |
76 |
errmsg_stderr_plugin_init, |
|
2095.3.1
by Monty Taylor
Re-purpose the old plugin sysvar slot in the struct to be a depends list. |
77 |
NULL, /* depends */ |
499.2.6
by Mark Atwood
an implemention of the errmsg plugin |
78 |
NULL
|
79 |
}
|
|
1228.1.5
by Monty Taylor
Merged in some naming things. |
80 |
DRIZZLE_DECLARE_PLUGIN_END; |