Merge lp:~ansharyan015/drizzle/syslog_dynamic into lp:drizzle

Proposed by Daniel Nichter
Status: Merged
Approved by: Brian Aker
Approved revision: 2569
Merged at revision: 2579
Proposed branch: lp:~ansharyan015/drizzle/syslog_dynamic
Merge into: lp:drizzle
Diff against target: 356 lines (+101/-45)
9 files modified
plugin/syslog/errmsg.cc (+3/-2)
plugin/syslog/errmsg.h (+4/-4)
plugin/syslog/function.cc (+3/-2)
plugin/syslog/function.h (+2/-0)
plugin/syslog/logging.cc (+32/-3)
plugin/syslog/logging.h (+18/-11)
plugin/syslog/module.cc (+35/-23)
plugin/syslog/wrap.cc (+2/-0)
plugin/syslog/wrap.h (+2/-0)
To merge this branch: bzr merge lp:~ansharyan015/drizzle/syslog_dynamic
Reviewer Review Type Date Requested Status
Daniel Nichter (community) code review Approve
Drizzle Merge Team Pending
Review via email: mp+114036@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Daniel Nichter (daniel-nichter) :
review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugin/syslog/errmsg.cc'
2--- plugin/syslog/errmsg.cc 2012-01-16 02:37:54 +0000
3+++ plugin/syslog/errmsg.cc 2012-08-06 11:30:29 +0000
4@@ -27,8 +27,8 @@
5 #include <plugin/syslog/errmsg.h>
6 #include <plugin/syslog/wrap.h>
7
8-namespace drizzle_plugin
9-{
10+namespace drizzle_plugin {
11+namespace syslog {
12
13 error_message::Syslog::Syslog(const std::string& facility) :
14 drizzled::plugin::ErrorMessage("syslog_error_message"),
15@@ -49,4 +49,5 @@
16 return false;
17 }
18
19+} /* namespace syslog */
20 } /* namespace drizzle_plugin */
21
22=== modified file 'plugin/syslog/errmsg.h'
23--- plugin/syslog/errmsg.h 2011-10-20 02:45:57 +0000
24+++ plugin/syslog/errmsg.h 2012-08-06 11:30:29 +0000
25@@ -22,10 +22,9 @@
26 #include <stdarg.h>
27 #include <drizzled/plugin/error_message.h>
28
29-namespace drizzle_plugin
30-{
31-namespace error_message
32-{
33+namespace drizzle_plugin {
34+namespace syslog {
35+namespace error_message {
36
37 class Syslog : public drizzled::plugin::ErrorMessage
38 {
39@@ -38,6 +37,7 @@
40 virtual bool errmsg(drizzled::error::priority_t, const char *format, va_list ap);
41 };
42
43+} /* namespace syslog */
44 } /* namespace error_message */
45 } /* namespace drizzle_plugin */
46
47
48=== modified file 'plugin/syslog/function.cc'
49--- plugin/syslog/function.cc 2011-10-20 02:45:57 +0000
50+++ plugin/syslog/function.cc 2012-08-06 11:30:29 +0000
51@@ -25,8 +25,8 @@
52 #include <plugin/syslog/function.h>
53 #include <plugin/syslog/wrap.h>
54
55-namespace drizzle_plugin
56-{
57+namespace drizzle_plugin {
58+namespace syslog {
59
60 udf::Syslog::Syslog()
61 : Item_str_func()
62@@ -73,4 +73,5 @@
63 return (n == 3);
64 }
65
66+} /* namespace syslog */
67 } /* namespace drizzle_plugin */
68
69=== modified file 'plugin/syslog/function.h'
70--- plugin/syslog/function.h 2011-08-14 17:13:26 +0000
71+++ plugin/syslog/function.h 2012-08-06 11:30:29 +0000
72@@ -24,6 +24,7 @@
73 #include <drizzled/function/str/strfunc.h>
74
75 namespace drizzle_plugin {
76+namespace syslog {
77 namespace udf {
78
79 class Syslog : public drizzled::Item_str_func
80@@ -40,6 +41,7 @@
81 };
82
83 } /* namespace udf */
84+} /* namespace syslog */
85 } /* namepsace drizzle_plugin */
86
87
88
89=== modified file 'plugin/syslog/logging.cc'
90--- plugin/syslog/logging.cc 2012-01-16 02:37:54 +0000
91+++ plugin/syslog/logging.cc 2012-08-06 11:30:29 +0000
92@@ -39,13 +39,18 @@
93 #include "wrap.h"
94
95 namespace drizzle_plugin {
96+namespace syslog {
97+using namespace drizzled;
98+
99+extern bool sysvar_logging_enable;
100
101 logging::Syslog::Syslog(const std::string &facility,
102- uint64_t threshold_slow,
103- uint64_t threshold_big_resultset,
104- uint64_t threshold_big_examined) :
105+ uint64_constraint threshold_slow,
106+ uint64_constraint threshold_big_resultset,
107+ uint64_constraint threshold_big_examined) :
108 drizzled::plugin::Logging("syslog_query_log"),
109 _facility(WrapSyslog::getFacilityByName(facility.c_str())),
110+ sysvar_facility(facility),
111 _threshold_slow(threshold_slow),
112 _threshold_big_resultset(threshold_big_resultset),
113 _threshold_big_examined(threshold_big_examined)
114@@ -56,6 +61,7 @@
115 _("syslog facility \"%s\" not known, using \"local0\""),
116 facility.c_str());
117 _facility= WrapSyslog::getFacilityByName("local0");
118+ sysvar_facility= "local0";
119 }
120 }
121
122@@ -74,7 +80,12 @@
123 {
124 return false;
125 }
126+
127+ // return if query logging is not enabled
128+ if (sysvar_logging_enable == false)
129+ return false;
130
131+
132 /*
133 TODO, the session object should have a "utime command completed"
134 inside itself, so be more accurate, and so this doesnt have to
135@@ -119,4 +130,22 @@
136 return false;
137 }
138
139+bool logging::Syslog::setFacility(std::string new_facility)
140+{
141+ int tmp_facility= WrapSyslog::getFacilityByName(new_facility.c_str());
142+ if(tmp_facility>0)
143+ {
144+ _facility= tmp_facility;
145+ sysvar_facility= new_facility;
146+ return true;
147+ }
148+ return false;
149+}
150+
151+std::string& logging::Syslog::getFacility()
152+{
153+ return sysvar_facility;
154+}
155+
156+} /* namespace syslog */
157 } /* namespsace drizzle_plugin */
158
159=== modified file 'plugin/syslog/logging.h'
160--- plugin/syslog/logging.h 2011-10-19 19:30:54 +0000
161+++ plugin/syslog/logging.h 2012-08-06 11:30:29 +0000
162@@ -22,28 +22,35 @@
163
164 #include <drizzled/plugin/logging.h>
165
166-namespace drizzle_plugin
167-{
168-namespace logging
169-{
170+namespace drizzle_plugin {
171+namespace syslog {
172+namespace logging {
173
174 class Syslog: public drizzled::plugin::Logging
175 {
176 private:
177 int _facility;
178- uint64_t _threshold_slow;
179- uint64_t _threshold_big_resultset;
180- uint64_t _threshold_big_examined;
181+ std::string sysvar_facility;
182
183 public:
184 Syslog(const std::string &facility,
185- uint64_t threshold_slow,
186- uint64_t threshold_big_resultset,
187- uint64_t threshold_big_examined);
188-
189+ drizzled::uint64_constraint threshold_slow,
190+ drizzled::uint64_constraint threshold_big_resultset,
191+ drizzled::uint64_constraint threshold_big_examined);
192+
193+ /*
194+ These variables are made public as, otherwise, we will have to make setter functions for each of these variables to change their value
195+ at runtime or we will have to make these variables extern. Changing them to public ensures that they can be changed at runtime directly.
196+ */
197+ drizzled::uint64_constraint _threshold_slow;
198+ drizzled::uint64_constraint _threshold_big_resultset;
199+ drizzled::uint64_constraint _threshold_big_examined;
200 virtual bool post (drizzled::Session *session);
201+ bool setFacility(std::string new_facility);
202+ std::string& getFacility();
203 };
204
205 } /* namespace logging */
206+} /* namespace syslog */
207 } /* namespace drizzle_plugin */
208
209
210=== modified file 'plugin/syslog/module.cc'
211--- plugin/syslog/module.cc 2012-01-15 20:54:59 +0000
212+++ plugin/syslog/module.cc 2012-08-06 11:30:29 +0000
213@@ -19,6 +19,7 @@
214
215 #include <config.h>
216
217+#include <drizzled/item.h>
218 #include <drizzled/plugin.h>
219 #include <drizzled/plugin/logging.h>
220 #include <drizzled/plugin/error_message.h>
221@@ -36,16 +37,33 @@
222 using namespace std;
223 using namespace drizzled;
224
225-namespace drizzle_plugin
226-{
227-
228-static bool sysvar_logging_enable= false;
229+namespace drizzle_plugin {
230+namespace syslog {
231+
232+
233+bool sysvar_logging_enable= false;
234 static bool sysvar_errmsg_enable= true;
235+bool updateFacility(Session *, set_var *);
236
237 uint64_constraint sysvar_logging_threshold_slow;
238 uint64_constraint sysvar_logging_threshold_big_resultset;
239 uint64_constraint sysvar_logging_threshold_big_examined;
240
241+logging::Syslog *logging_syslog_handler = NULL;
242+
243+bool updateFacility(Session *, set_var* var)
244+{
245+ if (not var->value->str_value.empty())
246+ {
247+ std::string new_facility(var->value->str_value.data());
248+ if (logging_syslog_handler->setFacility(new_facility))
249+ return false; //success
250+ else
251+ return true; // error
252+ }
253+ errmsg_printf(error::ERROR, _("syslog_facility cannot be NULL"));
254+ return true; // error
255+}
256
257 static int init(drizzled::module::Context &context)
258 {
259@@ -57,32 +75,25 @@
260 context.add(new error_message::Syslog(vm["facility"].as<string>()));
261 }
262
263- if (sysvar_logging_enable)
264- {
265- context.add(new logging::Syslog(vm["facility"].as<string>(),
266- sysvar_logging_threshold_slow.get(),
267- sysvar_logging_threshold_big_resultset.get(),
268- sysvar_logging_threshold_big_examined.get()));
269- }
270+ logging_syslog_handler = new logging::Syslog(vm["facility"].as<string>(),
271+ sysvar_logging_threshold_slow.get(),
272+ sysvar_logging_threshold_big_resultset.get(),
273+ sysvar_logging_threshold_big_examined.get());
274+ context.add(logging_syslog_handler);
275
276 context.add(new plugin::Create_function<udf::Syslog>("syslog"));
277
278- context.registerVariable(new sys_var_const_string_val("facility",
279- vm["facility"].as<string>()));
280+ context.registerVariable(new sys_var_std_string("facility", logging_syslog_handler->getFacility(), NULL, &updateFacility));
281 context.registerVariable(new sys_var_const_string_val("errmsg_priority",
282 vm["errmsg-priority"].as<string>()));
283 context.registerVariable(new sys_var_const_string_val("logging_priority",
284 vm["logging-priority"].as<string>()));
285- context.registerVariable(new sys_var_bool_ptr_readonly("logging_enable",
286- &sysvar_logging_enable));
287+ context.registerVariable(new sys_var_bool_ptr("logging_enable", &sysvar_logging_enable, NULL));
288 context.registerVariable(new sys_var_bool_ptr_readonly("errmsg_enable",
289 &sysvar_errmsg_enable));
290- context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("logging_threshold_slow",
291- sysvar_logging_threshold_slow));
292- context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("logging_threshold_big_resultset",
293- sysvar_logging_threshold_big_resultset));
294- context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("logging_threshold_big_examined",
295- sysvar_logging_threshold_big_examined));
296+ context.registerVariable(new sys_var_constrained_value<uint64_t>("logging_threshold_slow", logging_syslog_handler->_threshold_slow));
297+ context.registerVariable(new sys_var_constrained_value<uint64_t>("logging_threshold_big_resultset", logging_syslog_handler->_threshold_big_resultset));
298+ context.registerVariable(new sys_var_constrained_value<uint64_t>("logging_threshold_big_examined", logging_syslog_handler->_threshold_big_examined));
299
300 return 0;
301 }
302@@ -119,6 +130,7 @@
303 _("Syslog Priority of error messages"));
304 }
305
306+} /* namespace syslog */
307 } /* namespace drizzle_plugin */
308
309 DRIZZLE_DECLARE_PLUGIN
310@@ -129,8 +141,8 @@
311 "Mark Atwood",
312 N_("Logs error messages and queries to syslog"),
313 PLUGIN_LICENSE_GPL,
314- drizzle_plugin::init,
315+ drizzle_plugin::syslog::init,
316 NULL,
317- drizzle_plugin::init_options
318+ drizzle_plugin::syslog::init_options
319 }
320 DRIZZLE_DECLARE_PLUGIN_END;
321
322=== modified file 'plugin/syslog/wrap.cc'
323--- plugin/syslog/wrap.cc 2011-10-20 02:45:57 +0000
324+++ plugin/syslog/wrap.cc 2012-08-06 11:30:29 +0000
325@@ -34,6 +34,7 @@
326 #endif
327
328 namespace drizzle_plugin {
329+namespace syslog {
330
331 WrapSyslog::WrapSyslog () :
332 _check(false)
333@@ -101,4 +102,5 @@
334 va_end(ap);
335 }
336
337+} /* namespace syslog */
338 } /* namespace drizzle_plugin */
339
340=== modified file 'plugin/syslog/wrap.h'
341--- plugin/syslog/wrap.h 2011-10-20 02:45:57 +0000
342+++ plugin/syslog/wrap.h 2012-08-06 11:30:29 +0000
343@@ -26,6 +26,7 @@
344 #include <drizzled/error/priority_t.h>
345
346 namespace drizzle_plugin {
347+namespace syslog {
348
349 class WrapSyslog
350 {
351@@ -51,5 +52,6 @@
352 return handle;
353 }
354
355+} /* namespace syslog */
356 } /* namespsace drizzle_plugin */
357

Subscribers

People subscribed via source and target branches

to all changes: