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>
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
46 LogLevel
& operator= (const LogLevel
&);
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
67 #define _LOGLEVEL_CATEGORIES (CFG_MAX_LOGLEVEL - CFG_MIN_LOGLEVEL + 1)
68 STATIC_CONST( LOGLEVEL_CATEGORIES
= _LOGLEVEL_CATEGORIES
);
73 * Note level is valid as 0-15
75 int setLogLevel(EventCategory ec
, Uint32 level
= 7);
78 * Get the loglevel (0-15) for a category
80 Uint32
getLogLevel(EventCategory ec
) const;
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
);
97 Uint8 logLevelData
[LOGLEVEL_CATEGORIES
];
101 LogLevel::LogLevel(){
107 LogLevel::operator= (const LogLevel
& org
){
108 memcpy(logLevelData
, org
.logLevelData
, sizeof(logLevelData
));
115 for(Uint32 i
= 0; i
<LOGLEVEL_CATEGORIES
; i
++){
122 LogLevel::setLogLevel(EventCategory ec
, Uint32 level
){
123 if (ec
>= 0 && (Uint32
) ec
< LOGLEVEL_CATEGORIES
)
125 logLevelData
[ec
] = (Uint8
)level
;
133 LogLevel::getLogLevel(EventCategory ec
) const{
134 assert(ec
>= 0 && (Uint32
) ec
< LOGLEVEL_CATEGORIES
);
136 return (Uint32
)logLevelData
[ec
];
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
];
149 #include "signaldata/EventSubscribeReq.hpp"
153 LogLevel::operator=(const EventSubscribeReq
& req
)
156 for(size_t i
= 0; i
<req
.noOfEntries
; i
++){
157 logLevelData
[(req
.theData
[i
] >> 16)] = req
.theData
[i
] & 0xFFFF;