~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/logging.cc

  • Committer: Brian Aker
  • Date: 2010-12-18 10:14:05 UTC
  • mfrom: (2008.1.3 clean)
  • Revision ID: brian@tangent.org-20101218101405-qjbse29shi9coklg
Merge of user identifier work

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
class Session;
29
29
 
30
 
using namespace std;
31
 
 
32
30
namespace drizzled
33
31
{
34
32
 
35
 
vector<plugin::Logging *> all_loggers;
 
33
std::vector<plugin::Logging *> all_loggers;
36
34
 
37
35
 
38
36
bool plugin::Logging::addPlugin(plugin::Logging *handler)
45
43
void plugin::Logging::removePlugin(plugin::Logging *handler)
46
44
{
47
45
  if (handler != NULL)
48
 
    all_loggers.erase(find(all_loggers.begin(), all_loggers.end(), handler));
 
46
    all_loggers.erase(std::find(all_loggers.begin(), all_loggers.end(), handler));
49
47
}
50
48
 
51
49
 
52
 
class PreIterate : public unary_function<plugin::Logging *, bool>
 
50
class PreIterate : public std::unary_function<plugin::Logging *, bool>
53
51
{
54
52
  Session *session;
55
53
public:
56
54
  PreIterate(Session *session_arg) :
57
 
    unary_function<plugin::Logging *, bool>(),
 
55
    std::unary_function<plugin::Logging *, bool>(),
58
56
    session(session_arg) {}
59
57
 
60
58
  inline result_type operator()(argument_type handler)
73
71
};
74
72
 
75
73
 
76
 
class PostIterate : public unary_function<plugin::Logging *, bool>
 
74
class PostIterate : public std::unary_function<plugin::Logging *, bool>
77
75
{
78
76
  Session *session;
79
77
public:
80
78
  PostIterate(Session *session_arg) :
81
 
    unary_function<plugin::Logging *, bool>(),
 
79
    std::unary_function<plugin::Logging *, bool>(),
82
80
    session(session_arg) {}
83
81
 
84
82
  /* This gets called once for each loaded logging plugin */
97
95
  }
98
96
};
99
97
 
100
 
class PostEndIterate : public unary_function<plugin::Logging *, bool>
 
98
class PostEndIterate : public std::unary_function<plugin::Logging *, bool>
101
99
{
102
100
  Session *session;
103
101
public:
104
102
  PostEndIterate(Session *session_arg) :
105
 
    unary_function<plugin::Logging *, bool>(),
 
103
    std::unary_function<plugin::Logging *, bool>(),
106
104
    session(session_arg) {}
107
105
 
108
106
  /* This gets called once for each loaded logging plugin */
121
119
  }
122
120
};
123
121
 
124
 
class ResetIterate : public unary_function<plugin::Logging *, bool>
 
122
class ResetIterate : public std::unary_function<plugin::Logging *, bool>
125
123
{
126
124
  Session *session;
127
125
public:
128
126
  ResetIterate(Session *session_arg) :
129
 
    unary_function<plugin::Logging *, bool>(),
 
127
    std::unary_function<plugin::Logging *, bool>(),
130
128
    session(session_arg) {}
131
129
 
132
130
  inline result_type operator()(argument_type handler)
150
148
bool plugin::Logging::preDo(Session *session)
151
149
{
152
150
  /* Use find_if instead of foreach so that we can collect return codes */
153
 
  vector<plugin::Logging *>::iterator iter=
154
 
    find_if(all_loggers.begin(), all_loggers.end(),
155
 
            PreIterate(session)); 
 
151
  std::vector<plugin::Logging *>::iterator iter=
 
152
    std::find_if(all_loggers.begin(), all_loggers.end(),
 
153
                 PreIterate(session)); 
156
154
  /* If iter is == end() here, that means that all of the plugins returned
157
155
   * false, which in this case means they all succeeded. Since we want to 
158
156
   * return false on success, we return the value of the two being != 
165
163
bool plugin::Logging::postDo(Session *session)
166
164
{
167
165
  /* Use find_if instead of foreach so that we can collect return codes */
168
 
  vector<plugin::Logging *>::iterator iter=
169
 
    find_if(all_loggers.begin(), all_loggers.end(),
170
 
            PostIterate(session)); 
 
166
  std::vector<plugin::Logging *>::iterator iter=
 
167
    std::find_if(all_loggers.begin(), all_loggers.end(),
 
168
                 PostIterate(session)); 
171
169
  /* If iter is == end() here, that means that all of the plugins returned
172
170
   * false, which in this case means they all succeeded. Since we want to 
173
171
   * return false on success, we return the value of the two being != 
179
177
bool plugin::Logging::postEndDo(Session *session)
180
178
{
181
179
  /* Use find_if instead of foreach so that we can collect return codes */
182
 
  vector<plugin::Logging *>::iterator iter=
183
 
    find_if(all_loggers.begin(), all_loggers.end(),
184
 
            PostEndIterate(session));
 
180
  std::vector<plugin::Logging *>::iterator iter=
 
181
    std::find_if(all_loggers.begin(), all_loggers.end(),
 
182
                 PostEndIterate(session));
185
183
  /* If iter is == end() here, that means that all of the plugins returned
186
184
   * false, which in this case means they all succeeded. Since we want to
187
185
   * return false on success, we return the value of the two being !=
192
190
/* Resets global stats for logging plugin */
193
191
bool plugin::Logging::resetStats(Session *session)
194
192
{
195
 
  vector<plugin::Logging *>::iterator iter=
196
 
    find_if(all_loggers.begin(), all_loggers.end(),
197
 
            ResetIterate(session));
 
193
  std::vector<plugin::Logging *>::iterator iter=
 
194
    std::find_if(all_loggers.begin(), all_loggers.end(),
 
195
                 ResetIterate(session));
198
196
 
199
197
  return iter != all_loggers.end();
200
198
}