31
31
#include <boost/format.hpp>
32
#include <boost/program_options.hpp>
33
#include <drizzled/module/option_map.h>
36
namespace po= boost::program_options;
35
37
using namespace drizzled;
36
38
using namespace std;
303
305
static int logging_query_plugin_init(drizzled::module::Context &context)
308
const module::option_map &vm= context.getOptions();
309
if (vm.count("threshold-slow"))
311
if (sysvar_logging_query_threshold_slow > UINT32_MAX)
313
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for threshold-slow"));
318
if (vm.count("threshold-big-resultset"))
320
if (sysvar_logging_query_threshold_big_resultset > UINT32_MAX)
322
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for threshold-big-resultset"));
327
if (vm.count("threshold-big-examined"))
329
if (sysvar_logging_query_threshold_big_examined > UINT32_MAX)
331
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for threshold-big-examined"));
305
335
handler= new Logging_query();
306
336
context.add(handler);
341
static void init_options(drizzled::module::option_context &context)
344
po::value<bool>(&sysvar_logging_query_enable)->default_value(false)->zero_tokens(),
345
N_("Enable logging to CSV file"));
346
context("threshold-slow",
347
po::value<unsigned long>(&sysvar_logging_query_threshold_slow)->default_value(0),
348
N_("Threshold for logging slow queries, in microseconds"));
349
context("threshold-big-resultset",
350
po::value<unsigned long>(&sysvar_logging_query_threshold_big_resultset)->default_value(0),
351
N_("Threshold for logging big queries, for rows returned"));
352
context("threshold-big-examined",
353
po::value<unsigned long>(&sysvar_logging_query_threshold_big_examined)->default_value(0),
354
N_("Threshold for logging big queries, for rows examined"));
311
357
static DRIZZLE_SYSVAR_BOOL(
313
359
sysvar_logging_query_enable,
384
430
DRIZZLE_DECLARE_PLUGIN
386
432
DRIZZLE_VERSION_ID,
389
435
"Mark Atwood <mark@fallenpegasus.com>",
390
436
N_("Log queries to a CSV file"),
391
437
PLUGIN_LICENSE_GPL,
392
438
logging_query_plugin_init,
393
439
logging_query_system_variables,
396
442
DRIZZLE_DECLARE_PLUGIN_END;