MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LogHandler Class Reference

#include <LogHandler.hpp>

Inheritance diagram for LogHandler:

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 &params)
virtual bool setParam (const BaseString &param, 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

Detailed Description

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)

Version
#@
Id:
LogHandler.hpp,v 1.7 2003/09/01 10:15:53 innpeno Exp

Definition at line 42 of file LogHandler.hpp.

Constructor & Destructor Documentation

LogHandler::LogHandler ( )

Default constructor.

Definition at line 26 of file LogHandler.cpp.

LogHandler::~LogHandler ( )
virtual

Destructor.

Definition at line 40 of file LogHandler.cpp.

Member Function Documentation

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.

Parameters
pCategorythe category/name to tag the log entry with.
levelthe log level.
pMsgthe log message.

Definition at line 45 of file LogHandler.cpp.

bool LogHandler::checkParams ( )
virtual

Checks that all necessary parameters have been set.

Returns
true if all parameters are correctly set, false otherwise

Reimplemented in FileLogHandler.

Definition at line 201 of file LogHandler.cpp.

Here is the caller graph for this function:

virtual bool LogHandler::close ( )
pure virtual

Closes/free any allocated resources used by the log handler.

Returns
true if successful.

Implemented in SysLogHandler, FileLogHandler, ConsoleLogHandler, and EventLogHandler.

const char * LogHandler::getDateTimeFormat ( ) const

Returns the date and time format used by ctime().

Returns
the date and time format.

Definition at line 117 of file LogHandler.cpp.

const char * LogHandler::getDefaultFooter ( ) const

Returns a default formatted footer. Currently only returns a newline.

Returns
the footer.

Definition at line 111 of file LogHandler.cpp.

Here is the caller graph for this function:

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 –'

Parameters
pStrthe header string to format.
pCategorya category/name to tag the log entry with.
levelthe log level.
Returns
the header.

Definition at line 97 of file LogHandler.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int LogHandler::getErrorCode ( ) const

Returns the error code.

Definition at line 147 of file LogHandler.cpp.

Here is the caller graph for this function:

char * LogHandler::getErrorStr ( )

Returns the error string.

Definition at line 160 of file LogHandler.cpp.

Here is the caller graph for this function:

virtual bool LogHandler::getParams ( BaseString config)
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"

Parameters
configwhere to store parameters

Reimplemented in FileLogHandler.

Definition at line 187 of file LogHandler.hpp.

virtual bool LogHandler::is_open ( )
pure virtual

Check if LogHandler is open

Returns
true if open.

Implemented in SysLogHandler, FileLogHandler, ConsoleLogHandler, and EventLogHandler.

Here is the caller graph for this function:

virtual bool LogHandler::open ( )
pure virtual

Opens/initializes the log handler.

Returns
true if successful.

Implemented in SysLogHandler, FileLogHandler, ConsoleLogHandler, and EventLogHandler.

Here is the caller graph for this function:

bool LogHandler::parseParams ( const BaseString params)

Parse logstring parameters

Parameters
paramslist of parameters, formatted as "param=value", entries separated by ","
Returns
true on success, false on failure

Definition at line 172 of file LogHandler.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void LogHandler::setDateTimeFormat ( const char *  pFormat)

Sets the date and time format. It needs to have the same arguments a ctime().

Parameters
pFormatthe date and time format.

Definition at line 123 of file LogHandler.cpp.

void LogHandler::setErrorCode ( int  code)

Sets the error code.

Parameters
codethe error code.

Definition at line 153 of file LogHandler.cpp.

Here is the caller graph for this function:

void LogHandler::setErrorStr ( const char *  str)

Sets the error string.

Parameters
strthe error string.

Definition at line 166 of file LogHandler.cpp.

Here is the caller graph for this function:

virtual bool LogHandler::setParam ( const BaseString param,
const BaseString value 
)
pure virtual

Sets a parameters. What parameters are accepted depends on the subclass.

Parameters
paramname of parameter
valuevalue of parameter

Implemented in SysLogHandler, FileLogHandler, ConsoleLogHandler, and EventLogHandler.

Here is the caller graph for this function:

LogHandler::STATIC_CONST ( MAX_DATE_TIME_HEADER_LENGTH  = 64)
protected

Max length of the date and time header in the log.

LogHandler::STATIC_CONST ( MAX_HEADER_LENGTH  = 128)
protected

Max length of the header the log.

LogHandler::STATIC_CONST ( MAX_FOOTER_LENGTH  = 128)
protected

Max lenght of footer in the log.

virtual void LogHandler::writeFooter ( )
protectedpure virtual

Write the footer to the log.

Implemented in SysLogHandler, FileLogHandler, and ConsoleLogHandler.

virtual void LogHandler::writeHeader ( const char *  category,
Logger::LoggerLevel  level 
)
protectedpure virtual

Write the header to the log.

Parameters
pCategorythe category to tag the log with.
levelthe log level.

Implemented in SysLogHandler, FileLogHandler, and ConsoleLogHandler.

virtual void LogHandler::writeMessage ( const char *  pMsg)
protectedpure virtual

Write the message to the log.

Parameters
pMsgthe message to log.

Implemented in SysLogHandler, FileLogHandler, and ConsoleLogHandler.


The documentation for this class was generated from the following files: