Merge lp:~vjsamuel/drizzle/rplugin-syslog into lp:~drizzle-trunk/drizzle/development

Proposed by Vijay Samuel
Status: Merged
Merged at revision: 1686
Proposed branch: lp:~vjsamuel/drizzle/rplugin-syslog
Merge into: lp:~drizzle-trunk/drizzle/development
Diff against target: 136 lines (+106/-1)
1 file modified
plugin/syslog/module.cc (+106/-1)
To merge this branch: bzr merge lp:~vjsamuel/drizzle/rplugin-syslog
Reviewer Review Type Date Requested Status
Drizzle Merge Team Pending
Review via email: mp+31724@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugin/syslog/module.cc'
--- plugin/syslog/module.cc 2010-06-26 06:39:35 +0000
+++ plugin/syslog/module.cc 2010-08-04 08:46:45 +0000
@@ -28,7 +28,12 @@
28#include "logging.h"28#include "logging.h"
29#include "errmsg.h"29#include "errmsg.h"
30#include "function.h"30#include "function.h"
31#include <iostream>
32#include <boost/program_options.hpp>
33#include <drizzled/module/option_map.h>
3134
35namespace po= boost::program_options;
36using namespace std;
32using namespace drizzled;37using namespace drizzled;
3338
34namespace syslog_module39namespace syslog_module
@@ -46,6 +51,75 @@
4651
47static int init(drizzled::module::Context &context)52static int init(drizzled::module::Context &context)
48{53{
54 const module::option_map &vm= context.getOptions();
55
56 if (vm.count("logging_threshold-slow"))
57 {
58 if (sysvar_logging_threshold_slow > ULONG_MAX)
59 {
60 errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for logging-threshold-slow\n"));
61 exit(-1);
62 }
63 }
64
65 if (vm.count("logging-threshold-big-resultset"))
66 {
67 if (sysvar_logging_threshold_big_resultset > 2)
68 {
69 errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for logging-threshold-big-resultset\n"));
70 exit(-1);
71 }
72 }
73
74 if (vm.count("logging-threshold-big-examined"))
75 {
76 if (sysvar_logging_threshold_big_examined > 2)
77 {
78 errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for logging-threshold-big-examined\n"));
79 exit(-1);
80 }
81 }
82
83 if (vm.count("ident"))
84 {
85 sysvar_ident= strdup(vm["ident"].as<string>().c_str());
86 }
87
88 else
89 {
90 sysvar_ident= strdup("drizzled");
91 }
92
93 if (vm.count("facility"))
94 {
95 sysvar_facility= strdup(vm["facility"].as<string>().c_str());
96 }
97
98 else
99 {
100 sysvar_facility= strdup("local0");
101 }
102
103 if (vm.count("logging-priority"))
104 {
105 sysvar_logging_priority= strdup(vm["logging-priority"].as<string>().c_str());
106 }
107
108 else
109 {
110 sysvar_logging_priority= strdup("info");
111 }
112
113 if (vm.count("errmsg-priority"))
114 {
115 sysvar_errmsg_priority= strdup(vm["errmsg-priority"].as<string>().c_str());
116 }
117
118 else
119 {
120 sysvar_errmsg_priority= strdup("warning");
121 }
122
49 context.add(new Logging_syslog());123 context.add(new Logging_syslog());
50 context.add(new ErrorMessage_syslog());124 context.add(new ErrorMessage_syslog());
51 context.add(new plugin::Create_function<Function_syslog>("syslog"));125 context.add(new plugin::Create_function<Function_syslog>("syslog"));
@@ -142,6 +216,37 @@
142 NULL, /* update func*/216 NULL, /* update func*/
143 "warning" /* default */);217 "warning" /* default */);
144218
219static void init_options(drizzled::module::option_context &context)
220{
221 context("ident",
222 po::value<string>(),
223 N_("Syslog Ident"));
224 context("facility",
225 po::value<string>(),
226 N_("Syslog Facility"));
227 context("logging-enable",
228 po::value<bool>(&sysvar_logging_enable)->default_value(false)->zero_tokens(),
229 N_("Enable logging to syslog of the query log"));
230 context("logging-priority",
231 po::value<string>(),
232 N_("Syslog Priority of query logging"));
233 context("logging-threshold-slow",
234 po::value<unsigned long>(&sysvar_logging_threshold_slow)->default_value(0),
235 N_("Threshold for logging slow queries, in microseconds"));
236 context("logging-threshold-big-resultset",
237 po::value<unsigned long>(&sysvar_logging_threshold_big_resultset)->default_value(0),
238 N_("Threshold for logging big queries, for rows returned"));
239 context("logging-threshold-big-examined",
240 po::value<unsigned long>(&sysvar_logging_threshold_big_examined)->default_value(0),
241 N_("Threshold for logging big queries, for rows examined"));
242 context("errmsg-enable",
243 po::value<bool>(&sysvar_errmsg_enable)->default_value(false)->zero_tokens(),
244 N_("Enable logging to syslog of the error messages"));
245 context("errmsg-priority",
246 po::value<string>(),
247 N_("Syslog Priority of error messages"));
248}
249
145static drizzle_sys_var* system_variables[]= {250static drizzle_sys_var* system_variables[]= {
146 DRIZZLE_SYSVAR(ident),251 DRIZZLE_SYSVAR(ident),
147 DRIZZLE_SYSVAR(facility),252 DRIZZLE_SYSVAR(facility),
@@ -157,4 +262,4 @@
157262
158} // namespace syslog_module263} // namespace syslog_module
159264
160DRIZZLE_PLUGIN(syslog_module::init, syslog_module::system_variables, NULL);265DRIZZLE_PLUGIN(syslog_module::init, syslog_module::system_variables, syslog_module::init_options);