| 
    MySQL 5.6.14 Source Code Document
    
   | 
 
#include <Logger.hpp>

Public Types | |
| enum | LoggerLevel {  LL_ON, LL_DEBUG, LL_INFO, LL_WARNING, LL_ERROR, LL_CRITICAL, LL_ALERT, LL_ALL }  | 
Public Member Functions | |
| Logger () | |
| virtual | ~Logger () | 
| void | setCategory (const char *pCategory) | 
| bool | createConsoleHandler (NdbOut &out=ndbout) | 
| void | removeConsoleHandler () | 
| bool | createEventLogHandler (const char *source_name) | 
| bool | createFileHandler (char *filename=0) | 
| void | removeFileHandler () | 
| bool | createSyslogHandler () | 
| void | removeSyslogHandler () | 
| bool | addHandler (LogHandler *pHandler) | 
| bool | addHandler (const BaseString &logstring, int *err, int len, char *errStr) | 
| bool | removeHandler (LogHandler *pHandler) | 
| void | removeAllHandlers () | 
| bool | isEnable (LoggerLevel logLevel) const | 
| void | enable (LoggerLevel logLevel) | 
| void | enable (LoggerLevel fromLogLevel, LoggerLevel toLogLevel) | 
| void | disable (LoggerLevel logLevel) | 
| virtual void | alert (const char *pMsg,...) const ATTRIBUTE_FORMAT(printf | 
| virtual void virtual void | alert (BaseString &pMsg) const | 
| virtual void | critical (const char *pMsg,...) const ATTRIBUTE_FORMAT(printf | 
| virtual void virtual void | critical (BaseString &pMsg) const | 
| virtual void | error (const char *pMsg,...) const ATTRIBUTE_FORMAT(printf | 
| virtual void virtual void | error (BaseString &pMsg) const | 
| virtual void | warning (const char *pMsg,...) const ATTRIBUTE_FORMAT(printf | 
| virtual void virtual void | warning (BaseString &pMsg) const | 
| virtual void | info (const char *pMsg,...) const ATTRIBUTE_FORMAT(printf | 
| virtual void virtual void | info (BaseString &pMsg) const | 
| virtual void | debug (const char *pMsg,...) const ATTRIBUTE_FORMAT(printf | 
| virtual void virtual void | debug (BaseString &pMsg) const | 
| virtual void | setRepeatFrequency (unsigned val) | 
Static Public Attributes | |
| static const char * | LoggerLevelNames [] | 
Protected Member Functions | |
| void | log (LoggerLevel logLevel, const char *msg, va_list ap) const | 
Protected Attributes | |
| NdbMutex * | m_mutex | 
Logger should be used whenver you need to log a message like general information or debug messages. By creating/adding different log handlers, a single log message can be sent to different outputs (stdout, file or syslog).
Each log entry is created with a log level (or severity) which is used to identity the type of the entry, e.g., if it is a debug or an error message.
Example of a log entry:
09:17:39 2002-03-13 [myLogger] INFO – Local checkpoint started.
HOW TO USE
1) Create a new instance of the Logger.
Logger myLogger = new Logger();
2) Add the log handlers that you want, i.e., where the log entries should be written/shown.
myLogger->createConsoleHandler(); // Output to console/stdout myLogger->addHandler(new FileLogHandler("mylog.txt")); // use mylog.txt
3) Tag each log entry with a category/name.
myLogger->setCategory("myLogger");
4) Start log messages.
myLogger->alert("T-9 to lift off");
myLogger->info("Here comes the sun, la la"); 
myLogger->debug("Why does this not work!!!, We should not be here...")
5) Log only debug messages.
myLogger->enable(Logger::LL_DEBUG);
6) Log only ALERTS and ERRORS.
myLogger->enable(Logger::LL_ERROR, Logger::LL_ALERT);
7) Do not log any messages.
myLogger->disable(Logger::LL_ALL);
LOG LEVELS (Matches the severity levels of syslog)
ALERT A condition that should be corrected immediately, such as a corrupted system database.
 CRITICAL        Critical conditions, such as hard device
                 errors.ERROR Errors.
WARNING Warning messages.
INFO Informational messages.
 DEBUG           Messages that contain  information  nor-
                 mally  of use only when debugging a pro-
                 gram.
Definition at line 102 of file Logger.hpp.
| enum Logger::LoggerLevel | 
The log levels. NOTE: Could not use the name LogLevel since it caused conflicts with another class.
Definition at line 108 of file Logger.hpp.
| Logger::Logger | ( | ) | 
Default constructor.
Definition at line 42 of file Logger.cpp.

      
  | 
  virtual | 
| bool Logger::addHandler | ( | LogHandler * | pHandler | ) | 
Add a new log handler.
| pHandler | a log handler. | 
Definition at line 195 of file Logger.cpp.


| bool Logger::addHandler | ( | const BaseString & | logstring, | 
| int * | err, | ||
| int | len, | ||
| char * | errStr | ||
| ) | 
Add a new handler
| logstring | string describing the handler to add | 
| err | OS errno in event of error | 
| len | max length of errStr buffer | 
| errStr | logger error string in event of error | 
Definition at line 214 of file Logger.cpp.

      
  | 
  virtual | 
Log an alert message.
| pMsg | the message. | 
Definition at line 370 of file Logger.cpp.

| bool Logger::createConsoleHandler | ( | NdbOut & | out = ndbout | ) | 
Create a default handler that logs to the console/stdout.
Definition at line 72 of file Logger.cpp.

| bool Logger::createEventLogHandler | ( | const char * | source_name | ) | 
Create a default handler that logs to the Windows event log with source component set to source_name
NOTE! Can only be created on Windows.
Definition at line 104 of file Logger.cpp.

| bool Logger::createFileHandler | ( | char * | filename = 0 | ) | 
Create a default handler that logs to a file called logger.log.
Definition at line 126 of file Logger.cpp.

| bool Logger::createSyslogHandler | ( | ) | 
Create a default handler that logs to the syslog.
Definition at line 159 of file Logger.cpp.

      
  | 
  virtual | 
Log a critical message.
| pMsg | the message. | 
Definition at line 379 of file Logger.cpp.

      
  | 
  virtual | 
Log a debug message.
| pMsg | the message. | 
Definition at line 413 of file Logger.cpp.

| void Logger::disable | ( | LoggerLevel | logLevel | ) | 
Disable log level.
| logLevel | disable log level. | 
Definition at line 353 of file Logger.cpp.

| void Logger::enable | ( | LoggerLevel | logLevel | ) | 
Enable the specified log level.
| logLevel | the loglevel to enable. | 
Definition at line 319 of file Logger.cpp.

| void Logger::enable | ( | LoggerLevel | fromLogLevel, | 
| LoggerLevel | toLogLevel | ||
| ) | 
Enable log levels.
| fromLogLevel | enable from log level. | 
| toLogLevel | enable to log level. | 
Definition at line 336 of file Logger.cpp.
      
  | 
  virtual | 
Log an error message.
| pMsg | the message. | 
Definition at line 387 of file Logger.cpp.

      
  | 
  virtual | 
Log an info message.
| pMsg | the message. | 
Definition at line 404 of file Logger.cpp.

| bool Logger::isEnable | ( | LoggerLevel | logLevel | ) | const | 
Returns true if the specified log level is enabled.
Definition at line 305 of file Logger.cpp.
| void Logger::removeAllHandlers | ( | ) | 
Remove all log handlers.
Definition at line 294 of file Logger.cpp.


| void Logger::removeConsoleHandler | ( | ) | 
Remove the default console handler.
Definition at line 94 of file Logger.cpp.

| void Logger::removeFileHandler | ( | ) | 
Remove the default file handler.
Definition at line 149 of file Logger.cpp.

| bool Logger::removeHandler | ( | LogHandler * | pHandler | ) | 
Remove a log handler.
| pHandler | log handler to remove. | 
Definition at line 274 of file Logger.cpp.


| void Logger::removeSyslogHandler | ( | ) | 
Remove the default syslog handler.
Definition at line 185 of file Logger.cpp.

| void Logger::setCategory | ( | const char * | pCategory | ) | 
Set a category/name that each log entry will have.
| pCategory | the category. | 
Definition at line 65 of file Logger.cpp.

      
  | 
  virtual | 
Log a warning message.
| pMsg | the message. | 
Definition at line 395 of file Logger.cpp.

      
  | 
  static | 
String representation of the the log levels.
Definition at line 114 of file Logger.hpp.