drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
drizzled::plugin::QueryLog Class Reference

QueryLog implements the query_log plugin. More...

#include <query_log.h>

Inheritance diagram for drizzled::plugin::QueryLog:
[legend]
Collaboration diagram for drizzled::plugin::QueryLog:
[legend]

Public Member Functions

 QueryLog (bool enabled, QueryLoggerFile *logger_file)
void registerSessionEventsDo (Session &session, EventObserverList &observers)
bool observeEventDo (EventData &)
bool afterStatement (AfterStatementEventData &data)
Public Member Functions inherited from drizzled::plugin::EventObserver
 EventObserver (std::string name_arg)
virtual void registerTableEventsDo (TableShare &, EventObserverList &)
virtual void registerSchemaEventsDo (const std::string &, EventObserverList &)
void registerEvent (EventObserverList &observers, EventType event, int32_t position=0)
Public Member Functions inherited from drizzled::plugin::Plugin
 Plugin (const std::string &name, const std::string &type_name)
virtual void shutdownPlugin ()
virtual void prime ()
virtual void startup (drizzled::Session &)
void activate ()
void deactivate ()
bool isActive () const
const std::string & getName () const
void setModule (module::Module *module)
const std::string & getTypeName () const
virtual bool removeLast () const
const std::string & getModuleName () const

Public Attributes

bool sysvar_enabled
bool sysvar_file_enabled
std::string sysvar_file
uint32_constraint sysvar_threshold_execution_time
uint32_constraint sysvar_threshold_lock_time
uint32_constraint sysvar_threshold_rows_examined
uint32_constraint sysvar_threshold_rows_sent
uint32_constraint sysvar_threshold_tmp_tables
uint32_constraint sysvar_threshold_warnings
uint32_constraint sysvar_threshold_session_time

Private Attributes

QueryLoggerFile * _logger_file
event_t _event

Additional Inherited Members

Public Types inherited from drizzled::plugin::EventObserver
enum  EventType {
  BEFORE_CREATE_DATABASE , AFTER_CREATE_DATABASE , BEFORE_DROP_DATABASE , AFTER_DROP_DATABASE ,
  CONNECT_SESSION , DISCONNECT_SESSION , AFTER_STATEMENT , BEFORE_STATEMENT ,
  BEFORE_DROP_TABLE , AFTER_DROP_TABLE , BEFORE_RENAME_TABLE , AFTER_RENAME_TABLE ,
  BEFORE_INSERT_RECORD , AFTER_INSERT_RECORD , BEFORE_UPDATE_RECORD , AFTER_UPDATE_RECORD ,
  BEFORE_DELETE_RECORD , AFTER_DELETE_RECORD , MAX_EVENT_COUNT
}
Public Types inherited from drizzled::plugin::Plugin
typedef std::pair< const std::string, const std::string > map_key
typedef std::unique_ptr< plugin::Plugin, deleter_fn > owned_ptr
typedef std::map< const map_key, owned_ptr > map
typedef std::vector< Plugin * > vector
Static Public Member Functions inherited from drizzled::plugin::EventObserver
static const char * eventName (EventType event)
static bool addPlugin (EventObserver &handler)
static void removePlugin (EventObserver &handler)
static void registerTableEvents (TableShare &table_share)
static void deregisterTableEvents (TableShare &table_share)
static void registerSchemaEvents (Session &session, const std::string &db)
static void deregisterSchemaEvents (EventObserverList *observers)
static void registerSessionEvents (Session &session)
static void deregisterSessionEvents (EventObserverList *observers)
static bool beforeDropTable (Session &session, const drizzled::identifier::Table &table)
static bool afterDropTable (Session &session, const drizzled::identifier::Table &table, int err)
static bool beforeRenameTable (Session &session, const drizzled::identifier::Table &from, const drizzled::identifier::Table &to)
static bool afterRenameTable (Session &session, const drizzled::identifier::Table &from, const drizzled::identifier::Table &to, int err)
static bool connectSession (Session &session)
static bool disconnectSession (Session &session)
static bool beforeStatement (Session &session)
static bool afterStatement (Session &session)
static bool beforeInsertRecord (Table &table, unsigned char *buf)
static bool afterInsertRecord (Table &table, const unsigned char *buf, int err)
static bool beforeDeleteRecord (Table &table, const unsigned char *buf)
static bool afterDeleteRecord (Table &table, const unsigned char *buf, int err)
static bool beforeUpdateRecord (Table &table, const unsigned char *old_data, unsigned char *new_data)
static bool afterUpdateRecord (Table &table, const unsigned char *old_data, unsigned char *new_data, int err)
static bool beforeCreateDatabase (Session &session, const std::string &db)
static bool afterCreateDatabase (Session &session, const std::string &db, int err)
static bool beforeDropDatabase (Session &session, const std::string &db)
static bool afterDropDatabase (Session &session, const std::string &db, int err)
static const EventObserverVector & getEventObservers (void)

Detailed Description

QueryLog implements the query_log plugin.

This is our event observer plugin subclass that sits between Drizzle and logger classes like QueryLoggerFile. This class encapsulates and manages data associated with the plugin: system variables and incoming events. The future plan is to have other logger classes, like QueryLoggerTable or QueryLoggerUDPSocket. So implemeting those should be easy because this class abstracts plugin data management from actual logging: it gets events from Drizzle, filters and prepares them, then sends them to logger classes which only have to log them.

Definition at line 43 of file query_log.h.

Constructor & Destructor Documentation

◆ QueryLog()

QueryLog::QueryLog ( bool enabled,
QueryLoggerFile * logger_file )

Definition at line 34 of file query_log.cc.

Member Function Documentation

◆ afterStatement()

bool QueryLog::afterStatement ( AfterStatementEventData & data)

Time values, first in microseconds so we can check the thresholds.

Check thresholds as soon as possible, return early if possible. This avoid unnecessary work; i.e. don't construct the whole event only to throw it away at the end because it fails a threshold.

Convert from microseconds to seconds, e.g. 42 to 0.000042 This is done for the user who may read the log. It's a lot easier to see half a second as 0.5 than 500000.

Integer values

Boolean values, as strings

String values, may be blank

The query string

Timestamp values, convert from microseconds from epoch to ISO timestamp like 2002-01-31T10:00:01.123456

Definition at line 65 of file query_log.cc.

◆ observeEventDo()

bool QueryLog::observeEventDo ( EventData & data)
virtual

Implements drizzled::plugin::EventObserver.

Definition at line 46 of file query_log.cc.

◆ registerSessionEventsDo()

void QueryLog::registerSessionEventsDo ( Session & session,
EventObserverList & observers )
virtual

Reimplemented from drizzled::plugin::EventObserver.

Definition at line 41 of file query_log.cc.

Member Data Documentation

◆ _event

event_t drizzled::plugin::QueryLog::_event
private

Definition at line 69 of file query_log.h.

◆ _logger_file

QueryLoggerFile* drizzled::plugin::QueryLog::_logger_file
private

Definition at line 68 of file query_log.h.

◆ sysvar_enabled

bool drizzled::plugin::QueryLog::sysvar_enabled

These are the query_log system variables. So sysvar_enabled is query_log_enabled in SHOW VARIABLES, etc. They are all global and dynamic.

Definition at line 56 of file query_log.h.

◆ sysvar_file

std::string drizzled::plugin::QueryLog::sysvar_file

Definition at line 58 of file query_log.h.

◆ sysvar_file_enabled

bool drizzled::plugin::QueryLog::sysvar_file_enabled

Definition at line 57 of file query_log.h.

◆ sysvar_threshold_execution_time

uint32_constraint drizzled::plugin::QueryLog::sysvar_threshold_execution_time

Definition at line 59 of file query_log.h.

◆ sysvar_threshold_lock_time

uint32_constraint drizzled::plugin::QueryLog::sysvar_threshold_lock_time

Definition at line 60 of file query_log.h.

◆ sysvar_threshold_rows_examined

uint32_constraint drizzled::plugin::QueryLog::sysvar_threshold_rows_examined

Definition at line 61 of file query_log.h.

◆ sysvar_threshold_rows_sent

uint32_constraint drizzled::plugin::QueryLog::sysvar_threshold_rows_sent

Definition at line 62 of file query_log.h.

◆ sysvar_threshold_session_time

uint32_constraint drizzled::plugin::QueryLog::sysvar_threshold_session_time

Definition at line 65 of file query_log.h.

◆ sysvar_threshold_tmp_tables

uint32_constraint drizzled::plugin::QueryLog::sysvar_threshold_tmp_tables

Definition at line 63 of file query_log.h.

◆ sysvar_threshold_warnings

uint32_constraint drizzled::plugin::QueryLog::sysvar_threshold_warnings

Definition at line 64 of file query_log.h.


The documentation for this class was generated from the following files: