~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/logging.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-03-21 20:26:28 UTC
  • mto: (960.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 961.
  • Revision ID: osullivan.padraig@gmail.com-20090321202628-nh6qsi825m4d4av6
Removing the queues.[h,cc] files from the mysys directory. The only place
where they are needed now is in the MyISAM storage engine. Thus, I moved the
files there and updated the files in the MyISAM storage engine
appropriately.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
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
 
1
20
#include <drizzled/server_includes.h>
2
21
#include <drizzled/logging.h>
 
22
#include <drizzled/gettext.h>
3
23
 
4
24
int logging_initializer(st_plugin_int *plugin)
5
25
{
6
 
  logging_t *p;
7
 
 
8
 
  fprintf(stderr, "MRA %s plugin:%s dl:%s\n",
9
 
          __func__, plugin->name.str, plugin->plugin_dl->dl.str);
10
 
 
11
 
  p= (logging_t *) malloc(sizeof(logging_t));
12
 
  if (p == NULL) return 1;
13
 
  memset(p, 0, sizeof(logging_t));
 
26
  Logging_handler *p;
 
27
 
 
28
  if (plugin->plugin->init)
 
29
  {
 
30
    if (plugin->plugin->init(&p))
 
31
    {
 
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",
 
35
                    plugin->name.str);
 
36
      return 1;
 
37
    }
 
38
  }
14
39
 
15
40
  plugin->data= (void *)p;
 
41
  plugin->state= PLUGIN_IS_READY;
16
42
 
17
 
  if (plugin->plugin->init)
18
 
  {
19
 
    if (plugin->plugin->init((void *)p))
20
 
    {
21
 
      sql_print_error("Logging plugin '%s' init function returned error.",
22
 
                      plugin->name.str);
23
 
      goto err;
24
 
    }
25
 
  }
26
43
  return 0;
27
 
 
28
 
err:
29
 
  free(p);
30
 
  return 1;
31
44
}
32
45
 
 
46
 
33
47
int logging_finalizer(st_plugin_int *plugin)
34
 
35
 
  logging_t *p = (logging_t *) plugin->data;
36
 
 
37
 
  fprintf(stderr, "MRA %s plugin:%s dl:%s\n",
38
 
          __func__, plugin->name.str, plugin->plugin_dl->dl.str);
 
48
{
 
49
  Logging_handler *p = static_cast<Logging_handler *>(plugin->data);
39
50
 
40
51
  if (plugin->plugin->deinit)
41
52
  {
42
53
    if (plugin->plugin->deinit((void *)p))
43
54
    {
44
 
      sql_print_error("Logging plugin '%s' deinit function returned error.",
45
 
                      plugin->name.str);
 
55
      /* TRANSLATORS: The leading word "logging" is the name
 
56
         of the plugin api, and so should not be translated. */
 
57
      errmsg_printf(ERRMSG_LVL_ERROR, _("logging plugin '%s' deinit() failed"),
 
58
                      plugin->name.str);
46
59
    }
47
60
  }
48
61
 
49
 
  if (p) free(p);
50
 
 
51
62
  return 0;
52
63
}
53
64
 
54
 
static bool logging_pre_iterate (THD *thd, plugin_ref plugin,
55
 
                                 void *stuff __attribute__ ((__unused__)))
56
 
{
57
 
  logging_t *l= plugin_data(plugin, logging_t *);
58
 
 
59
 
  if (l && l->logging_pre)
60
 
  {
61
 
    if (l->logging_pre(thd))
62
 
      return true;
63
 
  }
64
 
  return false;
65
 
}
66
 
 
67
 
void logging_pre_do (THD *thd)
68
 
{
69
 
  if (plugin_foreach(thd, logging_pre_iterate, DRIZZLE_LOGGER_PLUGIN, NULL))
70
 
  {
71
 
    sql_print_error("Logging plugin pre had an error.");
72
 
  }
73
 
  return;
74
 
}
75
 
 
76
 
static bool logging_post_iterate (THD *thd, plugin_ref plugin, 
77
 
                                  void *stuff __attribute__ ((__unused__)))
78
 
{
79
 
  logging_t *l= plugin_data(plugin, logging_t *);
80
 
 
81
 
  if (l && l->logging_post)
82
 
  {
83
 
    if (l->logging_post(thd))
84
 
      return true;
85
 
  }
86
 
  return false;
87
 
}
88
 
 
89
 
void logging_post_do (THD *thd)
90
 
{
91
 
  if (plugin_foreach(thd, logging_post_iterate, DRIZZLE_LOGGER_PLUGIN, NULL))
92
 
  {
93
 
    sql_print_error("Logging plugin post had an error.");
94
 
  }
95
 
  return;
 
65
/* This gets called by plugin_foreach once for each loaded logging plugin */
 
66
static bool logging_pre_iterate (Session *session, plugin_ref plugin, void *)
 
67
{
 
68
  Logging_handler *handler= plugin_data(plugin, Logging_handler *);
 
69
 
 
70
  /* call this loaded logging plugin's logging_pre function pointer */
 
71
  if (handler)
 
72
  {
 
73
    if (handler->pre(session))
 
74
    {
 
75
      /* TRANSLATORS: The leading word "logging" is the name
 
76
         of the plugin api, and so should not be translated. */
 
77
      errmsg_printf(ERRMSG_LVL_ERROR,
 
78
                    _("logging plugin '%s' pre() failed"),
 
79
                    (char *)plugin_name(plugin));
 
80
      return true;
 
81
    }
 
82
  }
 
83
  return false;
 
84
}
 
85
 
 
86
/* This is the logging_pre_do entry point.
 
87
   This gets called by the rest of the Drizzle server code */
 
88
bool logging_pre_do (Session *session)
 
89
{
 
90
  bool foreach_rv;
 
91
 
 
92
  foreach_rv= plugin_foreach(session, logging_pre_iterate, DRIZZLE_LOGGER_PLUGIN, NULL);
 
93
 
 
94
  return foreach_rv;
 
95
}
 
96
 
 
97
/* This gets called by plugin_foreach once for each loaded logging plugin */
 
98
static bool logging_post_iterate (Session *session, plugin_ref plugin, void *)
 
99
{
 
100
  Logging_handler *handler= plugin_data(plugin, Logging_handler *);
 
101
 
 
102
  if (handler)
 
103
  {
 
104
    if (handler->post(session))
 
105
    {
 
106
      /* TRANSLATORS: The leading word "logging" is the name
 
107
         of the plugin api, and so should not be translated. */
 
108
      errmsg_printf(ERRMSG_LVL_ERROR,
 
109
                    _("logging plugin '%s' post() failed"),
 
110
                                (char *)plugin_name(plugin));
 
111
      return true;
 
112
    }
 
113
  }
 
114
  return false;
 
115
}
 
116
 
 
117
/* This is the logging_pre_do entry point.
 
118
   This gets called by the rest of the Drizzle server code */
 
119
bool logging_post_do (Session *session)
 
120
{
 
121
  bool foreach_rv;
 
122
 
 
123
  foreach_rv= plugin_foreach(session, logging_post_iterate, DRIZZLE_LOGGER_PLUGIN, NULL);
 
124
 
 
125
  return foreach_rv;
96
126
}