mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / ndb / include / kernel / LogLevel.hpp
blobbeba32f49a7632fe5690bbd13d048ddc61150a81
1 /* Copyright (c) 2003-2005 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
16 #ifndef _LOG_LEVEL_HPP
17 #define _LOG_LEVEL_HPP
19 #include <ndb_global.h>
20 #include <mgmapi_config_parameters.h>
22 /**
25 class LogLevel {
26 friend class Config;
27 public:
28 /**
29 * Constructor
31 LogLevel();
33 /**
34 * Howto add a new event category:
35 * 1. Add the new event category to EventCategory below
36 * 2. Update #define _LOGLEVEL_CATEGORIES (found below) with the number of
37 * items in EventCategory
38 * 3. Update LogLevelCategoryName in LogLevel.cpp
39 * 4. Add the event in EventLogger
43 /**
44 * Copy operator
46 LogLevel & operator= (const LogLevel &);
48 enum EventCategory {
49 llInvalid = -1,
50 llStartUp = CFG_LOGLEVEL_STARTUP - CFG_MIN_LOGLEVEL,
51 llShutdown = CFG_LOGLEVEL_SHUTDOWN - CFG_MIN_LOGLEVEL,
52 llStatistic = CFG_LOGLEVEL_STATISTICS - CFG_MIN_LOGLEVEL,
53 llCheckpoint = CFG_LOGLEVEL_CHECKPOINT - CFG_MIN_LOGLEVEL,
54 llNodeRestart = CFG_LOGLEVEL_NODERESTART - CFG_MIN_LOGLEVEL,
55 llConnection = CFG_LOGLEVEL_CONNECTION - CFG_MIN_LOGLEVEL,
56 llInfo = CFG_LOGLEVEL_INFO - CFG_MIN_LOGLEVEL,
57 llWarning = CFG_LOGLEVEL_WARNING - CFG_MIN_LOGLEVEL,
58 llError = CFG_LOGLEVEL_ERROR - CFG_MIN_LOGLEVEL,
59 llCongestion = CFG_LOGLEVEL_CONGESTION - CFG_MIN_LOGLEVEL,
60 llDebug = CFG_LOGLEVEL_DEBUG - CFG_MIN_LOGLEVEL
61 ,llBackup = CFG_LOGLEVEL_BACKUP - CFG_MIN_LOGLEVEL
64 /**
65 * No of categories
67 #define _LOGLEVEL_CATEGORIES (CFG_MAX_LOGLEVEL - CFG_MIN_LOGLEVEL + 1)
68 STATIC_CONST( LOGLEVEL_CATEGORIES = _LOGLEVEL_CATEGORIES );
70 void clear();
72 /**
73 * Note level is valid as 0-15
75 int setLogLevel(EventCategory ec, Uint32 level = 7);
77 /**
78 * Get the loglevel (0-15) for a category
80 Uint32 getLogLevel(EventCategory ec) const;
82 /**
83 * Set this= max(this, ll) per category
85 LogLevel& set_max(const LogLevel& ll);
87 bool operator==(const LogLevel& l) const {
88 return memcmp(this, &l, sizeof(* this)) == 0;
91 LogLevel& operator=(const struct EventSubscribeReq & req);
93 private:
94 /**
95 * The actual data
97 Uint8 logLevelData[LOGLEVEL_CATEGORIES];
100 inline
101 LogLevel::LogLevel(){
102 clear();
105 inline
106 LogLevel &
107 LogLevel::operator= (const LogLevel & org){
108 memcpy(logLevelData, org.logLevelData, sizeof(logLevelData));
109 return * this;
112 inline
113 void
114 LogLevel::clear(){
115 for(Uint32 i = 0; i<LOGLEVEL_CATEGORIES; i++){
116 logLevelData[i] = 0;
120 inline
122 LogLevel::setLogLevel(EventCategory ec, Uint32 level){
123 if (ec >= 0 && (Uint32) ec < LOGLEVEL_CATEGORIES)
125 logLevelData[ec] = (Uint8)level;
126 return 0;
128 return 1;
131 inline
132 Uint32
133 LogLevel::getLogLevel(EventCategory ec) const{
134 assert(ec >= 0 && (Uint32) ec < LOGLEVEL_CATEGORIES);
136 return (Uint32)logLevelData[ec];
139 inline
140 LogLevel &
141 LogLevel::set_max(const LogLevel & org){
142 for(Uint32 i = 0; i<LOGLEVEL_CATEGORIES; i++){
143 if(logLevelData[i] < org.logLevelData[i])
144 logLevelData[i] = org.logLevelData[i];
146 return * this;
149 #include "signaldata/EventSubscribeReq.hpp"
151 inline
152 LogLevel&
153 LogLevel::operator=(const EventSubscribeReq& req)
155 clear();
156 for(size_t i = 0; i<req.noOfEntries; i++){
157 logLevelData[(req.theData[i] >> 16)] = req.theData[i] & 0xFFFF;
159 return * this;
162 #endif