Log backend implementation for MITK.
More...
#include <mitkLogBackend.h>
|
static void | Register () |
| Registers MITK log backend. More...
|
|
static void | Unregister () |
| Unregister MITK log backend. More...
|
|
static void | SetLogFile (const std::string &file) |
| Set extra log file path in addition to the console log. More...
|
|
static void | RotateLogFiles (const std::string &prefixPath) |
| Activates and handles a rolling log file with the given prefix and path. More...
|
|
static std::string | IncrementLogFileNames (const std::string &prefixPath, int numLogFiles=10) |
| Increment the names of logfiles with the given prefixPath. More...
|
|
static std::string | GetLogFile () |
|
static void | EnableAdditionalConsoleWindow (bool enable) |
| Enable an additional logging output window by means of itk::OutputWindow. More...
|
|
static void | CatchLogFileCommandLineParameter (int &argc, char **argv) |
| Automatically extract and remove the "--logfile <file>" parameters from the standard C main parameter list and calls SetLogFile if needed. More...
|
|
Log backend implementation for MITK.
Definition at line 23 of file mitkLogBackend.h.
◆ CatchLogFileCommandLineParameter()
static void mitk::LogBackend::CatchLogFileCommandLineParameter |
( |
int & |
argc, |
|
|
char ** |
argv |
|
) |
| |
|
static |
Automatically extract and remove the "--logfile <file>" parameters from the standard C main parameter list and calls SetLogFile if needed.
◆ CheckIfFileExists()
static bool mitk::LogBackend::CheckIfFileExists |
( |
const std::string & |
filename | ) |
|
|
staticprotected |
Check if a file exists.
- Returns
- Returns true if the file exists, false if not.
◆ EnableAdditionalConsoleWindow()
static void mitk::LogBackend::EnableAdditionalConsoleWindow |
( |
bool |
enable | ) |
|
|
static |
Enable an additional logging output window by means of itk::OutputWindow.
This might be relevant for showing log output in applications with no default output console.
◆ GetLogFile()
static std::string mitk::LogBackend::GetLogFile |
( |
| ) |
|
|
static |
- Returns
- Return the log file if there is one. Returns an empty string if no log file is active.
◆ GetOutputType()
◆ IncrementLogFileNames()
static std::string mitk::LogBackend::IncrementLogFileNames |
( |
const std::string & |
prefixPath, |
|
|
int |
numLogFiles = 10 |
|
) |
| |
|
static |
Increment the names of logfiles with the given prefixPath.
This means, if the prefixPath is "myLogFile" myLogFile-0.log is renamed to myLogFile-1.log, myLogFile-1.log to myLogFile-2.log, and so on. The oldest logfile is deleted. The number of log files is defined by the parameter "numLogFiles". The first logfile name is "free" (e.g., [prefix]-0.log) again. This name is returned.
- Parameters
-
prefixPath | Should hold the prefix of the logfile together with its path. E.g., "C:/programs/mitk/myLogFile". |
numLogFiles | Sets the number of logfiles. Default value is 10. This means logfiles from [prefix]-0.log to [prefix]-1.log are stored. |
- Returns
- Returns a new logfile name which is free again because the old first log file was renamed.
- Exceptions
-
mitk::Exception | Throws an exception if there is a problem with renaming the logfiles, e.g., because of file access problems. |
◆ ProcessMessage()
void mitk::LogBackend::ProcessMessage |
( |
const LogMessage & |
message | ) |
|
|
overridevirtual |
Called by the MITK log mechanism if the object is registered and a log message is emitted.
- Parameters
-
message | Logging message which was emitted. |
Implements mitk::LogBackendText.
◆ Register()
static void mitk::LogBackend::Register |
( |
| ) |
|
|
static |
Registers MITK log backend.
◆ RotateLogFiles()
static void mitk::LogBackend::RotateLogFiles |
( |
const std::string & |
prefixPath | ) |
|
|
static |
Activates and handles a rolling log file with the given prefix and path.
This method handles 10 log files with a given prefix, e.g. "myLogFile". The 10 log files will then look like this:
-
myLogFile-0.log (current file)
-
myLogFile-1.log (last file)
-
myLogFile-2.log
-
[...]
-
myLogFile-9.log
Everytime this method this called, normally when MITK is started, then all log files are copied one file below (0 to 1, 1 to 2, and so on). The oldest logfile (number 9) is always deleted. So users have access to the log files of the last 10 runs.
- Exceptions
-
mitk::Exception | Throws an exception if there is a problem with renaming the logfiles, e.g., because of file access problems. |
- Parameters
-
prefixPath | Should hold the prefix of the logfile together with its path. E.g., "C:/programs/mitk/myLogFile". |
◆ SetLogFile()
static void mitk::LogBackend::SetLogFile |
( |
const std::string & |
file | ) |
|
|
static |
Set extra log file path in addition to the console log.
◆ Unregister()
static void mitk::LogBackend::Unregister |
( |
| ) |
|
|
static |
Unregister MITK log backend.
The documentation for this class was generated from the following file: