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 |
*/
|
|
19 |
||
383.6.1
by Mark Atwood
add pluggable logging |
20 |
#include <drizzled/server_includes.h> |
21 |
#include <drizzled/logging.h> |
|
549
by Monty Taylor
Took gettext.h out of header files. |
22 |
#include <drizzled/gettext.h> |
383.6.1
by Mark Atwood
add pluggable logging |
23 |
|
24 |
int logging_initializer(st_plugin_int *plugin) |
|
25 |
{
|
|
958.1.1
by Monty Taylor
Made logging plugin class based. |
26 |
Logging_handler *p; |
383.6.1
by Mark Atwood
add pluggable logging |
27 |
|
28 |
if (plugin->plugin->init) |
|
29 |
{
|
|
958.1.1
by Monty Taylor
Made logging plugin class based. |
30 |
if (plugin->plugin->init(&p)) |
383.6.1
by Mark Atwood
add pluggable logging |
31 |
{
|
499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
32 |
/* TRANSLATORS: The leading word "logging" is the name
|
33 |
of the plugin api, and so should not be translated. */
|
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
34 |
errmsg_printf(ERRMSG_LVL_ERROR, "logging plugin '%s' init() failed", |
958.1.1
by Monty Taylor
Made logging plugin class based. |
35 |
plugin->name.str); |
36 |
return 1; |
|
383.6.1
by Mark Atwood
add pluggable logging |
37 |
}
|
38 |
}
|
|
810
by Brian Aker
Fix for making sure I_S has good information about which plugins are |
39 |
|
958.1.1
by Monty Taylor
Made logging plugin class based. |
40 |
plugin->data= (void *)p; |
810
by Brian Aker
Fix for making sure I_S has good information about which plugins are |
41 |
|
383.6.1
by Mark Atwood
add pluggable logging |
42 |
return 0; |
43 |
}
|
|
44 |
||
958.1.1
by Monty Taylor
Made logging plugin class based. |
45 |
|
383.6.1
by Mark Atwood
add pluggable logging |
46 |
int logging_finalizer(st_plugin_int *plugin) |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
47 |
{
|
958.1.1
by Monty Taylor
Made logging plugin class based. |
48 |
Logging_handler *p = static_cast<Logging_handler *>(plugin->data); |
383.6.1
by Mark Atwood
add pluggable logging |
49 |
|
50 |
if (plugin->plugin->deinit) |
|
51 |
{
|
|
52 |
if (plugin->plugin->deinit((void *)p)) |
|
53 |
{
|
|
499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
54 |
/* TRANSLATORS: The leading word "logging" is the name
|
55 |
of the plugin api, and so should not be translated. */
|
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
56 |
errmsg_printf(ERRMSG_LVL_ERROR, _("logging plugin '%s' deinit() failed"), |
499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
57 |
plugin->name.str); |
383.6.1
by Mark Atwood
add pluggable logging |
58 |
}
|
59 |
}
|
|
60 |
||
61 |
return 0; |
|
62 |
}
|
|
63 |
||
499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
64 |
/* This gets called by plugin_foreach once for each loaded logging plugin */
|
779.3.1
by Monty Taylor
More cleanup. |
65 |
static bool logging_pre_iterate (Session *session, plugin_ref plugin, void *) |
383.6.1
by Mark Atwood
add pluggable logging |
66 |
{
|
958.1.1
by Monty Taylor
Made logging plugin class based. |
67 |
Logging_handler *handler= plugin_data(plugin, Logging_handler *); |
383.6.1
by Mark Atwood
add pluggable logging |
68 |
|
499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
69 |
/* call this loaded logging plugin's logging_pre function pointer */
|
958.1.1
by Monty Taylor
Made logging plugin class based. |
70 |
if (handler) |
383.6.1
by Mark Atwood
add pluggable logging |
71 |
{
|
958.1.1
by Monty Taylor
Made logging plugin class based. |
72 |
if (handler->pre(session)) |
499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
73 |
{
|
74 |
/* TRANSLATORS: The leading word "logging" is the name
|
|
75 |
of the plugin api, and so should not be translated. */
|
|
958.1.1
by Monty Taylor
Made logging plugin class based. |
76 |
errmsg_printf(ERRMSG_LVL_ERROR, |
77 |
_("logging plugin '%s' pre() failed"), |
|
960
by Brian Aker
Merging Monty |
78 |
(char *)plugin_name(plugin)); |
383.6.1
by Mark Atwood
add pluggable logging |
79 |
return true; |
499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
80 |
}
|
383.6.1
by Mark Atwood
add pluggable logging |
81 |
}
|
82 |
return false; |
|
83 |
}
|
|
84 |
||
499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
85 |
/* This is the logging_pre_do entry point.
|
86 |
This gets called by the rest of the Drizzle server code */
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
87 |
bool logging_pre_do (Session *session) |
383.6.1
by Mark Atwood
add pluggable logging |
88 |
{
|
499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
89 |
bool foreach_rv; |
90 |
||
960
by Brian Aker
Merging Monty |
91 |
foreach_rv= plugin_foreach(session, logging_pre_iterate, DRIZZLE_LOGGER_PLUGIN, NULL); |
92 |
||
499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
93 |
return foreach_rv; |
383.6.1
by Mark Atwood
add pluggable logging |
94 |
}
|
95 |
||
499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
96 |
/* This gets called by plugin_foreach once for each loaded logging plugin */
|
779.3.1
by Monty Taylor
More cleanup. |
97 |
static bool logging_post_iterate (Session *session, plugin_ref plugin, void *) |
383.6.1
by Mark Atwood
add pluggable logging |
98 |
{
|
958.1.1
by Monty Taylor
Made logging plugin class based. |
99 |
Logging_handler *handler= plugin_data(plugin, Logging_handler *); |
383.6.1
by Mark Atwood
add pluggable logging |
100 |
|
958.1.1
by Monty Taylor
Made logging plugin class based. |
101 |
if (handler) |
383.6.1
by Mark Atwood
add pluggable logging |
102 |
{
|
958.1.1
by Monty Taylor
Made logging plugin class based. |
103 |
if (handler->post(session)) |
499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
104 |
{
|
105 |
/* TRANSLATORS: The leading word "logging" is the name
|
|
106 |
of the plugin api, and so should not be translated. */
|
|
958.1.1
by Monty Taylor
Made logging plugin class based. |
107 |
errmsg_printf(ERRMSG_LVL_ERROR, |
108 |
_("logging plugin '%s' post() failed"), |
|
109 |
(char *)plugin_name(plugin)); |
|
383.6.1
by Mark Atwood
add pluggable logging |
110 |
return true; |
499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
111 |
}
|
383.6.1
by Mark Atwood
add pluggable logging |
112 |
}
|
113 |
return false; |
|
114 |
}
|
|
115 |
||
499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
116 |
/* This is the logging_pre_do entry point.
|
117 |
This gets called by the rest of the Drizzle server code */
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
118 |
bool logging_post_do (Session *session) |
383.6.1
by Mark Atwood
add pluggable logging |
119 |
{
|
499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
120 |
bool foreach_rv; |
121 |
||
960
by Brian Aker
Merging Monty |
122 |
foreach_rv= plugin_foreach(session, logging_post_iterate, DRIZZLE_LOGGER_PLUGIN, NULL); |
123 |
||
499.2.14
by Mark Atwood
fixes as per MontyT's comments, prep for internationalization |
124 |
return foreach_rv; |
383.6.1
by Mark Atwood
add pluggable logging |
125 |
}
|