~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/logging_gearman/logging_gearman.cc

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-10-02 14:17:48 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (2.1.17 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20101002141748-m6vbfbfjhrw1153e
Tags: 2010.09.1802-1
* New upstream release.
* Removed pid-file argument hack.
* Updated GPL-2 address to be new address.
* Directly copy in drizzledump.1 since debian doesn't have sphinx 1.0 yet.
* Link to jquery from libjs-jquery. Add it as a depend.
* Add drizzled.8 symlink to the install files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include <drizzled/plugin/logging.h>
22
22
#include <drizzled/gettext.h>
23
23
#include <drizzled/session.h>
24
 
 
 
24
#include <boost/program_options.hpp>
 
25
#include <drizzled/module/option_map.h>
25
26
#include <libgearman/gearman.h>
26
27
#include <limits.h>
27
28
#include <sys/time.h>
28
29
#include <sys/types.h>
29
30
#include <sys/stat.h>
30
31
#include <fcntl.h>
31
 
 
 
32
#include <cstdio>
 
33
#include <cerrno>
32
34
 
33
35
using namespace drizzled;
34
 
 
 
36
namespace po= boost::program_options;
35
37
 
36
38
/* TODO make this dynamic as needed */
37
39
static const int MAX_MSG_LEN= 32*1024;
38
40
 
39
 
static bool sysvar_logging_gearman_enable= false;
 
41
static bool sysvar_logging_gearman_enable;
40
42
static char* sysvar_logging_gearman_host= NULL;
41
43
static char* sysvar_logging_gearman_function= NULL;
42
44
 
192
194
 
193
195
    if (gearman_client_create(&gearman_client) == NULL)
194
196
    {
 
197
      char errmsg[STRERROR_MAX];
 
198
      strerror_r(errno, errmsg, sizeof(errmsg));
195
199
      errmsg_printf(ERRMSG_LVL_ERROR, _("fail gearman_client_create(): %s"),
196
 
                    strerror(errno));
 
200
                    errmsg);
197
201
      return;
198
202
    }
199
203
 
290
294
 
291
295
static LoggingGearman *handler= NULL;
292
296
 
293
 
static int logging_gearman_plugin_init(plugin::Registry &registry)
 
297
static int logging_gearman_plugin_init(module::Context &context)
294
298
{
295
299
  handler= new LoggingGearman();
296
 
  registry.add(handler);
 
300
  context.add(handler);
297
301
 
298
302
  return 0;
299
303
}
300
304
 
301
 
static int logging_gearman_plugin_deinit(plugin::Registry &registry)
 
305
static void init_options(drizzled::module::option_context &context)
302
306
{
303
 
  registry.remove(handler);
304
 
  delete handler;
305
 
 
306
 
  return 0;
 
307
  context("enable",
 
308
          po::value<bool>(&sysvar_logging_gearman_enable)->default_value(false)->zero_tokens(),
 
309
          N_("Enable logging to a gearman server"));
307
310
}
308
311
 
309
312
static DRIZZLE_SYSVAR_BOOL(
343
346
DRIZZLE_DECLARE_PLUGIN
344
347
{
345
348
  DRIZZLE_VERSION_ID,
346
 
    "logging_gearman",
 
349
    "logging-gearman",
347
350
    "0.1",
348
351
    "Mark Atwood <mark@fallenpegasus.com>",
349
352
    N_("Log queries to a Gearman server"),
350
353
    PLUGIN_LICENSE_GPL,
351
354
    logging_gearman_plugin_init,
352
 
    logging_gearman_plugin_deinit,
353
355
    logging_gearman_system_variables,
354
 
    NULL
 
356
    init_options
355
357
}
356
358
DRIZZLE_DECLARE_PLUGIN_END;