22 #include <drizzled/item.h>
23 #include <drizzled/plugin.h>
24 #include <drizzled/plugin/logging.h>
25 #include <drizzled/plugin/error_message.h>
26 #include <drizzled/plugin/function.h>
28 #include <plugin/syslog/wrap.h>
29 #include <plugin/syslog/logging.h>
30 #include <plugin/syslog/errmsg.h>
31 #include <plugin/syslog/function.h>
33 #include <boost/program_options.hpp>
36 namespace po= boost::program_options;
44 bool sysvar_logging_enable=
false;
45 static bool sysvar_errmsg_enable=
true;
52 logging::Syslog *logging_syslog_handler = NULL;
58 std::string new_facility(var->value->
str_value.data());
59 if (logging_syslog_handler->setFacility(new_facility))
64 errmsg_printf(error::ERROR, _(
"syslog_facility cannot be NULL"));
72 WrapSyslog::singleton().openlog(vm[
"ident"].as<string>());
73 if (sysvar_errmsg_enable)
75 context.add(
new error_message::Syslog(vm[
"facility"].as<string>()));
78 logging_syslog_handler =
new logging::Syslog(vm[
"facility"].as<string>(),
79 sysvar_logging_threshold_slow.get(),
80 sysvar_logging_threshold_big_resultset.get(),
81 sysvar_logging_threshold_big_examined.get());
82 context.add(logging_syslog_handler);
84 context.add(
new plugin::Create_function<udf::Syslog>(
"syslog"));
86 context.registerVariable(
new sys_var_std_string(
"facility", logging_syslog_handler->getFacility(), NULL, &updateFacility));
88 vm[
"errmsg-priority"].as<string>()));
90 vm[
"logging-priority"].as<string>()));
91 context.registerVariable(
new sys_var_bool_ptr(
"logging_enable", &sysvar_logging_enable, NULL));
93 &sysvar_errmsg_enable));
105 po::value<string>()->default_value(
"drizzled"),
108 po::value<string>()->default_value(
"local0"),
109 _(
"Syslog Facility"));
110 context(
"logging-enable",
111 po::value<bool>(&sysvar_logging_enable)->default_value(
false)->zero_tokens(),
112 _(
"Enable logging to syslog of the query log"));
113 context(
"logging-priority",
114 po::value<string>()->default_value(
"warning"),
115 _(
"Syslog Priority of query logging"));
116 context(
"logging-threshold-slow",
117 po::value<uint64_constraint>(&sysvar_logging_threshold_slow)->default_value(0),
118 _(
"Threshold for logging slow queries, in microseconds"));
119 context(
"logging-threshold-big-resultset",
120 po::value<uint64_constraint>(&sysvar_logging_threshold_big_resultset)->default_value(0),
121 _(
"Threshold for logging big queries, for rows returned"));
122 context(
"logging-threshold-big-examined",
123 po::value<uint64_constraint>(&sysvar_logging_threshold_big_examined)->default_value(0),
124 _(
"Threshold for logging big queries, for rows examined"));
125 context(
"errmsg-enable",
126 po::value<bool>(&sysvar_errmsg_enable)->default_value(
true)->zero_tokens(),
127 _(
"Enable logging to syslog of the error messages"));
128 context(
"errmsg-priority",
129 po::value<string>()->default_value(
"warning"),
130 _(
"Syslog Priority of error messages"));
136 DRIZZLE_DECLARE_PLUGIN
142 N_(
"Logs error messages and queries to syslog"),
144 drizzle_plugin::syslog::init,
146 drizzle_plugin::syslog::init_options
148 DRIZZLE_DECLARE_PLUGIN_END;
TODO: Rename this file - func.h is stupid.
An Proxy Wrapper around boost::program_options::variables_map.