MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LogLevel.hpp
1 /*
2  Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #ifndef _LOG_LEVEL_HPP
19 #define _LOG_LEVEL_HPP
20 
21 #include <ndb_global.h>
22 #include <mgmapi_config_parameters.h>
23 
27 class LogLevel {
28  friend class Config;
29 public:
33  LogLevel();
34 
48  LogLevel & operator= (const LogLevel &);
49 
50  enum EventCategory {
51  llInvalid = -1,
52  llStartUp = CFG_LOGLEVEL_STARTUP - CFG_MIN_LOGLEVEL,
53  llShutdown = CFG_LOGLEVEL_SHUTDOWN - CFG_MIN_LOGLEVEL,
54  llStatistic = CFG_LOGLEVEL_STATISTICS - CFG_MIN_LOGLEVEL,
55  llCheckpoint = CFG_LOGLEVEL_CHECKPOINT - CFG_MIN_LOGLEVEL,
56  llNodeRestart = CFG_LOGLEVEL_NODERESTART - CFG_MIN_LOGLEVEL,
57  llConnection = CFG_LOGLEVEL_CONNECTION - CFG_MIN_LOGLEVEL,
58  llInfo = CFG_LOGLEVEL_INFO - CFG_MIN_LOGLEVEL,
59  llWarning = CFG_LOGLEVEL_WARNING - CFG_MIN_LOGLEVEL,
60  llError = CFG_LOGLEVEL_ERROR - CFG_MIN_LOGLEVEL,
61  llCongestion = CFG_LOGLEVEL_CONGESTION - CFG_MIN_LOGLEVEL,
62  llDebug = CFG_LOGLEVEL_DEBUG - CFG_MIN_LOGLEVEL
63  ,llBackup = CFG_LOGLEVEL_BACKUP - CFG_MIN_LOGLEVEL
64  ,llSchema = CFG_LOGLEVEL_SCHEMA - CFG_MIN_LOGLEVEL
65  };
66 
70 #define _LOGLEVEL_CATEGORIES (CFG_MAX_LOGLEVEL - CFG_MIN_LOGLEVEL + 1)
71  STATIC_CONST( LOGLEVEL_CATEGORIES = _LOGLEVEL_CATEGORIES );
72 
73  void clear();
74 
78  int setLogLevel(EventCategory ec, Uint32 level = 7);
79 
83  Uint32 getLogLevel(EventCategory ec) const;
84 
88  LogLevel& set_max(const LogLevel& ll);
89 
90  bool operator==(const LogLevel& l) const {
91  return memcmp(this, &l, sizeof(* this)) == 0;
92  }
93 
94  LogLevel& operator=(const struct EventSubscribeReq & req);
95 
96 private:
100  Uint8 logLevelData[LOGLEVEL_CATEGORIES];
101 };
102 
103 inline
105  clear();
106 }
107 
108 inline
109 LogLevel &
111  memcpy(logLevelData, org.logLevelData, sizeof(logLevelData));
112  return * this;
113 }
114 
115 inline
116 void
117 LogLevel::clear(){
118  for(Uint32 i = 0; i<LOGLEVEL_CATEGORIES; i++){
119  logLevelData[i] = 0;
120  }
121 }
122 
123 inline
124 int
125 LogLevel::setLogLevel(EventCategory ec, Uint32 level){
126  if (ec >= 0 && (Uint32) ec < LOGLEVEL_CATEGORIES)
127  {
128  logLevelData[ec] = (Uint8)level;
129  return 0;
130  }
131  return 1;
132 }
133 
134 inline
135 Uint32
136 LogLevel::getLogLevel(EventCategory ec) const{
137  assert(ec >= 0 && (Uint32) ec < LOGLEVEL_CATEGORIES);
138 
139  return (Uint32)logLevelData[ec];
140 }
141 
142 inline
143 LogLevel &
145  for(Uint32 i = 0; i<LOGLEVEL_CATEGORIES; i++){
146  if(logLevelData[i] < org.logLevelData[i])
147  logLevelData[i] = org.logLevelData[i];
148  }
149  return * this;
150 }
151 
152 #include "signaldata/EventSubscribeReq.hpp"
153 
154 inline
155 LogLevel&
157 {
158  clear();
159  for(size_t i = 0; i<req.noOfEntries; i++){
160  logLevelData[(req.theData[i] >> 16)] = req.theData[i] & 0xFFFF;
161  }
162  return * this;
163 }
164 
165 #endif