~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/syslog/logging.cc

  • Committer: Brian Aker
  • Date: 2011-10-19 19:30:54 UTC
  • mto: This revision was merged to the branch mainline in revision 2444.
  • Revision ID: brian@tangent.org-20111019193054-pxnb4hflrmbfhmbm
Fix level_t to be more inline with syslog

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include <config.h>
22
22
 
23
 
#include <stdarg.h>
 
23
#include <cstdarg>
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>
36
37
 
37
38
#include "logging.h"
38
39
#include "wrap.h"
40
41
namespace drizzle_plugin {
41
42
 
42
43
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())),
50
49
  _threshold_slow(threshold_slow),
51
50
  _threshold_big_resultset(threshold_big_resultset),
52
51
  _threshold_big_examined(threshold_big_examined)
58
57
                            facility.c_str());
59
58
    _facility= WrapSyslog::getFacilityByName("local0");
60
59
  }
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
 
  }
69
60
}
70
61
 
71
62
 
75
66
 
76
67
  // return if query was not too small
77
68
  if (session->sent_row_count < _threshold_big_resultset)
 
69
  {
78
70
    return false;
 
71
  }
 
72
 
79
73
  if (session->examined_row_count < _threshold_big_examined)
 
74
  {
80
75
    return false;
 
76
  }
81
77
 
82
78
  /*
83
79
    TODO, the session object should have a "utime command completed"
88
84
 
89
85
  // return if query was not too slow
90
86
  if (session->times.getElapsedTime() < _threshold_slow)
 
87
  {
91
88
    return false;
 
89
  }
92
90
 
93
91
  drizzled::Session::QueryString query_string(session->getQueryString());
94
92
  drizzled::util::string::ptr schema(session->schema());
95
93
 
96
94
  WrapSyslog::singleton()
97
 
    .log(_facility, _priority,
 
95
    .log(_facility, drizzled::error::INFO,
98
96
         "thread_id=%ld query_id=%ld"
99
97
         " db=\"%.*s\""
100
98
         " query=\"%.*s\""