25 #include <sys/types.h>
29 #include <boost/date_time.hpp>
31 #include <drizzled/gettext.h>
32 #include <drizzled/session.h>
33 #include <drizzled/session/times.h>
34 #include <drizzled/sql_parse.h>
35 #include <drizzled/plugin.h>
36 #include <drizzled/error.h>
45 extern bool sysvar_logging_enable;
47 logging::Syslog::Syslog(
const std::string &facility,
52 _facility(WrapSyslog::getFacilityByName(facility.c_str())),
53 sysvar_facility(facility),
54 _threshold_slow(threshold_slow),
55 _threshold_big_resultset(threshold_big_resultset),
56 _threshold_big_examined(threshold_big_examined)
60 drizzled::errmsg_printf(drizzled::error::WARN,
61 _(
"syslog facility \"%s\" not known, using \"local0\""),
63 _facility= WrapSyslog::getFacilityByName(
"local0");
64 sysvar_facility=
"local0";
71 assert(session != NULL);
85 if (sysvar_logging_enable ==
false)
94 uint64_t t_mark= session->times.getCurrentTimestamp(
false);
97 if (session->times.getElapsedTime() < _threshold_slow)
103 drizzled::util::string::ptr schema(session->schema());
105 WrapSyslog::singleton()
106 .log(_facility, drizzled::error::INFO,
107 "thread_id=%ld query_id=%ld"
111 " t_connect=%lld t_start=%lld t_lock=%lld"
112 " rows_sent=%ld rows_examined=%ld"
113 " tmp_table=%ld total_warn_count=%ld\n",
114 (
unsigned long) session->thread_id,
116 (int) schema->size(),
117 schema->empty() ?
"" : schema->c_str(),
118 (int) query_string->length(),
119 query_string->empty() ?
"" : query_string->c_str(),
120 (int) drizzled::getCommandName(session->
command).size(),
121 drizzled::getCommandName(session->
command).c_str(),
122 (
unsigned long long) (t_mark - session->times.getConnectMicroseconds()),
123 (
unsigned long long) (session->times.getElapsedTime()),
124 (
unsigned long long) (t_mark - session->times.utime_after_lock),
127 (
unsigned long) session->tmp_table,
128 (
unsigned long) session->total_warn_count);
133 bool logging::Syslog::setFacility(std::string new_facility)
135 int tmp_facility= WrapSyslog::getFacilityByName(new_facility.c_str());
138 _facility= tmp_facility;
139 sysvar_facility= new_facility;
145 std::string& logging::Syslog::getFacility()
147 return sysvar_facility;
ha_rows examined_row_count
TODO: Rename this file - func.h is stupid.
boost::shared_ptr< const std::string > QueryString
query_id_t getQueryId() const
enum_server_command command