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

#include <FileLogHandler.hpp>

Inheritance diagram for FileLogHandler:
Collaboration diagram for FileLogHandler:

Public Member Functions

virtual const char * handler_type ()
 FileLogHandler (const char *aFileName="logger.log", int maxNoFiles=6, long maxFileSize=1024000, unsigned int maxLogEntries=10000)
virtual ~FileLogHandler ()
virtual bool open ()
virtual bool close ()
virtual bool is_open ()
virtual bool setParam (const BaseString &param, const BaseString &value)
virtual bool checkParams ()
virtual bool getParams (BaseString &config)
virtual off_t getCurrentSize ()
virtual off_t getMaxSize ()
- Public Member Functions inherited from LogHandler
 LogHandler ()
virtual ~LogHandler ()
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 void setRepeatFrequency (unsigned val)

Protected Member Functions

virtual void writeHeader (const char *pCategory, Logger::LoggerLevel level)
virtual void writeMessage (const char *pMsg)
virtual void writeFooter ()
- Protected Member Functions inherited from LogHandler
 STATIC_CONST (MAX_DATE_TIME_HEADER_LENGTH=64)
 STATIC_CONST (MAX_HEADER_LENGTH=128)
 STATIC_CONST (MAX_FOOTER_LENGTH=128)

Detailed Description

Logs messages to a file. The log file will be archived depending on the file's size or after N number of log entries. There will be only a specified number of archived logs which will be "recycled".

The archived log file will be named as <filename>.1..N.

See Also
LogHandler
Version
#@
Id:
FileLogHandler.hpp,v 1.2 2003/09/01 10:15:53 innpeno Exp

Definition at line 37 of file FileLogHandler.hpp.

Constructor & Destructor Documentation

FileLogHandler::FileLogHandler ( const char *  aFileName = "logger.log",
int  maxNoFiles = 6,
long  maxFileSize = 1024000,
unsigned int  maxLogEntries = 10000 
)

Creates a new file handler with the specified filename, max number of archived log files and max log size for each log.

Parameters
aFileNamethe log filename.
maxNoFilesthe maximum number of archived log files.
maxFileSizethe maximum log file size before archiving.
maxLogEntriesthe maximum number of log entries before checking time to archive.

Definition at line 26 of file FileLogHandler.cpp.

FileLogHandler::~FileLogHandler ( )
virtual

Destructor.

Definition at line 38 of file FileLogHandler.cpp.

Member Function Documentation

bool FileLogHandler::checkParams ( )
virtual

Checks that all necessary parameters have been set.

Returns
true if all parameters are correctly set, false otherwise

Reimplemented from LogHandler.

Definition at line 255 of file FileLogHandler.cpp.

Here is the call graph for this function:

bool FileLogHandler::close ( )
virtual

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

Returns
true if successful.

Implements LogHandler.

Definition at line 75 of file FileLogHandler.cpp.

Here is the call graph for this function:

bool FileLogHandler::getParams ( BaseString config)
virtual

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 from LogHandler.

Definition at line 203 of file FileLogHandler.cpp.

Here is the call graph for this function:

bool FileLogHandler::is_open ( )
virtual

Check if LogHandler is open

Returns
true if open.

Implements LogHandler.

Definition at line 69 of file FileLogHandler.cpp.

Here is the call graph for this function:

bool FileLogHandler::open ( )
virtual

Opens/initializes the log handler.

Returns
true if successful.

Implements LogHandler.

Definition at line 44 of file FileLogHandler.cpp.

Here is the call graph for this function:

bool FileLogHandler::setParam ( const BaseString param,
const BaseString value 
)
virtual

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

Parameters
paramname of parameter
valuevalue of parameter

Implements LogHandler.

Definition at line 192 of file FileLogHandler.cpp.

Here is the call graph for this function:

void FileLogHandler::writeFooter ( )
protectedvirtual

Write the footer to the log.

The reason I also check the number of log entries instead of only the log size, is that I do not want to check the file size after each log entry which requires system calls and is quite slow. TODO: Any better way?

Implements LogHandler.

Definition at line 101 of file FileLogHandler.cpp.

Here is the call graph for this function:

void FileLogHandler::writeHeader ( const char *  category,
Logger::LoggerLevel  level 
)
protectedvirtual

Write the header to the log.

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

Implements LogHandler.

Definition at line 88 of file FileLogHandler.cpp.

Here is the call graph for this function:

void FileLogHandler::writeMessage ( const char *  pMsg)
protectedvirtual

Write the message to the log.

Parameters
pMsgthe message to log.

Implements LogHandler.

Definition at line 95 of file FileLogHandler.cpp.

Here is the call graph for this function:


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