~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/logging_gearman/logging_gearman.cc

  • Committer: Lee Bieber
  • Date: 2010-11-20 01:33:21 UTC
  • mfrom: (1878.10.4 drizzle_bug665252)
  • Revision ID: kalebral@gmail.com-20101120013321-7nk9lq4nnr20zk6b
Merge Billy - removed my_getsysdate, my_micro_time and my_micro_time_and_time and replaced with boost::date_time for compatibility.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include <drizzled/plugin/logging.h>
25
25
#include <drizzled/gettext.h>
26
26
#include <drizzled/session.h>
 
27
#include <boost/date_time.hpp>
27
28
#include <boost/program_options.hpp>
28
29
#include <drizzled/module/option_map.h>
29
30
#include <libgearman/gearman.h>
30
31
#include <limits.h>
31
 
#include <sys/time.h>
32
32
#include <sys/types.h>
33
33
#include <sys/stat.h>
34
34
#include <fcntl.h>
46
46
static char* sysvar_logging_gearman_host= NULL;
47
47
static char* sysvar_logging_gearman_function= NULL;
48
48
 
49
 
 
50
 
/* stolen from mysys/my_getsystime
51
 
   until the Session has a good utime "now" we can use
52
 
   will have to use this instead */
53
 
 
54
 
static uint64_t get_microtime()
55
 
{
56
 
#if defined(HAVE_GETHRTIME)
57
 
  return gethrtime()/1000;
58
 
#else
59
 
  uint64_t newtime;
60
 
  struct timeval t;
61
 
  /*
62
 
    The following loop is here because gettimeofday may fail on some systems
63
 
  */
64
 
  while (gettimeofday(&t, NULL) != 0) {}
65
 
  newtime= (uint64_t)t.tv_sec * 1000000 + t.tv_usec;
66
 
  return newtime;
67
 
#endif  /* defined(HAVE_GETHRTIME) */
68
 
}
69
 
 
70
49
/* quote a string to be safe to include in a CSV line
71
50
   that means backslash quoting all commas, doublequotes, backslashes,
72
51
   and all the ASCII unprintable characters
246
225
       inside itself, so be more accurate, and so this doesnt have to
247
226
       keep calling current_utime, which can be slow */
248
227
  
249
 
    uint64_t t_mark= get_microtime();
 
228
    boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
 
229
    boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
 
230
    uint64_t t_mark= (mytime-epoch).total_microseconds();
250
231
  
 
232
 
251
233
    // buffer to quotify the query
252
234
    unsigned char qs[255];
253
235