Commit 1c3b1c70 authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

NEW more CamiTK class information prepend

parent 362f220f
......@@ -23,11 +23,9 @@
* $CAMITK_LICENCE_END$
****************************************************************************/
#ifndef ACTION_EXTENSION_H
#define ACTION_EXTENSION_H
#include "CamiTKAPI.h"
// -- QT stuff
......
......@@ -30,6 +30,8 @@
#include "Viewer.h"
#include "Application.h"
#include "MainWindow.h"
#include "ActionExtension.h"
#include "ComponentExtension.h"
#include "Log.h"
#include <iostream>
......@@ -340,24 +342,37 @@ QString CamiTKLogger::getCamiTKAPIInformation(const QObject* sender) {
return QString(camitkComponent->metaObject()->className()) + " \"" + camitkComponent->getName() + "\" - ";
}
// sender is a ActionExtension
QObject *nonConstSender = const_cast<QObject*>(sender); // beware!
camitk::ActionExtension* camitkActionExt = dynamic_cast<camitk::ActionExtension*>(nonConstSender);
if (camitkActionExt != nullptr) {
return QString("Action Extension \"") + camitkActionExt->getName() + "\" - ";
}
// sender is a ComponentExtension
const camitk::ComponentExtension* camitkComponentExt = dynamic_cast<const camitk::ComponentExtension*>(sender);
if (camitkComponentExt != nullptr) {
return QString("Component Extension \"") + camitkComponentExt->getName() + "\" - ";
}
// sender is an application
const camitk::Application* camitkApplication = dynamic_cast<const camitk::Application*>(sender);
if (camitkApplication != nullptr) {
return QString("Application \"") + camitkApplication->getName() + "\" - ";
}
// sender in a main window
// sender is a main window
const camitk::MainWindow* camitkMainWindow = dynamic_cast<const camitk::MainWindow*>(sender);
if (camitkMainWindow != nullptr) {
return QString("Main Window \"") + camitkMainWindow->getName() + "\" - ";
}
// sender in a viewer
// sender is a viewer
const camitk::Viewer* camitkViewer = dynamic_cast<const camitk::Viewer*>(sender);
if (camitkViewer != nullptr) {
return QString("Viewer \"") + camitkViewer->objectName() + "\" - ";
}
return "";
}
......
......@@ -102,8 +102,22 @@ namespace camitk {
* ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^
* ^if time stamp shown ^ if debug info shown
*
* Moreover, if the log macro is used inside an Action, then message is prepend with "Action \"Action Name\":"
* Moreover, if the log macro is used inside a CamiTK inherited class (e.g., Action, Component,...)
* then message is prepend with a specific text (see below)
*
* \note About log macro used inside a CamiTK inherited class
* If the log macro is used in a CamiTK inherited class, then it will automatically be prepend with
* a specific text.
*
* For example:
* - if a log macro is called from a camitk::Action or any class inheriting from camitk::Action
* then the text "Action 'MyActionName' - " is automatically added at the beginning of the log message
* - if a log macro is called from a camitk::Component or any subclass, then the text
* "Component 'MyComponentName' - " is automatically added at the beginning of the log message
* - ...
*
* Action, Component, Viewer, Application, MainWindow, ComponentExtension and ActionExtension are
* currently supported.
*/
class CAMITK_API CamiTKLogger : public InterfaceLogger {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment