17 #include <itkOutputWindow.h> 18 #include <itkSimpleFastMutexLock.h> 66 itk::OutputWindow::GetInstance()->DisplayText(
outputWindow->str().c_str());
86 mitkLogBackend =
nullptr;
95 std::string closedFileName;
110 MITK_INFO <<
"closing logfile (" << closedFileName <<
")";
122 logFile->open(file, std::ios_base::out | std::ios_base::app);
134 MITK_WARN <<
"opening logfile '" << file <<
"' for writing failed";
150 for (r = 1; r < argc; r++)
152 if (std::string(argv[r]) ==
"--logfile")
157 MITK_ERROR <<
"--logfile parameter found, but no file given";
163 for (r += 2; r < argc; r++)
164 argv[r - 2] = argv[r];
174 static const int numLogFiles = 10;
175 std::string newEmptyLogFileName;
189 s << prefixPath.c_str() <<
"-" << numLogFiles - 1 <<
".log";
193 int retVal = ::remove(s.str().c_str());
197 <<
"Problem while deleting the oldest log file. Maybe the access to this files is blocked. Aborting!";
203 for (
int r = numLogFiles - 1; r >= 1; r--)
205 std::stringstream dst;
206 dst << prefixPath.c_str() <<
"-" << r <<
".log";
208 std::stringstream src;
209 src << prefixPath.c_str() <<
"-" << r - 1 <<
".log";
214 int retVal = ::rename(src.str().c_str(), dst.str().c_str());
217 mitkThrow() <<
"Problem while renaming the log files. Maybe the access to this files is blocked. Aborting!";
225 s << prefixPath.c_str() <<
"-0.log";
232 bool returnValue =
false;
233 std::ifstream
File(filename.c_str());
static mitk::LoggingBackend * mitkLogBackend
void MBILOG_EXPORT UnregisterBackend(BackendBase *backend)
Unregisters a backend.
static void Register()
registers MITK logging backend at mbilog
static bool logOutputWindow
void ProcessMessage(const mbilog::LogMessage &) override
overloaded method for receiving log message from mbilog
mbilog::OutputType GetOutputType() const override
static itk::SimpleFastMutexLock logMutex
static void RotateLogFiles(const std::string &prefixPath)
Activates and handles a rolling log file with the given prefix and path. This method handles 10 log f...
static std::stringstream * outputWindow
static bool CheckIfFileExists(const std::string &filename)
An object of this class represents a single logging message (logging event) of the mbi logging mechan...
void MBILOG_EXPORT RegisterBackend(BackendBase *backend)
Registeres a backend to the mbi logging mechanism. If a backend is registered here, all mbilog messages are relayed to this backend through the method ProcessMessage. If no backend is registered the default backend is used.
mbilog backend implementation for mitk
static std::ofstream * logFile
static std::string IncrementLogFileNames(const std::string &prefixPath, int numLogFiles=10)
Increments the names of logfiles with the given prefixPath. This means, if the prefixPath is "myLogFi...
static void EnableAdditionalConsoleWindow(bool enable)
Enables an additional logging output window by means of itk::outputwindow This might be relevant for ...
static void SetLogFile(const char *file)
Sets extra log file path (additionally to the console log)
static void CatchLogFileCommandLineParameter(int &argc, char **argv)
Automatically extracts and removes the "--logfile <file>" parameters from the standard C main(argc...
static std::string GetLogFile()
static void Unregister()
Unregisters MITK logging backend at mbilog.
static std::string logFileName
void FormatFull(const LogMessage &l, int threadID=0)
Method formats the given LogMessage in the full/long format and writes it to std::cout.
void FormatSmart(const LogMessage &l, int threadID=0)
Method formats the given LogMessage in the smart/short format and writes it to std::cout.