~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/logging.cc

  • Committer: Brian Aker
  • Date: 2009-04-13 16:22:40 UTC
  • mfrom: (971.1.78 mordred)
  • Revision ID: brian@gaz-20090413162240-ugi3gvhofmcuglzl
Merge Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include <drizzled/server_includes.h>
21
21
#include <drizzled/logging.h>
22
22
#include <drizzled/gettext.h>
 
23
#include "drizzled/plugin_registry.h"
 
24
 
23
25
#include <vector>
24
26
 
25
27
using namespace std;
26
28
 
27
29
static vector<Logging_handler *> all_loggers;
28
30
 
29
 
static void add_logger(Logging_handler *handler)
30
 
{
31
 
  all_loggers.push_back(handler);
32
 
}
33
 
 
34
 
static void remove_logger(Logging_handler *handler)
35
 
{
36
 
  all_loggers.erase(find(all_loggers.begin(), all_loggers.end(), handler));
37
 
}
38
 
 
39
 
int logging_initializer(st_plugin_int *plugin)
40
 
{
41
 
  Logging_handler *p= NULL;
42
 
 
43
 
  if (plugin->plugin->init)
44
 
  {
45
 
    if (plugin->plugin->init(&p))
46
 
    {
47
 
      /* TRANSLATORS: The leading word "logging" is the name
48
 
         of the plugin api, and so should not be translated. */
49
 
      errmsg_printf(ERRMSG_LVL_ERROR, "logging plugin '%s' init() failed",
50
 
                    plugin->name.str);
51
 
      return 1;
52
 
    }
53
 
  }
54
 
 
55
 
  if (p != NULL)
56
 
    add_logger(p);
57
 
  plugin->data= p;
58
 
 
59
 
  return 0;
60
 
}
61
 
 
62
 
 
63
 
int logging_finalizer(st_plugin_int *plugin)
64
 
{
65
 
  Logging_handler *p = static_cast<Logging_handler *>(plugin->data);
66
 
 
67
 
  if (p != NULL)
68
 
  {
69
 
    remove_logger(p);
70
 
 
71
 
    if (plugin->plugin->deinit)
72
 
    {
73
 
      if (plugin->plugin->deinit((void *)p))
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, _("logging plugin '%s' deinit() failed"),
78
 
                      plugin->name.str);
79
 
      }
80
 
    }
81
 
  }
82
 
 
83
 
  return 0;
84
 
}
 
31
void add_logger(Logging_handler *handler)
 
32
{
 
33
  if (handler != NULL)
 
34
    all_loggers.push_back(handler);
 
35
}
 
36
 
 
37
void remove_logger(Logging_handler *handler)
 
38
{
 
39
  if (handler != NULL)
 
40
    all_loggers.erase(find(all_loggers.begin(), all_loggers.end(), handler));
 
41
}
 
42
 
85
43
 
86
44
class LoggingPreIterate : public unary_function<Logging_handler *, bool>
87
45
{