~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/logging_query/logging_query.cc

  • Committer: Brian Aker
  • Date: 2010-07-19 21:09:30 UTC
  • mfrom: (1662.1.3 rollup)
  • Revision ID: brian@gaz-20100719210930-jikrvg3zjfxe41cw
Rolloup patch for Brian, Monty, VJ. Fixes debug build for PBMS, and merges
in additional changes for using boost.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include <fcntl.h>
30
30
#include <string>
31
31
#include <boost/format.hpp>
32
 
 
 
32
#include <boost/program_options.hpp>
 
33
#include <drizzled/module/option_map.h>
33
34
#include <cstdio>
34
35
 
 
36
namespace po= boost::program_options;
35
37
using namespace drizzled;
36
38
using namespace std;
37
39
 
302
304
 
303
305
static int logging_query_plugin_init(drizzled::module::Context &context)
304
306
{
 
307
 
 
308
  const module::option_map &vm= context.getOptions();
 
309
  if (vm.count("threshold-slow"))
 
310
  {
 
311
    if (sysvar_logging_query_threshold_slow > UINT32_MAX)
 
312
    {
 
313
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for threshold-slow"));
 
314
      exit(-1);
 
315
    }
 
316
  }
 
317
 
 
318
  if (vm.count("threshold-big-resultset"))
 
319
  {
 
320
    if (sysvar_logging_query_threshold_big_resultset > UINT32_MAX)
 
321
    {
 
322
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for threshold-big-resultset"));
 
323
      exit(-1);
 
324
    }
 
325
  }
 
326
 
 
327
  if (vm.count("threshold-big-examined"))
 
328
  {
 
329
    if (sysvar_logging_query_threshold_big_examined > UINT32_MAX)
 
330
    {
 
331
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for threshold-big-examined"));
 
332
      exit(-1);
 
333
    }
 
334
  }
305
335
  handler= new Logging_query();
306
336
  context.add(handler);
307
337
 
308
338
  return 0;
309
339
}
310
340
 
 
341
static void init_options(drizzled::module::option_context &context)
 
342
{
 
343
  context("enable",
 
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"));
 
355
}
 
356
 
311
357
static DRIZZLE_SYSVAR_BOOL(
312
358
  enable,
313
359
  sysvar_logging_query_enable,
384
430
DRIZZLE_DECLARE_PLUGIN
385
431
{
386
432
  DRIZZLE_VERSION_ID,
387
 
  "logging_query",
 
433
  "logging-query",
388
434
  "0.2",
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,
394
 
  NULL
 
440
  init_options
395
441
}
396
442
DRIZZLE_DECLARE_PLUGIN_END;