Arc::LogFile Class Reference

A class for logging to files. More...

#include <Logger.h>

Inheritance diagram for Arc::LogFile:
Arc::LogDestination

Public Member Functions

 LogFile (const std::string &path)
 LogFile (const std::string &path, const std::string &locale)
void setMaxSize (int newsize)
void setBackups (int newbackup)
void setReopen (bool newreopen)
 operator bool (void)
bool operator! (void)
virtual void log (const LogMessage &message)

Detailed Description

A class for logging to files.

This class is used for logging to files. It provides synchronization in order to prevent different LogMessages to appear mixed with each other in the stream. It is possible to limit size of created file. Whenever specified size is exceeded fiel is deleted and new one is created. Old files may be moved into backup files instead of being deleted. Those files have names same as initial file with additional number suffix - similar to those found in /var/log of many Unix-like systems.


Constructor & Destructor Documentation

Arc::LogFile::LogFile ( const std::string &  path  ) 

Creates a LogFile connected to a file.

Creates a LogFile connected to the file located at specified path. In order not to break synchronization, it is important not to connect more than one LogFile object to a certain file. If file does not exist it will be created.

Parameters:
path The path to file to which to write LogMessages.
Arc::LogFile::LogFile ( const std::string &  path,
const std::string &  locale 
)

Creates a LogFile connected to a file.

Creates a LogFile connected to the file located at specified path. The output will be localised to the specified locale.


Member Function Documentation

virtual void Arc::LogFile::log ( const LogMessage message  )  [virtual]

Writes a LogMessage to the file.

This method writes a LogMessage to the file that is connected to this LogFile object. If after writitng size of file exceeds one set by setMaxSize() file is moved to backup and new one is created.

Parameters:
message The LogMessage to write.

Implements Arc::LogDestination.

void Arc::LogFile::setBackups ( int  newbackup  ) 

Set number of backups to store.

Set number of backups to store. When file size exceeds one specified with setMaxSize() file is closed and moved to one named path.1. If path.1 exists it is moved to path.2 and so on. Number of path.# files is one set in newbackup.

Parameters:
newbackup Number of backup files.
void Arc::LogFile::setMaxSize ( int  newsize  ) 

Set maximal allowed size of file.

Set maximal allowed size of file. This value is not obeyed exactly. Spesified size may be exceeded by amount of one LogMessage. To disable limit specify -1.

Parameters:
newsize Max size of log file.
void Arc::LogFile::setReopen ( bool  newreopen  ) 

Set file reopen on every write.

Set file reopen on every write. If set to true file is opened before writing every log record and closed afterward.

Parameters:
newreopen If file to be reopened for every log record.

The documentation for this class was generated from the following file:
Generated on Wed Jun 27 11:54:21 2012 for Hosting Environment (Daemon) by  doxygen 1.6.3