|
@@ -22,6 +22,7 @@
|
|
|
#include <QThread>
|
|
|
|
|
|
// CTK includes
|
|
|
+#include "ctkErrorLogContext.h"
|
|
|
#include "ctkVTKErrorLogMessageHandler.h"
|
|
|
#include "ctkUtils.h"
|
|
|
|
|
@@ -42,7 +43,8 @@ public:
|
|
|
vtkTypeMacro(ctkVTKOutputWindow,vtkOutputWindow);
|
|
|
void PrintSelf(ostream& os, vtkIndent indent);
|
|
|
|
|
|
- ctkVTKOutputWindow():MessageHandler(0){}
|
|
|
+ ctkVTKOutputWindow():MessageHandler(0),
|
|
|
+ ContextRegExp("[a-zA-Z\\s]+: In (.+), line ([\\d]+)\\n(.+\\(0x[a-fA-F0-9]+\\))\\:\\s(.*)"){}
|
|
|
~ctkVTKOutputWindow(){}
|
|
|
|
|
|
virtual void DisplayText(const char*);
|
|
@@ -52,7 +54,11 @@ public:
|
|
|
|
|
|
virtual void DisplayDebugText(const char*);
|
|
|
|
|
|
+ QString parseText(const QString &text, ctkErrorLogContext &context);
|
|
|
+
|
|
|
ctkErrorLogAbstractMessageHandler * MessageHandler;
|
|
|
+
|
|
|
+ QRegExp ContextRegExp;
|
|
|
};
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
@@ -74,27 +80,35 @@ void ctkVTKOutputWindow::DisplayText(const char* text)
|
|
|
this->MessageHandler->handleMessage(
|
|
|
ctk::qtHandleToString(QThread::currentThreadId()),
|
|
|
ctkErrorLogLevel::Info,
|
|
|
- this->MessageHandler->handlerPrettyName(), text);
|
|
|
+ this->MessageHandler->handlerPrettyName(), ctkErrorLogContext(), text);
|
|
|
}
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
void ctkVTKOutputWindow::DisplayErrorText(const char* text)
|
|
|
{
|
|
|
Q_ASSERT(this->MessageHandler);
|
|
|
+
|
|
|
+ ctkErrorLogContext context;
|
|
|
+ QString textOnly = this->parseText(text, context);
|
|
|
+
|
|
|
this->MessageHandler->handleMessage(
|
|
|
ctk::qtHandleToString(QThread::currentThreadId()),
|
|
|
ctkErrorLogLevel::Error,
|
|
|
- this->MessageHandler->handlerPrettyName(), text);
|
|
|
+ this->MessageHandler->handlerPrettyName(), context, textOnly);
|
|
|
}
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
void ctkVTKOutputWindow::DisplayWarningText(const char* text)
|
|
|
{
|
|
|
Q_ASSERT(this->MessageHandler);
|
|
|
+
|
|
|
+ ctkErrorLogContext context;
|
|
|
+ this->parseText(text, context);
|
|
|
+
|
|
|
this->MessageHandler->handleMessage(
|
|
|
ctk::qtHandleToString(QThread::currentThreadId()),
|
|
|
ctkErrorLogLevel::Warning,
|
|
|
- this->MessageHandler->handlerPrettyName(), text);
|
|
|
+ this->MessageHandler->handlerPrettyName(), context, text);
|
|
|
}
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
@@ -107,10 +121,28 @@ void ctkVTKOutputWindow::DisplayGenericWarningText(const char* text)
|
|
|
void ctkVTKOutputWindow::DisplayDebugText(const char* text)
|
|
|
{
|
|
|
Q_ASSERT(this->MessageHandler);
|
|
|
+
|
|
|
+ ctkErrorLogContext context;
|
|
|
+ this->parseText(text, context);
|
|
|
+
|
|
|
this->MessageHandler->handleMessage(
|
|
|
ctk::qtHandleToString(QThread::currentThreadId()),
|
|
|
ctkErrorLogLevel::Debug,
|
|
|
- this->MessageHandler->handlerPrettyName(), text);
|
|
|
+ this->MessageHandler->handlerPrettyName(), context, text);
|
|
|
+}
|
|
|
+
|
|
|
+//----------------------------------------------------------------------------
|
|
|
+QString ctkVTKOutputWindow::parseText(const QString& text, ctkErrorLogContext& context)
|
|
|
+{
|
|
|
+ context.Message = text;
|
|
|
+ if (this->ContextRegExp.exactMatch(text))
|
|
|
+ {
|
|
|
+ context.File = this->ContextRegExp.cap(1);
|
|
|
+ context.Category = this->ContextRegExp.cap(3);
|
|
|
+ context.Line = this->ContextRegExp.cap(2).toInt();
|
|
|
+ context.Message = this->ContextRegExp.cap(4);
|
|
|
+ }
|
|
|
+ return context.Message;
|
|
|
}
|
|
|
|
|
|
} // End of anonymous namespace
|
|
@@ -197,4 +229,3 @@ void ctkVTKErrorLogMessageHandler::setEnabledInternal(bool value)
|
|
|
d->SavedVTKOutputWindow = 0;
|
|
|
}
|
|
|
}
|
|
|
-
|