~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/syslog/logging.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:
19
19
 */
20
20
 
21
21
#include "config.h"
22
 
 
 
22
#include <boost/date_time.hpp>
23
23
#include <drizzled/gettext.h>
24
24
#include <drizzled/session.h>
25
25
 
26
26
#include <stdarg.h>
27
27
#include <limits.h>
28
 
#include <sys/time.h>
29
28
#include <sys/types.h>
30
29
#include <sys/stat.h>
31
30
#include <fcntl.h>
35
34
 
36
35
using namespace drizzled;
37
36
 
38
 
/* stolen from mysys/my_getsystime
39
 
   until the Session has a good utime "now" we can use
40
 
   will have to use this instead */
41
 
 
42
 
static uint64_t get_microtime()
43
 
{
44
 
#if defined(HAVE_GETHRTIME)
45
 
  return gethrtime()/1000;
46
 
#else
47
 
  uint64_t newtime;
48
 
  struct timeval t;
49
 
  /* loop is because gettimeofday may fail on some systems */
50
 
  while (gettimeofday(&t, NULL) != 0) {}
51
 
  newtime= (uint64_t)t.tv_sec * 1000000 + t.tv_usec;
52
 
  return newtime;
53
 
#endif
54
 
}
55
 
 
56
37
Logging_syslog::Logging_syslog()
57
38
  : drizzled::plugin::Logging("Logging_syslog")
58
39
{
95
76
     inside itself, so be more accurate, and so this doesnt have to
96
77
     keep calling current_utime, which can be slow */
97
78
  
98
 
  uint64_t t_mark= get_microtime();
 
79
  boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
 
80
  boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
 
81
  uint64_t t_mark= (mytime-epoch).total_microseconds();
99
82
 
100
83
  // return if query was not too slow
101
84
  if ((t_mark - session->start_utime) < syslog_module::sysvar_logging_threshold_slow)