#include <freLogFileController.h>
Public Member Functions | |
| bool | StartLog () |
| bool | StartLog (const std::string sLogFileName) |
| bool | StopLog () |
| bool | Active () const |
| bool | AddEntry (const std::string sEntry) |
| bool | AddDirectEntry (const std::string sEntry) |
| bool | AddEntry (const std::string sEntry, const bool bAddTimeStamp) |
| void | SetFileName (const std::string sFileName) |
| const std::string | GetFileName () const |
| void | SetHeader (const std::string sHeader) |
| const std::string | GetHeader () const |
| void | SetInsertTimeStamp (const bool bTime) |
| const bool | GetInsertTimeStamp () const |
| void | SetAppendFile (const bool bAppend) |
| const bool | GetAppendFile () const |
| LogFileController () | |
| LogFileController (const std::string sFileName, const std::string sHeader="Log file", const bool bAppend=true, const bool bInsertTime=true) | |
| ~LogFileController () | |
Private Member Functions | |
| bool | OpenLogFile () |
| bool | CloseLogFile () |
Private Attributes | |
| std::string | m_sFileName |
| std::string | m_sHeader |
| bool | m_bActive |
| bool | m_bInsertTime |
| bool | m_bAppendFile |
| std::ofstream | m_LogFile |
The LogFileController is used in F.R.E.E to manage the log of events. It is possible to specify the filename, if it should append, make time stamps and so on. Because the constructor checks for the file handel and close it if nessecary, the file will always be closed correctly. (But it is recommended to use the StopLog function, that you don't get used to a lazy style ;).
Definition at line 44 of file freLogFileController.h.
| FREE::LogFileController::LogFileController | ( | ) |
Default constructor
Definition at line 213 of file freLogFileController.cxx.
References m_bActive, m_bAppendFile, m_bInsertTime, m_sFileName, and m_sHeader.
| FREE::LogFileController::LogFileController | ( | const std::string | sFileName, | |
| const std::string | sHeader = "Log file", |
|||
| const bool | bAppend = true, |
|||
| const bool | bInsertTime = true | |||
| ) |
Constructor sets the passed values and directly open the log
| [in] | sFileName | The name of the log file, which should be opened. |
| [in] | sHeader | The Header of the log file. |
| [in] | bAppend | Indicates if an existing log file should be continued. |
| [in] | bInsertTime | Indicates if a time stamp should be added to an entry. |
Definition at line 224 of file freLogFileController.cxx.
References m_bActive, m_bAppendFile, m_bInsertTime, m_sFileName, and m_sHeader.
| FREE::LogFileController::~LogFileController | ( | ) |
Definition at line 235 of file freLogFileController.cxx.
References m_bActive, and StopLog().

| bool FREE::LogFileController::StartLog | ( | ) |
Starts the log by open a file with the specified file name. After starting the log, the state of the controller is active. If the controller is active (so has a file opened) while call StartLog, the old log will be closed and a new log will be started. Only if it is the same file and the controller is set to append logs, the old log won't be closed, but will be continued.
Definition at line 49 of file freLogFileController.cxx.
References FREE::ActTimeStampToStr(), m_bActive, m_LogFile, m_sHeader, OpenLogFile(), and StopLog().
Referenced by AddDirectEntry(), and StartLog().

| bool FREE::LogFileController::StartLog | ( | const std::string | sLogFileName | ) |
Starts the log by open a file with file name/path passed by the function call. After starting the log, the state of the controller is active. If the controller is active (so has a file opened) while call StartLog, the old log will be closed and a new log will be started. Only if it is the same file and the controller is set to append logs, the old log won't be closed, but will be continued.
| [in] | sLogFileName | Name (with path) of the file which should contain the new started log. |
Definition at line 75 of file freLogFileController.cxx.
References SetFileName(), and StartLog().

| bool FREE::LogFileController::StopLog | ( | ) |
Stops the log by close the log file. If the controller is not active. the call of StopLog will do nothing.
Definition at line 83 of file freLogFileController.cxx.
References FREE::ActTimeStampToStr(), CloseLogFile(), m_bActive, and m_LogFile.
Referenced by AddDirectEntry(), SetFileName(), StartLog(), and ~LogFileController().

| bool FREE::LogFileController::Active | ( | ) | const |
Returns the state of the controller. If it is true, a log file is opened a ready to receive an entry. If it is false, there is no open log and calling the functions StopLog and AddEntry will have no effect.
Definition at line 102 of file freLogFileController.cxx.
References m_bActive.
| bool FREE::LogFileController::AddEntry | ( | const std::string | sEntry | ) |
Adds an entry to the log file. If the log is not active no entry will be added. The format of the entry depends on the setup of the controller, when m_InsertTime is true, a time information will be in front of the entry.
| [in] | sEntry | The new entry for the log. |
Definition at line 136 of file freLogFileController.cxx.
References m_bInsertTime.
Referenced by AddDirectEntry(), FREE::ControllerCentral::LoadLibrariesInPath(), FREE::ControllerCentral::RegisterController(), FREE::ControllerCentral::UnRegisterAllControllers(), and FREE::ControllerCentral::UnRegisterController().
| bool FREE::LogFileController::AddDirectEntry | ( | const std::string | sEntry | ) |
Adds an entry to the log file. If the log is not active the logfile will be opened. If the opening fails no entry will be done. After adding the entry, the log file will be closed. This function can be used when different threads used to add entries to a log file. The format of the entry depends on the setup of the controller, when m_InsertTime is true, a time information will be in front of the entry.
| [in] | sEntry | The new entry for the log. |
Definition at line 143 of file freLogFileController.cxx.
References AddEntry(), m_bActive, StartLog(), and StopLog().
Referenced by FREE::LogControllerException(), and FREE::LogException().

| bool FREE::LogFileController::AddEntry | ( | const std::string | sEntry, | |
| const bool | bAddTimeStamp | |||
| ) |
Adds an entry to the log file. If the log is not active no entry will be added. The format of the entry depends on the bAddTimeStamp value, passed with the function call. This function ignores the value of m_InsertTime, so it is a possibility to make and entry, ignoring the default setting, without the need to change it.
| [in] | sEntry | The new entry for the log. |
| [in] | bAddTimeStamp | Indicates if a time stamp should be added in front of the entry. |
Definition at line 109 of file freLogFileController.cxx.
References FREE::ActTimeStampToStr(), m_bActive, and m_LogFile.

| void FREE::LogFileController::SetFileName | ( | const std::string | sFileName | ) |
Sets the file name for the log, which should be managed by the controller. If the controller is already active (so has a file opened) while setting a new file name, the old log will be closed and a new log will be started. Only if it is the same file is set and the controller is set to append logs, the old log won't be closed.
| [in] | sFileName | file name (with path) of the log file. |
Definition at line 153 of file freLogFileController.cxx.
References m_sFileName, and StopLog().
Referenced by StartLog().

| const std::string FREE::LogFileController::GetFileName | ( | ) | const |
This function returns the filename of the current log file.
Definition at line 164 of file freLogFileController.cxx.
References m_sFileName.
| void FREE::LogFileController::SetHeader | ( | const std::string | sHeader | ) |
Sets the header of the log file.
| [in] | sHeader | The header of the log file, when it will be opened. |
Definition at line 171 of file freLogFileController.cxx.
References m_sHeader.
| const std::string FREE::LogFileController::GetHeader | ( | ) | const |
This function returns the header.
Definition at line 178 of file freLogFileController.cxx.
References m_sHeader.
| void FREE::LogFileController::SetInsertTimeStamp | ( | const bool | bTime | ) |
This function allows to control the entry style by force the controller to add a time stamp to the entry or not.
| [in] | bTime | Indicates, if a time stamp should be added to the entry. |
Definition at line 185 of file freLogFileController.cxx.
References m_bInsertTime.
| const bool FREE::LogFileController::GetInsertTimeStamp | ( | ) | const |
This function allows to check, if time stamps will be added to an entry.
Definition at line 193 of file freLogFileController.cxx.
References m_bInsertTime.
| void FREE::LogFileController::SetAppendFile | ( | const bool | bAppend | ) |
This function allows to control the behavior of the controller, if a log file already exists, by setting m_AppendFile. If m_AppendFile is true and the file already is present, the controller will append to the existing log. If m_AppendFile is false, the file will always be newly created, so already existence log will be overridden.
| [in] | bAppend | Indicates, if a log file should be appended. |
Definition at line 200 of file freLogFileController.cxx.
References m_bAppendFile.
| const bool FREE::LogFileController::GetAppendFile | ( | ) | const |
This function allows to check, if an existence log file will be extended (true) or overridden (false).
Definition at line 207 of file freLogFileController.cxx.
References m_bAppendFile.
| bool FREE::LogFileController::OpenLogFile | ( | ) | [private] |
This function opens the specified file by using CStdioFile.
Definition at line 242 of file freLogFileController.cxx.
References m_bActive, m_bAppendFile, m_LogFile, and m_sFileName.
Referenced by StartLog().
| bool FREE::LogFileController::CloseLogFile | ( | ) | [private] |
This function closes the specified file by using CStdioFile.
Definition at line 261 of file freLogFileController.cxx.
References m_bActive, and m_LogFile.
Referenced by StopLog().
std::string FREE::LogFileController::m_sFileName [private] |
The name of the logfile is function closes the specified file by using CStdioFile.
Definition at line 167 of file freLogFileController.h.
Referenced by GetFileName(), LogFileController(), OpenLogFile(), and SetFileName().
std::string FREE::LogFileController::m_sHeader [private] |
The name of the logfile is function closes the specified file by using CStdioFile.
Definition at line 171 of file freLogFileController.h.
Referenced by GetHeader(), LogFileController(), SetHeader(), and StartLog().
bool FREE::LogFileController::m_bActive [private] |
The state of the controller. If m_Active is true, there is a log file open and ready to use.
Definition at line 175 of file freLogFileController.h.
Referenced by Active(), AddDirectEntry(), AddEntry(), CloseLogFile(), LogFileController(), OpenLogFile(), StartLog(), StopLog(), and ~LogFileController().
bool FREE::LogFileController::m_bInsertTime [private] |
Indicates if a time stamp should be added to every entry. If it is true, a time stamp will be added.
Definition at line 179 of file freLogFileController.h.
Referenced by AddEntry(), GetInsertTimeStamp(), LogFileController(), and SetInsertTimeStamp().
bool FREE::LogFileController::m_bAppendFile [private] |
Indicates if a log file should be extended if it is reopened. If it is true, it will append the new entries to the old log.
Definition at line 183 of file freLogFileController.h.
Referenced by GetAppendFile(), LogFileController(), OpenLogFile(), and SetAppendFile().
std::ofstream FREE::LogFileController::m_LogFile [private] |
Filestream to the log file managed by the controller.
Definition at line 186 of file freLogFileController.h.
Referenced by AddEntry(), CloseLogFile(), OpenLogFile(), StartLog(), and StopLog().
1.5.3 written by Dimitri van Heesch,
© 1997-2000