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
1=== modified file 'plugin/syslog/module.cc'
2--- plugin/syslog/module.cc 2010-06-26 06:39:35 +0000
3+++ plugin/syslog/module.cc 2010-08-04 08:46:45 +0000
4@@ -28,7 +28,12 @@
5 #include "logging.h"
6 #include "errmsg.h"
7 #include "function.h"
8+#include <iostream>
9+#include <boost/program_options.hpp>
10+#include <drizzled/module/option_map.h>
11
12+namespace po= boost::program_options;
13+using namespace std;
14 using namespace drizzled;
15
16 namespace syslog_module
17@@ -46,6 +51,75 @@
18
19 static int init(drizzled::module::Context &context)
20 {
21+ const module::option_map &vm= context.getOptions();
22+
23+ if (vm.count("logging_threshold-slow"))
24+ {
25+ if (sysvar_logging_threshold_slow > ULONG_MAX)
26+ {
27+ errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for logging-threshold-slow\n"));
28+ exit(-1);
29+ }
30+ }
31+
32+ if (vm.count("logging-threshold-big-resultset"))
33+ {
34+ if (sysvar_logging_threshold_big_resultset > 2)
35+ {
36+ errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for logging-threshold-big-resultset\n"));
37+ exit(-1);
38+ }
39+ }
40+
41+ if (vm.count("logging-threshold-big-examined"))
42+ {
43+ if (sysvar_logging_threshold_big_examined > 2)
44+ {
45+ errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for logging-threshold-big-examined\n"));
46+ exit(-1);
47+ }
48+ }
49+
50+ if (vm.count("ident"))
51+ {
52+ sysvar_ident= strdup(vm["ident"].as<string>().c_str());
53+ }
54+
55+ else
56+ {
57+ sysvar_ident= strdup("drizzled");
58+ }
59+
60+ if (vm.count("facility"))
61+ {
62+ sysvar_facility= strdup(vm["facility"].as<string>().c_str());
63+ }
64+
65+ else
66+ {
67+ sysvar_facility= strdup("local0");
68+ }
69+
70+ if (vm.count("logging-priority"))
71+ {
72+ sysvar_logging_priority= strdup(vm["logging-priority"].as<string>().c_str());
73+ }
74+
75+ else
76+ {
77+ sysvar_logging_priority= strdup("info");
78+ }
79+
80+ if (vm.count("errmsg-priority"))
81+ {
82+ sysvar_errmsg_priority= strdup(vm["errmsg-priority"].as<string>().c_str());
83+ }
84+
85+ else
86+ {
87+ sysvar_errmsg_priority= strdup("warning");
88+ }
89+
90 context.add(new Logging_syslog());
91 context.add(new ErrorMessage_syslog());
92 context.add(new plugin::Create_function<Function_syslog>("syslog"));
93@@ -142,6 +216,37 @@
94 NULL, /* update func*/
95 "warning" /* default */);
96
97+static void init_options(drizzled::module::option_context &context)
98+{
99+ context("ident",
100+ po::value<string>(),
101+ N_("Syslog Ident"));
102+ context("facility",
103+ po::value<string>(),
104+ N_("Syslog Facility"));
105+ context("logging-enable",
106+ po::value<bool>(&sysvar_logging_enable)->default_value(false)->zero_tokens(),
107+ N_("Enable logging to syslog of the query log"));
108+ context("logging-priority",
109+ po::value<string>(),
110+ N_("Syslog Priority of query logging"));
111+ context("logging-threshold-slow",
112+ po::value<unsigned long>(&sysvar_logging_threshold_slow)->default_value(0),
113+ N_("Threshold for logging slow queries, in microseconds"));
114+ context("logging-threshold-big-resultset",
115+ po::value<unsigned long>(&sysvar_logging_threshold_big_resultset)->default_value(0),
116+ N_("Threshold for logging big queries, for rows returned"));
117+ context("logging-threshold-big-examined",
118+ po::value<unsigned long>(&sysvar_logging_threshold_big_examined)->default_value(0),
119+ N_("Threshold for logging big queries, for rows examined"));
120+ context("errmsg-enable",
121+ po::value<bool>(&sysvar_errmsg_enable)->default_value(false)->zero_tokens(),
122+ N_("Enable logging to syslog of the error messages"));
123+ context("errmsg-priority",
124+ po::value<string>(),
125+ N_("Syslog Priority of error messages"));
126+}
127+
128 static drizzle_sys_var* system_variables[]= {
129 DRIZZLE_SYSVAR(ident),
130 DRIZZLE_SYSVAR(facility),
131@@ -157,4 +262,4 @@
132
133 } // namespace syslog_module
134
135-DRIZZLE_PLUGIN(syslog_module::init, syslog_module::system_variables, NULL);
136+DRIZZLE_PLUGIN(syslog_module::init, syslog_module::system_variables, syslog_module::init_options);