MySQL 5.6.14 Source Code Document
|
#include <LogHandler.hpp>
Public Member Functions | |
LogHandler () | |
virtual | ~LogHandler () |
virtual const char * | handler_type () |
virtual bool | open ()=0 |
virtual bool | close ()=0 |
virtual bool | is_open ()=0 |
void | append (const char *pCategory, Logger::LoggerLevel level, const char *pMsg) |
void | append_impl (const char *pCategory, Logger::LoggerLevel level, const char *pMsg) |
const char * | getDefaultHeader (char *pStr, const char *pCategory, Logger::LoggerLevel level) const |
const char * | getDefaultFooter () const |
const char * | getDateTimeFormat () const |
void | setDateTimeFormat (const char *pFormat) |
int | getErrorCode () const |
void | setErrorCode (int code) |
char * | getErrorStr () |
void | setErrorStr (const char *str) |
bool | parseParams (const BaseString ¶ms) |
virtual bool | setParam (const BaseString ¶m, const BaseString &value)=0 |
virtual bool | checkParams () |
virtual void | setRepeatFrequency (unsigned val) |
virtual bool | getParams (BaseString &config) |
virtual off_t | getCurrentSize () |
virtual off_t | getMaxSize () |
Protected Member Functions | |
STATIC_CONST (MAX_DATE_TIME_HEADER_LENGTH=64) | |
STATIC_CONST (MAX_HEADER_LENGTH=128) | |
STATIC_CONST (MAX_FOOTER_LENGTH=128) | |
virtual void | writeHeader (const char *category, Logger::LoggerLevel level)=0 |
virtual void | writeMessage (const char *pMsg)=0 |
virtual void | writeFooter ()=0 |
This class is the base class for all log handlers. A log handler is responsible for formatting and writing log messages to a specific output.
A log entry consists of three parts: a header, <body/log message and a footer.
09:17:37 2002-03-13 [MgmSrv] INFO -- Local checkpoint 13344 started.
Header format: TIME&DATE CATEGORY LEVEL – TIME&DATE = ctime() format. CATEGORY = Any string. LEVEL = ALERT to DEBUG (Log levels)
Footer format:
(currently only newline)
Definition at line 42 of file LogHandler.hpp.
LogHandler::LogHandler | ( | ) |
Default constructor.
Definition at line 26 of file LogHandler.cpp.
|
virtual |
Destructor.
Definition at line 40 of file LogHandler.cpp.
void LogHandler::append | ( | const char * | pCategory, |
Logger::LoggerLevel | level, | ||
const char * | pMsg | ||
) |
Append a log message to the output stream/file whatever. append() will call writeHeader(), writeMessage() and writeFooter() for a child class and in that order. Append checks for repeated messages. append_impl() does not check for repeats.
pCategory | the category/name to tag the log entry with. |
level | the log level. |
pMsg | the log message. |
Definition at line 45 of file LogHandler.cpp.
|
virtual |
Checks that all necessary parameters have been set.
Reimplemented in FileLogHandler.
Definition at line 201 of file LogHandler.cpp.
|
pure virtual |
Closes/free any allocated resources used by the log handler.
Implemented in SysLogHandler, FileLogHandler, ConsoleLogHandler, and EventLogHandler.
const char * LogHandler::getDateTimeFormat | ( | ) | const |
Returns the date and time format used by ctime().
Definition at line 117 of file LogHandler.cpp.
const char * LogHandler::getDefaultFooter | ( | ) | const |
Returns a default formatted footer. Currently only returns a newline.
Definition at line 111 of file LogHandler.cpp.
const char * LogHandler::getDefaultHeader | ( | char * | pStr, |
const char * | pCategory, | ||
Logger::LoggerLevel | level | ||
) | const |
Returns a default formatted header. It currently has the follwing default format: 'H:M:S Y-m-d [CATEGORY] LOGLEVEL –'
pStr | the header string to format. |
pCategory | a category/name to tag the log entry with. |
level | the log level. |
Definition at line 97 of file LogHandler.cpp.
int LogHandler::getErrorCode | ( | ) | const |
Returns the error code.
Definition at line 147 of file LogHandler.cpp.
char * LogHandler::getErrorStr | ( | ) |
Returns the error string.
Definition at line 160 of file LogHandler.cpp.
|
inlinevirtual |
Sets the config BaseString to the part of the LogDestination parameter needed in the config file to setup this LogHandler. i.e. passing the output of getParams to parseParams should do "nothing"
config | where to store parameters |
Reimplemented in FileLogHandler.
Definition at line 187 of file LogHandler.hpp.
|
pure virtual |
Check if LogHandler is open
Implemented in SysLogHandler, FileLogHandler, ConsoleLogHandler, and EventLogHandler.
|
pure virtual |
Opens/initializes the log handler.
Implemented in SysLogHandler, FileLogHandler, ConsoleLogHandler, and EventLogHandler.
bool LogHandler::parseParams | ( | const BaseString & | params | ) |
Parse logstring parameters
params | list of parameters, formatted as "param=value", entries separated by "," |
Definition at line 172 of file LogHandler.cpp.
void LogHandler::setDateTimeFormat | ( | const char * | pFormat | ) |
Sets the date and time format. It needs to have the same arguments a ctime().
pFormat | the date and time format. |
Definition at line 123 of file LogHandler.cpp.
void LogHandler::setErrorCode | ( | int | code | ) |
Sets the error code.
code | the error code. |
Definition at line 153 of file LogHandler.cpp.
void LogHandler::setErrorStr | ( | const char * | str | ) |
Sets the error string.
str | the error string. |
Definition at line 166 of file LogHandler.cpp.
|
pure virtual |
Sets a parameters. What parameters are accepted depends on the subclass.
param | name of parameter |
value | value of parameter |
Implemented in SysLogHandler, FileLogHandler, ConsoleLogHandler, and EventLogHandler.
|
protected |
Max length of the date and time header in the log.
|
protected |
Max length of the header the log.
|
protected |
Max lenght of footer in the log.
|
protectedpure virtual |
Write the footer to the log.
Implemented in SysLogHandler, FileLogHandler, and ConsoleLogHandler.
|
protectedpure virtual |
Write the header to the log.
pCategory | the category to tag the log with. |
level | the log level. |
Implemented in SysLogHandler, FileLogHandler, and ConsoleLogHandler.
|
protectedpure virtual |
Write the message to the log.
pMsg | the message to log. |
Implemented in SysLogHandler, FileLogHandler, and ConsoleLogHandler.