17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
22
#include <boost/scoped_array.hpp>
24
24
#include <drizzled/plugin/logging.h>
25
25
#include <drizzled/gettext.h>
26
26
#include <drizzled/session.h>
27
#include <drizzled/errmsg_print.h>
28
27
#include <boost/date_time.hpp>
29
28
#include <boost/program_options.hpp>
30
29
#include <drizzled/module/option_map.h>
183
182
if (gearman_client_create(&_gearman_client) == NULL)
185
drizzled::sql_perror(_("fail gearman_client_create()"));
184
char errmsg[STRERROR_MAX];
185
strerror_r(errno, errmsg, sizeof(errmsg));
186
drizzled::errmsg_printf(ERRMSG_LVL_ERROR, _("fail gearman_client_create(): %s"),
192
194
host.c_str(), 0);
193
195
if (ret != GEARMAN_SUCCESS)
195
drizzled::errmsg_printf(drizzled::error::ERROR, _("fail gearman_client_add_server(): %s"),
197
drizzled::errmsg_printf(ERRMSG_LVL_ERROR, _("fail gearman_client_add_server(): %s"),
196
198
gearman_client_error(&_gearman_client));
223
225
if (not _gearman_client_ok)
227
TODO, the session object should have a "utime command completed"
228
inside itself, so be more accurate, and so this doesnt have to
229
keep calling current_utime, which can be slow.
231
uint64_t t_mark= session->getCurrentTimestamp(false);
228
/* TODO, the session object should have a "utime command completed"
229
inside itself, so be more accurate, and so this doesnt have to
230
keep calling current_utime, which can be slow */
232
boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
233
boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
234
uint64_t t_mark= (mytime-epoch).total_microseconds();
234
237
// buffer to quotify the query
249
252
(int)dbs->size(), dbs->c_str(),
250
253
// do need to quote the query
251
254
quotify((const unsigned char *)session->getQueryString()->c_str(), session->getQueryString()->length(), qs, sizeof(qs)),
252
// getCommandName is defined in drizzled/sql_parse.h dont
253
// need to quote the command name, always CSV safe
254
(int)drizzled::getCommandName(session->command).size(),
255
drizzled::getCommandName(session->command).c_str(),
255
// command_name is defined in drizzled/sql_parse.cc
256
// dont need to quote the command name, always CSV safe
257
(int)drizzled::command_name[session->command].length,
258
drizzled::command_name[session->command].str,
256
259
// counters are at end, to make it easier to add more
257
260
(t_mark - session->getConnectMicroseconds()),
258
(session->getElapsedTime()),
261
(t_mark - session->start_utime),
259
262
(t_mark - session->utime_after_lock),
260
263
session->sent_row_count,
261
264
session->examined_row_count,
262
265
session->tmp_table,
263
266
session->total_warn_count,
264
267
session->getServerId(),
265
drizzled::getServerHostname().c_str()
268
drizzled::glob_hostname
268
271
char job_handle[GEARMAN_JOB_HANDLE_SIZE];
299
302
po::value<std::string>()->default_value("localhost"),
300
_("Hostname for logging to a Gearman server"));
303
N_("Hostname for logging to a Gearman server"));
301
304
context("function",
302
305
po::value<std::string>()->default_value("drizzlelog"),
303
_("Gearman Function to send logging to"));
306
N_("Gearman Function to send logging to"));
306
309
} /* namespace drizzle_plugin */