1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Mark Atwood
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.
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.
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
1
20
#include <drizzled/server_includes.h>
2
21
#include <drizzled/logging.h>
22
#include <drizzled/gettext.h>
4
24
int logging_initializer(st_plugin_int *plugin)
8
fprintf(stderr, "MRA %s plugin:%s dl:%s\n",
9
__func__, plugin->name.str, plugin->plugin_dl->dl.str);
11
p= (logging_t *) malloc(sizeof(logging_t));
12
if (p == NULL) return 1;
13
memset(p, 0, sizeof(logging_t));
28
if (plugin->plugin->init)
30
if (plugin->plugin->init(&p))
32
/* TRANSLATORS: The leading word "logging" is the name
33
of the plugin api, and so should not be translated. */
34
errmsg_printf(ERRMSG_LVL_ERROR, "logging plugin '%s' init() failed",
15
40
plugin->data= (void *)p;
17
if (plugin->plugin->init)
19
if (plugin->plugin->init((void *)p))
21
sql_print_error("Logging plugin '%s' init function returned error.",
33
46
int logging_finalizer(st_plugin_int *plugin)
35
logging_t *p = (logging_t *) plugin->data;
37
fprintf(stderr, "MRA %s plugin:%s dl:%s\n",
38
__func__, plugin->name.str, plugin->plugin_dl->dl.str);
48
Logging_handler *p = static_cast<Logging_handler *>(plugin->data);
40
50
if (plugin->plugin->deinit)
42
52
if (plugin->plugin->deinit((void *)p))
44
sql_print_error("Logging plugin '%s' deinit function returned error.",
54
/* TRANSLATORS: The leading word "logging" is the name
55
of the plugin api, and so should not be translated. */
56
errmsg_printf(ERRMSG_LVL_ERROR, _("logging plugin '%s' deinit() failed"),
54
static bool logging_pre_iterate (THD *thd, plugin_ref plugin,
55
void *stuff __attribute__ ((__unused__)))
57
logging_t *l= plugin_data(plugin, logging_t *);
59
if (l && l->logging_pre)
61
if (l->logging_pre(thd))
67
void logging_pre_do (THD *thd)
69
if (plugin_foreach(thd, logging_pre_iterate, DRIZZLE_LOGGER_PLUGIN, NULL))
71
sql_print_error("Logging plugin pre had an error.");
76
static bool logging_post_iterate (THD *thd, plugin_ref plugin,
77
void *stuff __attribute__ ((__unused__)))
79
logging_t *l= plugin_data(plugin, logging_t *);
81
if (l && l->logging_post)
83
if (l->logging_post(thd))
89
void logging_post_do (THD *thd)
91
if (plugin_foreach(thd, logging_post_iterate, DRIZZLE_LOGGER_PLUGIN, NULL))
93
sql_print_error("Logging plugin post had an error.");
64
/* This gets called by plugin_foreach once for each loaded logging plugin */
65
static bool logging_pre_iterate (Session *session, plugin_ref plugin, void *)
67
Logging_handler *handler= plugin_data(plugin, Logging_handler *);
69
/* call this loaded logging plugin's logging_pre function pointer */
72
if (handler->pre(session))
74
/* TRANSLATORS: The leading word "logging" is the name
75
of the plugin api, and so should not be translated. */
76
errmsg_printf(ERRMSG_LVL_ERROR,
77
_("logging plugin '%s' pre() failed"),
78
(char *)plugin_name(plugin));
85
/* This is the logging_pre_do entry point.
86
This gets called by the rest of the Drizzle server code */
87
bool logging_pre_do (Session *session)
91
foreach_rv= plugin_foreach(session, logging_pre_iterate, DRIZZLE_LOGGER_PLUGIN, NULL);
96
/* This gets called by plugin_foreach once for each loaded logging plugin */
97
static bool logging_post_iterate (Session *session, plugin_ref plugin, void *)
99
Logging_handler *handler= plugin_data(plugin, Logging_handler *);
103
if (handler->post(session))
105
/* TRANSLATORS: The leading word "logging" is the name
106
of the plugin api, and so should not be translated. */
107
errmsg_printf(ERRMSG_LVL_ERROR,
108
_("logging plugin '%s' post() failed"),
109
(char *)plugin_name(plugin));
116
/* This is the logging_pre_do entry point.
117
This gets called by the rest of the Drizzle server code */
118
bool logging_post_do (Session *session)
122
foreach_rv= plugin_foreach(session, logging_post_iterate, DRIZZLE_LOGGER_PLUGIN, NULL);