1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef EVENTLOGGER_H
#define EVENTLOGGER_H
#include <logger/Logger.hpp>
#include <logger/FileLogHandler.hpp>
#include <kernel/kernel_types.h>
#include <kernel/LogLevel.hpp>
#include <kernel/signaldata/EventReport.hpp>
class EventLoggerBase {
public:
virtual ~EventLoggerBase();
/**
* LogLevel settings
*/
LogLevel m_logLevel;
/**
* This matrix defines which event should be printed when
*
* threshold - is in range [0-15]
* severity - DEBUG to ALERT (Type of log message)
*/
typedef void (* EventTextFunction)(char *,size_t,const Uint32*);
struct EventRepLogLevelMatrix {
Ndb_logevent_type eventType;
LogLevel::EventCategory eventCategory;
Uint32 threshold;
Logger::LoggerLevel severity;
EventTextFunction textF;
};
static const EventRepLogLevelMatrix matrix[];
static const Uint32 matrixSize;
static int event_lookup(int eventType,
LogLevel::EventCategory &cat,
Uint32 &threshold,
Logger::LoggerLevel &severity,
EventTextFunction &textF);
};
/**
* The EventLogger is primarily used for logging NDB events
* in the Management Server. It inherits all logging functionality of Logger.
*
* HOW TO USE
*
* 1) Create an EventLogger
*
* EventLogger myEventLogger = new EventLogger();
*
* 2) Log NDB events and other log messages.
*
* myEventLogger->info("Changing log levels.");
*
* EventReport* report = (EventReport*)&theSignalData[0];
* myEventLogger->log(eventReport->getEventType(), theSignalData, aNodeId);
*
*
* The following NDB event categories and log levels are enabled as default:
*
* EVENT-CATEGORY LOG-LEVEL
*
* Startup 4
* Shutdown 1
* Statistic 2
* Checkpoint 5
* NodeRestart 8
* Connection 2
* Error 15
* Info 10
*
* @see Logger
* @version #@ $Id: EventLogger.hpp,v 1.3 2003/09/01 10:15:52 innpeno Exp $
*/
class EventLogger : public EventLoggerBase, public Logger
{
public:
/**
* Default constructor. Enables default log levels and
* sets the log category to 'EventLogger'.
*/
EventLogger();
/**
* Destructor.
*/
virtual ~EventLogger();
/**
* Opens/creates the eventlog with the specified filename.
*
* @param aFileName the eventlog filename.
* @param maxNoFiles the maximum no of archived eventlog files.
* @param maxFileSize the maximum eventlog file size.
* @param maxLogEntries the maximum number of log entries before
* checking time to archive.
* @return true if successful.
*/
bool open(const char* logFileName,
int maxNoFiles = FileLogHandler::MAX_NO_FILES,
long int maxFileSize = FileLogHandler::MAX_FILE_SIZE,
unsigned int maxLogEntries = FileLogHandler::MAX_LOG_ENTRIES);
/**
* Closes the eventlog.
*/
void close();
/**
* Logs the NDB event.
*
* @param eventType the type of event.
* @param theData the event data.
* @param nodeId the node id of event origin.
*/
virtual void log(int, const Uint32*, NodeId = 0,const class LogLevel * = 0);
/**
* Returns the event text for the specified event report type.
*
* @param textF print function for the event
* @param theData the event data.
* @param nodeId a node id.
* @return the event report text.
*/
static const char* getText(char * dst, size_t dst_len,
EventTextFunction textF,
const Uint32* theData, NodeId nodeId = 0);
/**
* Returns the log level that is used to filter an event. The event will not
* be logged unless its event category's log level is <= levelFilter.
*
* @return the log level filter that is used for all event categories.
*/
int getFilterLevel() const;
/**
* Sets log level filter. The event will be logged if
* the event category's log level is <= 'filterLevel'.
*
* @param level the log level to filter.
*/
void setFilterLevel(int filterLevel);
private:
/** Prohibit */
EventLogger(const EventLogger&);
EventLogger operator = (const EventLogger&);
bool operator == (const EventLogger&);
Uint32 m_filterLevel;
STATIC_CONST(MAX_TEXT_LENGTH = 256);
};
extern void getRestartAction(Uint32 action, BaseString &str);
#endif
|