~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/logging.cc

  • Committer: Monty Taylor
  • Date: 2009-03-20 23:09:52 UTC
  • mto: (950.1.2 mordred)
  • mto: This revision was merged to the branch mainline in revision 960.
  • Revision ID: mordred@inaugust.com-20090320230952-y8ytum7yk91vi0vm
Made logging plugin class based.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
int logging_initializer(st_plugin_int *plugin)
25
25
{
26
 
  logging_t *p;
27
 
 
28
 
  p= new logging_t;
29
 
  if (p == NULL) return 1;
30
 
  memset(p, 0, sizeof(logging_t));
31
 
 
32
 
  plugin->data= (void *)p;
 
26
  Logging_handler *p;
33
27
 
34
28
  if (plugin->plugin->init)
35
29
  {
36
 
    if (plugin->plugin->init((void *)p))
 
30
    if (plugin->plugin->init(&p))
37
31
    {
38
32
      /* TRANSLATORS: The leading word "logging" is the name
39
33
         of the plugin api, and so should not be translated. */
40
34
      errmsg_printf(ERRMSG_LVL_ERROR, "logging plugin '%s' init() failed",
41
 
                      plugin->name.str);
42
 
      goto err;
 
35
                    plugin->name.str);
 
36
      return 1;
43
37
    }
44
38
  }
45
39
 
 
40
  plugin->data= (void *)p;
46
41
  plugin->state= PLUGIN_IS_READY;
47
42
 
48
43
  return 0;
49
 
 
50
 
err:
51
 
  delete p;
52
 
  return 1;
53
44
}
54
45
 
 
46
 
55
47
int logging_finalizer(st_plugin_int *plugin)
56
48
{
57
 
  logging_t *p = (logging_t *) plugin->data;
 
49
  Logging_handler *p = static_cast<Logging_handler *>(plugin->data);
58
50
 
59
51
  if (plugin->plugin->deinit)
60
52
  {
67
59
    }
68
60
  }
69
61
 
70
 
  if (p) delete p;
71
 
 
72
62
  return 0;
73
63
}
74
64
 
75
65
/* This gets called by plugin_foreach once for each loaded logging plugin */
76
66
static bool logging_pre_iterate (Session *session, plugin_ref plugin, void *)
77
67
{
78
 
  logging_t *l= plugin_data(plugin, logging_t *);
 
68
  Logging_handler *handler= plugin_data(plugin, Logging_handler *);
79
69
 
80
70
  /* call this loaded logging plugin's logging_pre function pointer */
81
 
  if (l && l->logging_pre)
 
71
  if (handler)
82
72
  {
83
 
    if (l->logging_pre(session))
 
73
    if (handler->pre(session))
84
74
    {
85
75
      /* TRANSLATORS: The leading word "logging" is the name
86
76
         of the plugin api, and so should not be translated. */
87
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("logging plugin '%s' logging_pre() failed"),
88
 
                      (char *)plugin_name(plugin));
 
77
      errmsg_printf(ERRMSG_LVL_ERROR,
 
78
                    _("logging plugin '%s' pre() failed"),
 
79
                                (char *)plugin_name(plugin));
89
80
      return true;
90
81
    }
91
82
  }
108
99
/* This gets called by plugin_foreach once for each loaded logging plugin */
109
100
static bool logging_post_iterate (Session *session, plugin_ref plugin, void *)
110
101
{
111
 
  logging_t *l= plugin_data(plugin, logging_t *);
 
102
  Logging_handler *handler= plugin_data(plugin, Logging_handler *);
112
103
 
113
 
  if (l && l->logging_post)
 
104
  if (handler)
114
105
  {
115
 
    if (l->logging_post(session))
 
106
    if (handler->post(session))
116
107
    {
117
108
      /* TRANSLATORS: The leading word "logging" is the name
118
109
         of the plugin api, and so should not be translated. */
119
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("logging plugin '%s' logging_post() failed"),
120
 
                      (char *)plugin_name(plugin));
 
110
      errmsg_printf(ERRMSG_LVL_ERROR,
 
111
                    _("logging plugin '%s' post() failed"),
 
112
                                (char *)plugin_name(plugin));
121
113
      return true;
122
114
    }
123
115
  }