mbilog backend implementation for mitk More...
#include <mitkLog.h>


Public Member Functions | |
| void | ProcessMessage (const mbilog::LogMessage &) |
| overloaded method for receiving log message from mbilog | |
Static Public Member Functions | |
| static void | Register () |
| registers MITK logging backend at mbilog | |
| static void | Unregister () |
| Unregisters MITK logging backend at mbilog. | |
| static void | SetLogFile (const char *file) |
| Sets extra log file path (additionally to the console log) | |
| static void | EnableAdditionalConsoleWindow (bool enable) |
| Enables 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. | |
| static void | CatchLogFileCommandLineParameter (int &argc, char **argv) |
| Automatically extracts and removes the "--logfile <file>" parameters from the standard C main(argc,argv) parameter list and calls SetLogFile if needed. | |
mbilog backend implementation for mitk
Definition at line 30 of file mitkLog.h.
| void mitk::LoggingBackend::CatchLogFileCommandLineParameter | ( | int & | argc, |
| char ** | argv | ||
| ) | [static] |
Automatically extracts and removes the "--logfile <file>" parameters from the standard C main(argc,argv) parameter list and calls SetLogFile if needed.
Definition at line 121 of file mitkLog.cpp.
References MITK_ERROR, and SetLogFile().
{
int r;
for(r=1;r<argc;r++)
{
if(std::string(argv[r])=="--logfile")
{
if(r+1>=argc)
{
--argc;
MITK_ERROR << "--logfile parameter found, but no file given";
return;
}
mitk::LoggingBackend::SetLogFile(argv[r+1]);
for(r+=2;r<argc;r++)
argv[r-2]=argv[r];
argc-=2;
return;
}
}
}
| void mitk::LoggingBackend::EnableAdditionalConsoleWindow | ( | bool | enable ) | [static] |
Enables 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.
Definition at line 32 of file mitkLog.cpp.
References logOutputWindow.
{
logOutputWindow = enable;
}
| void mitk::LoggingBackend::ProcessMessage | ( | const mbilog::LogMessage & | l ) | [virtual] |
overloaded method for receiving log message from mbilog
Implements mbilog::AbstractBackend.
Definition at line 38 of file mitkLog.cpp.
References mbilog::BackendCout::FormatFull(), mbilog::BackendCout::FormatSmart(), logFile, logMutex, logOutputWindow, and outputWindow.
{
logMutex.Lock();
#ifdef _WIN32
mbilog::BackendCout::FormatSmart( l, (int)GetCurrentThreadId() );
#else
mbilog::BackendCout::FormatSmart( l );
#endif
if(logFile)
{
#ifdef _WIN32
mbilog::BackendCout::FormatFull( *logFile, l, (int)GetCurrentThreadId() );
#else
mbilog::BackendCout::FormatFull( *logFile, l );
#endif
}
if(logOutputWindow)
{
if(outputWindow == NULL)
{ outputWindow = new std::stringstream();}
outputWindow->str("");
outputWindow->clear();
#ifdef _WIN32
mbilog::BackendCout::FormatFull( *outputWindow, l, (int)GetCurrentThreadId() );
#else
mbilog::BackendCout::FormatFull( *outputWindow, l );
#endif
itk::OutputWindow::GetInstance()->DisplayText(outputWindow->str().c_str());
}
logMutex.Unlock();
}
| void mitk::LoggingBackend::Register | ( | ) | [static] |
registers MITK logging backend at mbilog
Definition at line 71 of file mitkLog.cpp.
References mbilog::RegisterBackend().
Referenced by main().
{
if(mitkLogBackend)
return;
mitkLogBackend = new mitk::LoggingBackend();
mbilog::RegisterBackend( mitkLogBackend );
}
| void mitk::LoggingBackend::SetLogFile | ( | const char * | file ) | [static] |
Sets extra log file path (additionally to the console log)
Definition at line 90 of file mitkLog.cpp.
References logFile, logMutex, and MITK_INFO.
Referenced by CatchLogFileCommandLineParameter().
{
logMutex.Lock();
if(logFile)
{
MITK_INFO << "closing logfile";
logFile->close();
delete logFile;
logFile = 0;
}
if(file)
{
logFile = new std::ofstream( file, std::ios_base::out | std::ios_base::app );
/*
if(*logFile)
{
std::cout << "opening logfile '" << file << "' for writing failed";
MITK_INFO << "logging to '" << file << "'";
}
else
{
std::cerr << "opening logfile '" << file << "' for writing failed";
MITK_ERROR << "opening logfile '" << file << "' for writing failed";
delete logFile;
logFile = 0;
}
*/
}
logMutex.Unlock();
}
| void mitk::LoggingBackend::Unregister | ( | ) | [static] |
Unregisters MITK logging backend at mbilog.
Definition at line 79 of file mitkLog.cpp.
References mitkLogBackend, and mbilog::UnregisterBackend().
Referenced by main().
{
if(mitkLogBackend)
{
SetLogFile(0);
mbilog::UnregisterBackend( mitkLogBackend );
delete mitkLogBackend;
mitkLogBackend=0;
}
}
1.7.2