~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/logging_gearman/logging_gearman.cc

  • Committer: Brian Aker
  • Date: 2010-12-24 21:27:54 UTC
  • mto: (2035.1.1 clean)
  • mto: This revision was merged to the branch mainline in revision 2037.
  • Revision ID: brian@tangent.org-20101224212754-85xvjullymvhibr9
Merge in cast() for BOOLEAN.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
 
20
#include "config.h"
21
21
 
22
22
#include <boost/scoped_array.hpp>
23
23
 
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>
182
181
 
183
182
    if (gearman_client_create(&_gearman_client) == NULL)
184
183
    {
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"),
 
187
                              errmsg);
186
188
      return;
187
189
    }
188
190
 
192
194
                                   host.c_str(), 0);
193
195
    if (ret != GEARMAN_SUCCESS)
194
196
    {
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));
197
199
      return;
198
200
    }
223
225
    if (not _gearman_client_ok)
224
226
        return false;
225
227
  
226
 
    /* 
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.
230
 
    */
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 */
 
231
  
 
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();
232
235
  
233
236
 
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
266
269
               );
267
270
  
268
271
    char job_handle[GEARMAN_JOB_HANDLE_SIZE];
297
300
{
298
301
  context("host",
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"));
304
307
}
305
308
 
306
309
} /* namespace drizzle_plugin */