~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/query_log/query_log.h

  • Committer: Mark Atwood
  • Date: 2011-08-06 22:44:31 UTC
  • mfrom: (2311.1.10 query-log-plugin)
  • Revision ID: me@mark.atwood.name-20110806224431-57s1770jarqncrl7
mergeĀ lp:~daniel-nichter/drizzle/query-log-plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright 2011 Daniel Nichter
 
5
 *
 
6
 *  This program is free software: you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation, either version 3 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
#pragma once
 
21
 
 
22
#include <drizzled/plugin/event_observer.h>
 
23
#include "file.h"
 
24
#include "event.h"
 
25
 
 
26
namespace drizzled
 
27
{
 
28
namespace plugin
 
29
{
 
30
 
 
31
/**
 
32
 * @brief
 
33
 *   QueryLog implements the query_log plugin.
 
34
 *
 
35
 * @details
 
36
 *   This is our event observer plugin subclass that sits between Drizzle
 
37
 *   and logger classes like QueryLoggerFile.  This class encapsulates and
 
38
 *   manages data associated with the plugin: system variables and incoming
 
39
 *   events.  The future plan is to have other logger classes, like
 
40
 *   QueryLoggerTable or QueryLoggerUDPSocket.  So implemeting those should
 
41
 *   be easy because this class abstracts plugin data management from actual
 
42
 *   logging: it gets events from Drizzle, filters and prepares them, then
 
43
 *   sends them to logger classes which only have to log them.
 
44
 */
 
45
class QueryLog : public drizzled::plugin::EventObserver
 
46
{
 
47
public:
 
48
  QueryLog(bool enabled, QueryLoggerFile *logger_file);
 
49
  ~QueryLog();
 
50
 
 
51
  void registerSessionEventsDo(Session &session, EventObserverList &observers);
 
52
  bool observeEventDo(EventData &);
 
53
  bool afterStatement(AfterStatementEventData &data);
 
54
 
 
55
  /**
 
56
   * These are the query_log system variables.  So sysvar_enabled is
 
57
   * query_log_enabled in SHOW VARIABLES, etc.  They are all global and dynamic.
 
58
   */
 
59
  bool sysvar_enabled;
 
60
  bool sysvar_file_enabled;
 
61
  std::string sysvar_file;
 
62
  uint32_constraint sysvar_threshold_execution_time;
 
63
  uint32_constraint sysvar_threshold_lock_time;
 
64
  uint32_constraint sysvar_threshold_rows_examined;
 
65
  uint32_constraint sysvar_threshold_rows_sent;
 
66
  uint32_constraint sysvar_threshold_tmp_tables;
 
67
  uint32_constraint sysvar_threshold_warnings;
 
68
  uint32_constraint sysvar_threshold_session_time;
 
69
 
 
70
private:
 
71
  QueryLoggerFile *_logger_file;
 
72
  event_t _event;
 
73
};
 
74
 
 
75
} /* namespace plugin */
 
76
} /* namespace drizzled */