~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/syslog/logging.cc

  • Committer: Mark Atwood
  • Date: 2011-10-08 04:50:51 UTC
  • mfrom: (2430.1.1 rf)
  • Revision ID: me@mark.atwood.name-20111008045051-6ha1qiy7k2a9c3jv
Tags: 2011.10.27
mergeĀ lp:~olafvdspek/drizzle/refactor2

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include <config.h>
22
22
 
23
 
#include <cstdarg>
 
23
#include <stdarg.h>
24
24
#include <limits.h>
25
25
#include <sys/types.h>
26
26
#include <sys/stat.h>
33
33
#include <drizzled/session/times.h>
34
34
#include <drizzled/sql_parse.h>
35
35
#include <drizzled/plugin.h>
36
 
#include <drizzled/error.h>
37
36
 
38
37
#include "logging.h"
39
38
#include "wrap.h"
41
40
namespace drizzle_plugin {
42
41
 
43
42
logging::Syslog::Syslog(const std::string &facility,
 
43
                        const std::string &priority,
44
44
                        uint64_t threshold_slow,
45
45
                        uint64_t threshold_big_resultset,
46
46
                        uint64_t threshold_big_examined) :
47
47
  drizzled::plugin::Logging("Syslog Logging"),
48
48
  _facility(WrapSyslog::getFacilityByName(facility.c_str())),
 
49
  _priority(WrapSyslog::getPriorityByName(priority.c_str())),
49
50
  _threshold_slow(threshold_slow),
50
51
  _threshold_big_resultset(threshold_big_resultset),
51
52
  _threshold_big_examined(threshold_big_examined)
57
58
                            facility.c_str());
58
59
    _facility= WrapSyslog::getFacilityByName("local0");
59
60
  }
 
61
 
 
62
  if (_priority < 0)
 
63
  {
 
64
    drizzled::errmsg_printf(drizzled::error::WARN,
 
65
                            _("syslog priority \"%s\" not known, using \"info\""),
 
66
                            priority.c_str());
 
67
    _priority= WrapSyslog::getPriorityByName("info");
 
68
  }
60
69
}
61
70
 
62
71
 
66
75
 
67
76
  // return if query was not too small
68
77
  if (session->sent_row_count < _threshold_big_resultset)
69
 
  {
70
78
    return false;
71
 
  }
72
 
 
73
79
  if (session->examined_row_count < _threshold_big_examined)
74
 
  {
75
80
    return false;
76
 
  }
77
81
 
78
82
  /*
79
83
    TODO, the session object should have a "utime command completed"
84
88
 
85
89
  // return if query was not too slow
86
90
  if (session->times.getElapsedTime() < _threshold_slow)
87
 
  {
88
91
    return false;
89
 
  }
90
92
 
91
93
  drizzled::Session::QueryString query_string(session->getQueryString());
92
94
  drizzled::util::string::ptr schema(session->schema());
93
95
 
94
96
  WrapSyslog::singleton()
95
 
    .log(_facility, drizzled::error::INFO,
 
97
    .log(_facility, _priority,
96
98
         "thread_id=%ld query_id=%ld"
97
99
         " db=\"%.*s\""
98
100
         " query=\"%.*s\""