~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/logging.cc

  • Committer: Eric Day
  • Date: 2009-03-24 04:59:05 UTC
  • mfrom: (962 drizzle)
  • mto: (968.1.1 lib-merge)
  • mto: This revision was merged to the branch mainline in revision 969.
  • Revision ID: eday@oddments.org-20090324045905-2ptqhz3ves0aa5ed
Merged trunk.

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
  }
98
89
{
99
90
  bool foreach_rv;
100
91
 
101
 
  foreach_rv= plugin_foreach(session,
102
 
                             logging_pre_iterate,
103
 
                             DRIZZLE_LOGGER_PLUGIN,
104
 
                             NULL);
 
92
  foreach_rv= plugin_foreach(session, logging_pre_iterate, DRIZZLE_LOGGER_PLUGIN, NULL);
 
93
 
105
94
  return foreach_rv;
106
95
}
107
96
 
108
97
/* This gets called by plugin_foreach once for each loaded logging plugin */
109
98
static bool logging_post_iterate (Session *session, plugin_ref plugin, void *)
110
99
{
111
 
  logging_t *l= plugin_data(plugin, logging_t *);
 
100
  Logging_handler *handler= plugin_data(plugin, Logging_handler *);
112
101
 
113
 
  if (l && l->logging_post)
 
102
  if (handler)
114
103
  {
115
 
    if (l->logging_post(session))
 
104
    if (handler->post(session))
116
105
    {
117
106
      /* TRANSLATORS: The leading word "logging" is the name
118
107
         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));
 
108
      errmsg_printf(ERRMSG_LVL_ERROR,
 
109
                    _("logging plugin '%s' post() failed"),
 
110
                                (char *)plugin_name(plugin));
121
111
      return true;
122
112
    }
123
113
  }
130
120
{
131
121
  bool foreach_rv;
132
122
 
133
 
  foreach_rv= plugin_foreach(session,
134
 
                             logging_post_iterate,
135
 
                             DRIZZLE_LOGGER_PLUGIN,
136
 
                             NULL);
 
123
  foreach_rv= plugin_foreach(session, logging_post_iterate, DRIZZLE_LOGGER_PLUGIN, NULL);
 
124
 
137
125
  return foreach_rv;
138
126
}