17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#include <drizzled/plugin/logging.h>
20
#include <drizzled/server_includes.h>
21
#include <drizzled/plugin/logging_handler.h>
22
22
#include <drizzled/gettext.h>
23
23
#include <drizzled/session.h>
25
25
#include <libgearman/gearman.h>
28
#include <sys/types.h>
33
using namespace drizzled;
36
28
/* TODO make this dynamic as needed */
244
235
unsigned char qs[255];
246
237
// to avoid trying to printf %s something that is potentially NULL
247
const char *dbs= session->db.empty() ? "" : session->db.c_str();
238
const char *dbs= (session->db) ? session->db : "";
241
dbl= session->db_length;
250
246
snprintf(msgbuf, MAX_MSG_LEN,
251
247
"%"PRIu64",%"PRIu64",%"PRIu64",\"%.*s\",\"%s\",\"%.*s\","
252
248
"%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64","
253
"%"PRIu32",%"PRIu32",%"PRIu32",\"%s\"",
249
"%"PRIu32",%"PRIu32",%"PRIu32",\"%s\",%"PRIu32"",
255
251
session->thread_id,
256
252
session->getQueryId(),
257
253
// dont need to quote the db name, always CSV safe
258
(int)session->db.length(), dbs,
259
255
// do need to quote the query
260
quotify((const unsigned char *)session->getQueryString().c_str(),
256
quotify((unsigned char *)session->getQueryString(),
261
257
session->getQueryLength(), qs, sizeof(qs)),
262
258
// command_name is defined in drizzled/sql_parse.cc
263
259
// dont need to quote the command name, always CSV safe
291
static LoggingGearman *handler= NULL;
288
static Logging_handler *handler= NULL;
293
static int logging_gearman_plugin_init(plugin::Context &context)
290
static int logging_gearman_plugin_init(drizzled::plugin::Registry ®istry)
295
292
handler= new LoggingGearman();
296
context.add(handler);
293
registry.add(handler);
298
static int logging_gearman_plugin_deinit(drizzled::plugin::Registry ®istry)
300
registry.remove(handler);
325
330
NULL, /* update func*/
326
331
"drizzlelog" /* default */);
328
static drizzle_sys_var* logging_gearman_system_variables[]= {
333
static struct st_mysql_sys_var* logging_gearman_system_variables[]= {
329
334
DRIZZLE_SYSVAR(enable),
330
335
DRIZZLE_SYSVAR(host),
331
336
DRIZZLE_SYSVAR(function),
335
DRIZZLE_DECLARE_PLUGIN
340
drizzle_declare_plugin(logging_gearman)
338
342
"logging_gearman",
340
344
"Mark Atwood <mark@fallenpegasus.com>",
341
345
N_("Log queries to a Gearman server"),
342
346
PLUGIN_LICENSE_GPL,
343
347
logging_gearman_plugin_init,
348
logging_gearman_plugin_deinit,
349
NULL, /* status variables */
344
350
logging_gearman_system_variables,
347
DRIZZLE_DECLARE_PLUGIN_END;
353
drizzle_declare_plugin_end;