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
=== modified file 'plugin/syslog/errmsg.cc'
--- plugin/syslog/errmsg.cc 2012-01-16 02:37:54 +0000
+++ plugin/syslog/errmsg.cc 2012-08-06 11:30:29 +0000
@@ -27,8 +27,8 @@
27#include <plugin/syslog/errmsg.h>27#include <plugin/syslog/errmsg.h>
28#include <plugin/syslog/wrap.h>28#include <plugin/syslog/wrap.h>
2929
30namespace drizzle_plugin30namespace drizzle_plugin {
31{31namespace syslog {
3232
33error_message::Syslog::Syslog(const std::string& facility) :33error_message::Syslog::Syslog(const std::string& facility) :
34 drizzled::plugin::ErrorMessage("syslog_error_message"),34 drizzled::plugin::ErrorMessage("syslog_error_message"),
@@ -49,4 +49,5 @@
49 return false;49 return false;
50}50}
5151
52} /* namespace syslog */
52} /* namespace drizzle_plugin */53} /* namespace drizzle_plugin */
5354
=== modified file 'plugin/syslog/errmsg.h'
--- plugin/syslog/errmsg.h 2011-10-20 02:45:57 +0000
+++ plugin/syslog/errmsg.h 2012-08-06 11:30:29 +0000
@@ -22,10 +22,9 @@
22#include <stdarg.h>22#include <stdarg.h>
23#include <drizzled/plugin/error_message.h>23#include <drizzled/plugin/error_message.h>
2424
25namespace drizzle_plugin25namespace drizzle_plugin {
26{26namespace syslog {
27namespace error_message27namespace error_message {
28{
2928
30class Syslog : public drizzled::plugin::ErrorMessage29class Syslog : public drizzled::plugin::ErrorMessage
31{30{
@@ -38,6 +37,7 @@
38 virtual bool errmsg(drizzled::error::priority_t, const char *format, va_list ap);37 virtual bool errmsg(drizzled::error::priority_t, const char *format, va_list ap);
39};38};
4039
40} /* namespace syslog */
41} /* namespace error_message */41} /* namespace error_message */
42} /* namespace drizzle_plugin */42} /* namespace drizzle_plugin */
4343
4444
=== modified file 'plugin/syslog/function.cc'
--- plugin/syslog/function.cc 2011-10-20 02:45:57 +0000
+++ plugin/syslog/function.cc 2012-08-06 11:30:29 +0000
@@ -25,8 +25,8 @@
25#include <plugin/syslog/function.h>25#include <plugin/syslog/function.h>
26#include <plugin/syslog/wrap.h>26#include <plugin/syslog/wrap.h>
2727
28namespace drizzle_plugin28namespace drizzle_plugin {
29{29namespace syslog {
3030
31udf::Syslog::Syslog()31udf::Syslog::Syslog()
32 : Item_str_func()32 : Item_str_func()
@@ -73,4 +73,5 @@
73 return (n == 3);73 return (n == 3);
74}74}
7575
76} /* namespace syslog */
76} /* namespace drizzle_plugin */77} /* namespace drizzle_plugin */
7778
=== modified file 'plugin/syslog/function.h'
--- plugin/syslog/function.h 2011-08-14 17:13:26 +0000
+++ plugin/syslog/function.h 2012-08-06 11:30:29 +0000
@@ -24,6 +24,7 @@
24#include <drizzled/function/str/strfunc.h>24#include <drizzled/function/str/strfunc.h>
2525
26namespace drizzle_plugin {26namespace drizzle_plugin {
27namespace syslog {
27namespace udf {28namespace udf {
2829
29class Syslog : public drizzled::Item_str_func30class Syslog : public drizzled::Item_str_func
@@ -40,6 +41,7 @@
40};41};
4142
42} /* namespace udf */43} /* namespace udf */
44} /* namespace syslog */
43} /* namepsace drizzle_plugin */45} /* namepsace drizzle_plugin */
4446
4547
4648
=== modified file 'plugin/syslog/logging.cc'
--- plugin/syslog/logging.cc 2012-01-16 02:37:54 +0000
+++ plugin/syslog/logging.cc 2012-08-06 11:30:29 +0000
@@ -39,13 +39,18 @@
39#include "wrap.h"39#include "wrap.h"
4040
41namespace drizzle_plugin {41namespace drizzle_plugin {
42namespace syslog {
43using namespace drizzled;
44
45extern bool sysvar_logging_enable;
4246
43logging::Syslog::Syslog(const std::string &facility,47logging::Syslog::Syslog(const std::string &facility,
44 uint64_t threshold_slow,48 uint64_constraint threshold_slow,
45 uint64_t threshold_big_resultset,49 uint64_constraint threshold_big_resultset,
46 uint64_t threshold_big_examined) :50 uint64_constraint threshold_big_examined) :
47 drizzled::plugin::Logging("syslog_query_log"),51 drizzled::plugin::Logging("syslog_query_log"),
48 _facility(WrapSyslog::getFacilityByName(facility.c_str())),52 _facility(WrapSyslog::getFacilityByName(facility.c_str())),
53 sysvar_facility(facility),
49 _threshold_slow(threshold_slow),54 _threshold_slow(threshold_slow),
50 _threshold_big_resultset(threshold_big_resultset),55 _threshold_big_resultset(threshold_big_resultset),
51 _threshold_big_examined(threshold_big_examined)56 _threshold_big_examined(threshold_big_examined)
@@ -56,6 +61,7 @@
56 _("syslog facility \"%s\" not known, using \"local0\""),61 _("syslog facility \"%s\" not known, using \"local0\""),
57 facility.c_str());62 facility.c_str());
58 _facility= WrapSyslog::getFacilityByName("local0");63 _facility= WrapSyslog::getFacilityByName("local0");
64 sysvar_facility= "local0";
59 }65 }
60}66}
6167
@@ -74,7 +80,12 @@
74 {80 {
75 return false;81 return false;
76 }82 }
83
84 // return if query logging is not enabled
85 if (sysvar_logging_enable == false)
86 return false;
7787
88
78 /*89 /*
79 TODO, the session object should have a "utime command completed"90 TODO, the session object should have a "utime command completed"
80 inside itself, so be more accurate, and so this doesnt have to91 inside itself, so be more accurate, and so this doesnt have to
@@ -119,4 +130,22 @@
119 return false;130 return false;
120}131}
121132
133bool logging::Syslog::setFacility(std::string new_facility)
134{
135 int tmp_facility= WrapSyslog::getFacilityByName(new_facility.c_str());
136 if(tmp_facility>0)
137 {
138 _facility= tmp_facility;
139 sysvar_facility= new_facility;
140 return true;
141 }
142 return false;
143}
144
145std::string& logging::Syslog::getFacility()
146{
147 return sysvar_facility;
148}
149
150} /* namespace syslog */
122} /* namespsace drizzle_plugin */151} /* namespsace drizzle_plugin */
123152
=== modified file 'plugin/syslog/logging.h'
--- plugin/syslog/logging.h 2011-10-19 19:30:54 +0000
+++ plugin/syslog/logging.h 2012-08-06 11:30:29 +0000
@@ -22,28 +22,35 @@
2222
23#include <drizzled/plugin/logging.h>23#include <drizzled/plugin/logging.h>
2424
25namespace drizzle_plugin25namespace drizzle_plugin {
26{26namespace syslog {
27namespace logging27namespace logging {
28{
2928
30class Syslog: public drizzled::plugin::Logging29class Syslog: public drizzled::plugin::Logging
31{30{
32private:31private:
33 int _facility;32 int _facility;
34 uint64_t _threshold_slow;33 std::string sysvar_facility;
35 uint64_t _threshold_big_resultset;
36 uint64_t _threshold_big_examined;
3734
38public:35public:
39 Syslog(const std::string &facility,36 Syslog(const std::string &facility,
40 uint64_t threshold_slow,37 drizzled::uint64_constraint threshold_slow,
41 uint64_t threshold_big_resultset,38 drizzled::uint64_constraint threshold_big_resultset,
42 uint64_t threshold_big_examined);39 drizzled::uint64_constraint threshold_big_examined);
4340
41 /*
42 These variables are made public as, otherwise, we will have to make setter functions for each of these variables to change their value
43 at runtime or we will have to make these variables extern. Changing them to public ensures that they can be changed at runtime directly.
44 */
45 drizzled::uint64_constraint _threshold_slow;
46 drizzled::uint64_constraint _threshold_big_resultset;
47 drizzled::uint64_constraint _threshold_big_examined;
44 virtual bool post (drizzled::Session *session);48 virtual bool post (drizzled::Session *session);
49 bool setFacility(std::string new_facility);
50 std::string& getFacility();
45};51};
4652
47} /* namespace logging */53} /* namespace logging */
54} /* namespace syslog */
48} /* namespace drizzle_plugin */55} /* namespace drizzle_plugin */
4956
5057
=== modified file 'plugin/syslog/module.cc'
--- plugin/syslog/module.cc 2012-01-15 20:54:59 +0000
+++ plugin/syslog/module.cc 2012-08-06 11:30:29 +0000
@@ -19,6 +19,7 @@
1919
20#include <config.h>20#include <config.h>
2121
22#include <drizzled/item.h>
22#include <drizzled/plugin.h>23#include <drizzled/plugin.h>
23#include <drizzled/plugin/logging.h>24#include <drizzled/plugin/logging.h>
24#include <drizzled/plugin/error_message.h>25#include <drizzled/plugin/error_message.h>
@@ -36,16 +37,33 @@
36using namespace std;37using namespace std;
37using namespace drizzled;38using namespace drizzled;
3839
39namespace drizzle_plugin40namespace drizzle_plugin {
40{41namespace syslog {
4142
42static bool sysvar_logging_enable= false;43
44bool sysvar_logging_enable= false;
43static bool sysvar_errmsg_enable= true;45static bool sysvar_errmsg_enable= true;
46bool updateFacility(Session *, set_var *);
4447
45uint64_constraint sysvar_logging_threshold_slow;48uint64_constraint sysvar_logging_threshold_slow;
46uint64_constraint sysvar_logging_threshold_big_resultset;49uint64_constraint sysvar_logging_threshold_big_resultset;
47uint64_constraint sysvar_logging_threshold_big_examined;50uint64_constraint sysvar_logging_threshold_big_examined;
4851
52logging::Syslog *logging_syslog_handler = NULL;
53
54bool updateFacility(Session *, set_var* var)
55{
56 if (not var->value->str_value.empty())
57 {
58 std::string new_facility(var->value->str_value.data());
59 if (logging_syslog_handler->setFacility(new_facility))
60 return false; //success
61 else
62 return true; // error
63 }
64 errmsg_printf(error::ERROR, _("syslog_facility cannot be NULL"));
65 return true; // error
66}
4967
50static int init(drizzled::module::Context &context)68static int init(drizzled::module::Context &context)
51{69{
@@ -57,32 +75,25 @@
57 context.add(new error_message::Syslog(vm["facility"].as<string>()));75 context.add(new error_message::Syslog(vm["facility"].as<string>()));
58 }76 }
5977
60 if (sysvar_logging_enable)78 logging_syslog_handler = new logging::Syslog(vm["facility"].as<string>(),
61 {79 sysvar_logging_threshold_slow.get(),
62 context.add(new logging::Syslog(vm["facility"].as<string>(),80 sysvar_logging_threshold_big_resultset.get(),
63 sysvar_logging_threshold_slow.get(),81 sysvar_logging_threshold_big_examined.get());
64 sysvar_logging_threshold_big_resultset.get(),82 context.add(logging_syslog_handler);
65 sysvar_logging_threshold_big_examined.get()));
66 }
6783
68 context.add(new plugin::Create_function<udf::Syslog>("syslog"));84 context.add(new plugin::Create_function<udf::Syslog>("syslog"));
6985
70 context.registerVariable(new sys_var_const_string_val("facility",86 context.registerVariable(new sys_var_std_string("facility", logging_syslog_handler->getFacility(), NULL, &updateFacility));
71 vm["facility"].as<string>()));
72 context.registerVariable(new sys_var_const_string_val("errmsg_priority",87 context.registerVariable(new sys_var_const_string_val("errmsg_priority",
73 vm["errmsg-priority"].as<string>()));88 vm["errmsg-priority"].as<string>()));
74 context.registerVariable(new sys_var_const_string_val("logging_priority",89 context.registerVariable(new sys_var_const_string_val("logging_priority",
75 vm["logging-priority"].as<string>()));90 vm["logging-priority"].as<string>()));
76 context.registerVariable(new sys_var_bool_ptr_readonly("logging_enable",91 context.registerVariable(new sys_var_bool_ptr("logging_enable", &sysvar_logging_enable, NULL));
77 &sysvar_logging_enable));
78 context.registerVariable(new sys_var_bool_ptr_readonly("errmsg_enable",92 context.registerVariable(new sys_var_bool_ptr_readonly("errmsg_enable",
79 &sysvar_errmsg_enable));93 &sysvar_errmsg_enable));
80 context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("logging_threshold_slow",94 context.registerVariable(new sys_var_constrained_value<uint64_t>("logging_threshold_slow", logging_syslog_handler->_threshold_slow));
81 sysvar_logging_threshold_slow));95 context.registerVariable(new sys_var_constrained_value<uint64_t>("logging_threshold_big_resultset", logging_syslog_handler->_threshold_big_resultset));
82 context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("logging_threshold_big_resultset",96 context.registerVariable(new sys_var_constrained_value<uint64_t>("logging_threshold_big_examined", logging_syslog_handler->_threshold_big_examined));
83 sysvar_logging_threshold_big_resultset));
84 context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("logging_threshold_big_examined",
85 sysvar_logging_threshold_big_examined));
8697
87 return 0;98 return 0;
88}99}
@@ -119,6 +130,7 @@
119 _("Syslog Priority of error messages"));130 _("Syslog Priority of error messages"));
120}131}
121132
133} /* namespace syslog */
122} /* namespace drizzle_plugin */134} /* namespace drizzle_plugin */
123135
124DRIZZLE_DECLARE_PLUGIN136DRIZZLE_DECLARE_PLUGIN
@@ -129,8 +141,8 @@
129 "Mark Atwood",141 "Mark Atwood",
130 N_("Logs error messages and queries to syslog"),142 N_("Logs error messages and queries to syslog"),
131 PLUGIN_LICENSE_GPL,143 PLUGIN_LICENSE_GPL,
132 drizzle_plugin::init,144 drizzle_plugin::syslog::init,
133 NULL,145 NULL,
134 drizzle_plugin::init_options146 drizzle_plugin::syslog::init_options
135}147}
136DRIZZLE_DECLARE_PLUGIN_END;148DRIZZLE_DECLARE_PLUGIN_END;
137149
=== modified file 'plugin/syslog/wrap.cc'
--- plugin/syslog/wrap.cc 2011-10-20 02:45:57 +0000
+++ plugin/syslog/wrap.cc 2012-08-06 11:30:29 +0000
@@ -34,6 +34,7 @@
34#endif34#endif
3535
36namespace drizzle_plugin {36namespace drizzle_plugin {
37namespace syslog {
3738
38WrapSyslog::WrapSyslog () :39WrapSyslog::WrapSyslog () :
39 _check(false)40 _check(false)
@@ -101,4 +102,5 @@
101 va_end(ap);102 va_end(ap);
102}103}
103104
105} /* namespace syslog */
104} /* namespace drizzle_plugin */106} /* namespace drizzle_plugin */
105107
=== modified file 'plugin/syslog/wrap.h'
--- plugin/syslog/wrap.h 2011-10-20 02:45:57 +0000
+++ plugin/syslog/wrap.h 2012-08-06 11:30:29 +0000
@@ -26,6 +26,7 @@
26#include <drizzled/error/priority_t.h>26#include <drizzled/error/priority_t.h>
2727
28namespace drizzle_plugin {28namespace drizzle_plugin {
29namespace syslog {
2930
30class WrapSyslog31class WrapSyslog
31{32{
@@ -51,5 +52,6 @@
51 return handle;52 return handle;
52}53}
5354
55} /* namespace syslog */
54} /* namespsace drizzle_plugin */56} /* namespsace drizzle_plugin */
5557

Subscribers

People subscribed via source and target branches

to all changes: