~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/logging.cc

Moved service stuff into plugin/

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 */
19
19
 
20
20
#include <drizzled/server_includes.h>
21
 
#include <drizzled/service/logging.h>
 
21
#include <drizzled/plugin/logging.h>
22
22
#include <drizzled/gettext.h>
23
23
#include "drizzled/plugin/registry.h"
24
24
 
25
25
#include <vector>
26
26
 
27
 
using namespace drizzled;
28
27
using namespace std;
29
28
 
30
 
void service::Logging::add(plugin::Logging *handler)
 
29
namespace drizzled
 
30
{
 
31
 
 
32
vector<plugin::Logging *> all_loggers;
 
33
 
 
34
 
 
35
void plugin::Logging::add(plugin::Logging *handler)
31
36
{
32
37
  if (handler != NULL)
33
38
    all_loggers.push_back(handler);
34
39
}
35
40
 
36
 
void service::Logging::remove(plugin::Logging *handler)
 
41
void plugin::Logging::remove(plugin::Logging *handler)
37
42
{
38
43
  if (handler != NULL)
39
44
    all_loggers.erase(find(all_loggers.begin(), all_loggers.end(), handler));
40
45
}
41
46
 
42
47
 
43
 
namespace drizzled
44
 
{
45
 
namespace service
46
 
{
47
 
namespace logging_priv
48
 
{
49
 
 
50
48
class PreIterate : public unary_function<plugin::Logging *, bool>
51
49
{
52
50
  Session *session;
95
93
  }
96
94
};
97
95
 
98
 
} /* namespace logging_priv */
99
 
} /* namespace service */
100
 
} /* namespace drizzled */
101
 
 
102
96
 
103
97
/* This is the logging_pre_do entry point.
104
98
   This gets called by the rest of the Drizzle server code */
105
 
bool service::Logging::pre_do(Session *session)
 
99
bool plugin::Logging::pre_do(Session *session)
106
100
{
107
101
  /* Use find_if instead of foreach so that we can collect return codes */
108
102
  vector<plugin::Logging *>::iterator iter=
109
103
    find_if(all_loggers.begin(), all_loggers.end(),
110
 
            service::logging_priv::PreIterate(session)); 
 
104
            PreIterate(session)); 
111
105
  /* If iter is == end() here, that means that all of the plugins returned
112
106
   * false, which in this case means they all succeeded. Since we want to 
113
107
   * return false on success, we return the value of the two being != 
117
111
 
118
112
/* This is the logging_post_do entry point.
119
113
   This gets called by the rest of the Drizzle server code */
120
 
bool service::Logging::post_do(Session *session)
 
114
bool plugin::Logging::post_do(Session *session)
121
115
{
122
116
  /* Use find_if instead of foreach so that we can collect return codes */
123
117
  vector<plugin::Logging *>::iterator iter=
124
118
    find_if(all_loggers.begin(), all_loggers.end(),
125
 
            service::logging_priv::PostIterate(session)); 
 
119
            PostIterate(session)); 
126
120
  /* If iter is == end() here, that means that all of the plugins returned
127
121
   * false, which in this case means they all succeeded. Since we want to 
128
122
   * return false on success, we return the value of the two being != 
129
123
   */
130
124
  return iter != all_loggers.end();
131
125
}
 
126
 
 
127
} /* namespace drizzled */