FileLogManager Class Reference

Log manager which outputs string messages to files. More...

#include <FileLogManager.h>

Inheritance diagram for FileLogManager:

IGenericLogManager< std::tstring > ILogManager

List of all members.

Public Member Functions

 FileLogManager ()
 Default constructor.
 FileLogManager (const RegistryKey &key)
 Constructor. Configures the FileLogManager using configuration stored in the registry.
virtual void ManageMessage (const std::tstring &message)
 Writes the message to m_fstream and rotates the log files, if necessary.

Private Member Functions

void RotateIfNecessary ()
 Checks whether the size of the active log file exceeds m_maxFileSize. If true, it rotates the log files.
void InitFstream ()
 Initializes the m_fstream member.

Private Attributes

std::tfstream m_fstream
 File stream which writes to the active log file.
std::tstring m_pathPrefix
 Path prefix of the names of files managed by this LogManager.
unsigned int m_maxFileCount
 Maximum number of files managed by this FileLogManager.
unsigned int m_maxFileSize
 Maximum size of the file managed by this FileLogManager.

Friends

class Test::FileLogManagerTest


Detailed Description

Log manager which outputs string messages to files.

Definition at line 39 of file FileLogManager.h.


Constructor & Destructor Documentation

FileLogManager (  )  [inline]

Default constructor.

Exceptions:
std::runtime_exception When the name of the process couldn't be retreived.

Definition at line 101 of file FileLogManager.h.

References FileLogManager::InitFstream(), FileLogManager::m_maxFileCount, FileLogManager::m_maxFileSize, and FileLogManager::m_pathPrefix.

FileLogManager ( const RegistryKey &  key  )  [inline]

Constructor. Configures the FileLogManager using configuration stored in the registry.

Exceptions:
std::runtime_exception When the name of the process couldn't be retreived.
RegistryException When the configuration stored in the registry is invalid.

Definition at line 113 of file FileLogManager.h.

References FileLogManager::InitFstream(), FileLogManager::m_maxFileCount, FileLogManager::m_maxFileSize, and FileLogManager::m_pathPrefix.


Member Function Documentation

void InitFstream (  )  [inline, private]

Initializes the m_fstream member.

This involves creating all directories leading to m_pathPrefix, and modifying m_pathPrefix if (m_pathPrefix + ".log") is currently being written to by another process. LOGGING_MAX_INSTANCES_COUNT variations of m_pathPrefix are tried before the function will give up.

Definition at line 129 of file FileLogManager.h.

References FileLogManager::m_fstream, and FileLogManager::m_pathPrefix.

Referenced by FileLogManager::FileLogManager().


Member Data Documentation

unsigned int m_maxFileCount [private]

Maximum number of files managed by this FileLogManager.

If exceeded, the oldest file is deleted.

Definition at line 59 of file FileLogManager.h.

Referenced by FileLogManager::FileLogManager(), and FileLogManager::RotateIfNecessary().

unsigned int m_maxFileSize [private]

Maximum size of the file managed by this FileLogManager.

If exceeded, the log files are rotated.

Definition at line 66 of file FileLogManager.h.

Referenced by FileLogManager::FileLogManager(), and FileLogManager::RotateIfNecessary().

std::tstring m_pathPrefix [private]

Path prefix of the names of files managed by this LogManager.

This is equivalent to the name of the active log file.

Definition at line 52 of file FileLogManager.h.

Referenced by FileLogManager::FileLogManager(), FileLogManager::InitFstream(), and FileLogManager::RotateIfNecessary().


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

Generated on Thu Sep 17 15:05:17 2009 for Logging by  doxygen 1.5.8