#include <FileLogManager.h>
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 |
Definition at line 39 of file FileLogManager.h.
FileLogManager | ( | ) | [inline] |
Default constructor.
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.
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.
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().
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().