~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/logging.cc

  • Committer: Stewart Smith
  • Date: 2009-10-19 04:17:38 UTC
  • mto: This revision was merged to the branch mainline in revision 1192.
  • Revision ID: stewart@flamingspork.com-20091019041738-bsjyzmittghcomqj
remove some unused PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP related things as errorcheck mutexes are never used (and haven't been since at least MySQL 4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
21
 
#include "drizzled/plugin/logging.h"
22
 
#include "drizzled/gettext.h"
23
 
#include "drizzled/errmsg_print.h"
 
20
#include <drizzled/server_includes.h>
 
21
#include <drizzled/plugin/logging.h>
 
22
#include <drizzled/gettext.h>
 
23
#include "drizzled/plugin/registry.h"
24
24
 
25
25
#include <vector>
26
 
#include <algorithm>
27
26
 
28
 
class Session;
 
27
using namespace std;
29
28
 
30
29
namespace drizzled
31
30
{
32
31
 
33
 
std::vector<plugin::Logging *> all_loggers;
 
32
vector<plugin::Logging *> all_loggers;
34
33
 
35
34
 
36
35
bool plugin::Logging::addPlugin(plugin::Logging *handler)
43
42
void plugin::Logging::removePlugin(plugin::Logging *handler)
44
43
{
45
44
  if (handler != NULL)
46
 
    all_loggers.erase(std::find(all_loggers.begin(), all_loggers.end(), handler));
 
45
    all_loggers.erase(find(all_loggers.begin(), all_loggers.end(), handler));
47
46
}
48
47
 
49
48
 
50
 
class PreIterate : public std::unary_function<plugin::Logging *, bool>
 
49
class PreIterate : public unary_function<plugin::Logging *, bool>
51
50
{
52
51
  Session *session;
53
52
public:
54
53
  PreIterate(Session *session_arg) :
55
 
    std::unary_function<plugin::Logging *, bool>(),
 
54
    unary_function<plugin::Logging *, bool>(),
56
55
    session(session_arg) {}
57
56
 
58
57
  inline result_type operator()(argument_type handler)
71
70
};
72
71
 
73
72
 
74
 
class PostIterate : public std::unary_function<plugin::Logging *, bool>
 
73
class PostIterate : public unary_function<plugin::Logging *, bool>
75
74
{
76
75
  Session *session;
77
76
public:
78
77
  PostIterate(Session *session_arg) :
79
 
    std::unary_function<plugin::Logging *, bool>(),
 
78
    unary_function<plugin::Logging *, bool>(),
80
79
    session(session_arg) {}
81
80
 
82
81
  /* This gets called once for each loaded logging plugin */
95
94
  }
96
95
};
97
96
 
98
 
class PostEndIterate : public std::unary_function<plugin::Logging *, bool>
99
 
{
100
 
  Session *session;
101
 
public:
102
 
  PostEndIterate(Session *session_arg) :
103
 
    std::unary_function<plugin::Logging *, bool>(),
104
 
    session(session_arg) {}
105
 
 
106
 
  /* This gets called once for each loaded logging plugin */
107
 
  inline result_type operator()(argument_type handler)
108
 
  {
109
 
    if (handler->postEnd(session))
110
 
    {
111
 
      /* TRANSLATORS: The leading word "logging" is the name
112
 
         of the plugin api, and so should not be translated. */
113
 
      errmsg_printf(ERRMSG_LVL_ERROR,
114
 
                    _("logging '%s' postEnd() failed"),
115
 
                    handler->getName().c_str());
116
 
      return true;
117
 
    }
118
 
    return false;
119
 
  }
120
 
};
121
 
 
122
 
class ResetIterate : public std::unary_function<plugin::Logging *, bool>
123
 
{
124
 
  Session *session;
125
 
public:
126
 
  ResetIterate(Session *session_arg) :
127
 
    std::unary_function<plugin::Logging *, bool>(),
128
 
    session(session_arg) {}
129
 
 
130
 
  inline result_type operator()(argument_type handler)
131
 
  {
132
 
    if (handler->resetGlobalScoreboard())
133
 
    {
134
 
      /* TRANSLATORS: The leading word "logging" is the name
135
 
         of the plugin api, and so should not be translated. */
136
 
      errmsg_printf(ERRMSG_LVL_ERROR,
137
 
                    _("logging '%s' resetCurrentScoreboard() failed"),
138
 
                    handler->getName().c_str());
139
 
      return true;
140
 
    }
141
 
    return false;
142
 
  }
143
 
};
144
 
 
145
97
 
146
98
/* This is the Logging::preDo entry point.
147
99
   This gets called by the rest of the Drizzle server code */
148
100
bool plugin::Logging::preDo(Session *session)
149
101
{
150
102
  /* Use find_if instead of foreach so that we can collect return codes */
151
 
  std::vector<plugin::Logging *>::iterator iter=
152
 
    std::find_if(all_loggers.begin(), all_loggers.end(),
153
 
                 PreIterate(session)); 
 
103
  vector<plugin::Logging *>::iterator iter=
 
104
    find_if(all_loggers.begin(), all_loggers.end(),
 
105
            PreIterate(session)); 
154
106
  /* If iter is == end() here, that means that all of the plugins returned
155
107
   * false, which in this case means they all succeeded. Since we want to 
156
108
   * return false on success, we return the value of the two being != 
163
115
bool plugin::Logging::postDo(Session *session)
164
116
{
165
117
  /* Use find_if instead of foreach so that we can collect return codes */
166
 
  std::vector<plugin::Logging *>::iterator iter=
167
 
    std::find_if(all_loggers.begin(), all_loggers.end(),
168
 
                 PostIterate(session)); 
 
118
  vector<plugin::Logging *>::iterator iter=
 
119
    find_if(all_loggers.begin(), all_loggers.end(),
 
120
            PostIterate(session)); 
169
121
  /* If iter is == end() here, that means that all of the plugins returned
170
122
   * false, which in this case means they all succeeded. Since we want to 
171
123
   * return false on success, we return the value of the two being != 
173
125
  return iter != all_loggers.end();
174
126
}
175
127
 
176
 
/* This gets called in the session destructor */
177
 
bool plugin::Logging::postEndDo(Session *session)
178
 
{
179
 
  /* Use find_if instead of foreach so that we can collect return codes */
180
 
  std::vector<plugin::Logging *>::iterator iter=
181
 
    std::find_if(all_loggers.begin(), all_loggers.end(),
182
 
                 PostEndIterate(session));
183
 
  /* If iter is == end() here, that means that all of the plugins returned
184
 
   * false, which in this case means they all succeeded. Since we want to
185
 
   * return false on success, we return the value of the two being !=
186
 
   */
187
 
  return iter != all_loggers.end();
188
 
}
189
 
 
190
 
/* Resets global stats for logging plugin */
191
 
bool plugin::Logging::resetStats(Session *session)
192
 
{
193
 
  std::vector<plugin::Logging *>::iterator iter=
194
 
    std::find_if(all_loggers.begin(), all_loggers.end(),
195
 
                 ResetIterate(session));
196
 
 
197
 
  return iter != all_loggers.end();
198
 
}
199
 
 
200
128
} /* namespace drizzled */