Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit caea5fcf authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

FIXED Log code cleaning step 1

Log class now separately hold the application logger, static singleton better managements,
lots of other fixes and code cleaning: include Log.h when needed, translator initialization,
build message with date, improved debugging information using macro __FILE__, __LINE__
and Qt's Q_FUNC_INFO, test applications silent log...
parent 4124acbb
......@@ -32,6 +32,7 @@
// includes from CamiTK
#include <Application.h>
#include <Log.h>
#include <ItkProgressObserver.h>
#include <itkImageToVTKImageFilter.h>
#include <itkVTKImageToImageFilter.h>
......
......@@ -52,7 +52,7 @@ QList<DicomSerie*> DicomParser::parseDirectory(const QString& directory) {
dicomImageScanner.AddTag(tagPixelData);
dicomImageScanner.Scan(fileNames);
CAMITK_STATIC_TRACE("DicomParser::parseDirectory(..): parsing files for DICOM image files");
CAMITK_BASIC_TRACE("DicomParser::parseDirectory(..): parsing files for DICOM image files");
foreach(std::string file, dicomImageScanner.GetFilenames()) {
// 1st check the file is a valid DICOM file
if (dicomImageScanner.IsKey(file.c_str())) {
......@@ -60,15 +60,15 @@ QList<DicomSerie*> DicomParser::parseDirectory(const QString& directory) {
gdcm::Scanner::TagToValue const& ttv = dicomImageScanner.GetMapping(file.c_str());
gdcm::Scanner::TagToValue::const_iterator it = ttv.find( tagPixelData );
if ( it != ttv.end() ) {
CAMITK_STATIC_TRACE("DicomParser::parseDirectory(..):" + QString::fromStdString(file) + " is a DICOM image file");
CAMITK_BASIC_TRACE("DicomParser::parseDirectory(..):" + QString::fromStdString(file) + " is a DICOM image file");
imageFileNames.push_back(file);
}
else {
CAMITK_STATIC_TRACE("DicomParser::parseDirectory(..)" + QString::fromStdString(file) + " is a DICOM file WITHOUT PixelData information");
CAMITK_BASIC_TRACE("DicomParser::parseDirectory(..)" + QString::fromStdString(file) + " is a DICOM file WITHOUT PixelData information");
}
}
else {
CAMITK_STATIC_TRACE("DicomParser::parseDirectory(..)" + QString::fromStdString(file) + " is not a valid DICOM file");
CAMITK_BASIC_TRACE("DicomParser::parseDirectory(..)" + QString::fromStdString(file) + " is not a valid DICOM file");
}
}
......@@ -225,7 +225,7 @@ double DicomParser::getZSpacing(const std::vector<std::string>& serieFileNames)
std::string file = serieFileNames.at(0);
const char* value = scanner.GetValue(file.c_str(), zSpacingTag);
if (!value) {
CAMITK_STATIC_ERROR("DicomParser::getZSpacing(..): no Z spacing found on image: " + QString::fromStdString(serieFileNames.at(0)));
CAMITK_BASIC_ERROR("DicomParser::getZSpacing(..): no Z spacing found on image: " + QString::fromStdString(serieFileNames.at(0)));
return 1.0;
}
return atof(value);
......
......@@ -25,15 +25,15 @@
#include "ItkImageComponentExtension.h"
#include "ItkImageComponent.h"
//-- CamiTK includes
#include <Log.h>
using namespace camitk;
// save to itk
#include <itkImageFileWriter.h>
#include <itkVTKImageToImageFilter.h>
//-- Qt
#include <QMessageBox>
// --------------- getName -------------------
QString ItkImageComponentExtension::getName() const {
return "ItkImages Component";
......@@ -282,7 +282,7 @@ template<class ImageType> bool ItkImageComponentExtension::saveImage(ImageCompon
writer->Update();
}
catch (const itk::ExceptionObject& err ) {
CAMITK_STATIC_ERROR("ItkImageComponentExtension::saveImage(): saving Error: problem occurs while saving file:" + filename + ": ITK Exception: " + err.what());
CAMITK_BASIC_ERROR("ItkImageComponentExtension::saveImage(): saving Error: problem occurs while saving file:" + filename + ": ITK Exception: " + err.what());
return false;
}
......
......@@ -25,6 +25,7 @@
#include "CloseAllAction.h"
#include <Application.h>
#include <Log.h>
using namespace camitk;
......
......@@ -24,7 +24,7 @@
****************************************************************************/
#include "LoggerSettings.h"
#include <Application.h>
#include <Log.h>
#include <Property.h>
#include <QFileDialog>
......@@ -57,7 +57,7 @@ QWidget * LoggerSettings::getWidget() {
ui.loggerLevelComboBox->addItem("WARNING");
ui.loggerLevelComboBox->addItem("INFO");
ui.loggerLevelComboBox->addItem("TRACE");
switch(Application::getLogger()->getLogLevel()) {
switch(Log::getLogger()->getLogLevel()) {
default:
case InterfaceLogger::NONE:
ui.loggerLevelComboBox->setCurrentText("NONE");
......@@ -81,7 +81,7 @@ QWidget * LoggerSettings::getWidget() {
ui.loggerMessageBoxLevelComboBox->addItem("WARNING");
ui.loggerMessageBoxLevelComboBox->addItem("INFO");
ui.loggerMessageBoxLevelComboBox->addItem("TRACE");
switch(Application::getLogger()->getMessageBoxLevel()) {
switch(Log::getLogger()->getMessageBoxLevel()) {
default:
case InterfaceLogger::NONE:
ui.loggerMessageBoxLevelComboBox->setCurrentText("NONE");
......@@ -100,9 +100,9 @@ QWidget * LoggerSettings::getWidget() {
break;
}
ui.writeLogOnSOCheckBox->setChecked(Application::getLogger()->getWriteToStandardOutput());
ui.writeLogOnSOCheckBox->setChecked(Log::getLogger()->getWriteToStandardOutput());
ui.logFileNameLineEdit->setText(Application::getLogger()->getLogFileFullPath());
ui.logFileNameLineEdit->setText(Log::getLogger()->getLogFileFullPath());
ui.logFileNameLineEdit->setEnabled(false);
ui.logMessageLineEdit->setText("Example of Log Message");
......@@ -130,36 +130,36 @@ void LoggerSettings::loggerLevelChanged() {
QString levelString = ui.loggerLevelComboBox->currentText();
InterfaceLogger::LogLevel logLevel = getLevelAsLogLevel(levelString);
Application::getLogger()->setLogLevel(logLevel);
Log::getLogger()->setLogLevel(logLevel);
}
void LoggerSettings::messageBoxlLevelChanged() {
QString levelString = ui.loggerMessageBoxLevelComboBox->currentText();
InterfaceLogger::LogLevel logLevel = getLevelAsLogLevel(levelString);
Application::getLogger()->writeToMessageBoxLevel(logLevel);
Log::getLogger()->writeToMessageBoxLevel(logLevel);
}
void LoggerSettings::writeOnStandardOutputChanged() {
bool writeOnStandardOutput = ui.writeLogOnSOCheckBox->isChecked();
Application::getLogger()->writeToStandardOutput(writeOnStandardOutput);
Log::getLogger()->writeToStandardOutput(writeOnStandardOutput);
}
void LoggerSettings::logDirectoryButtonClicked() {
bool signalState = ui.writeLogOnDirectoryLineEdit->blockSignals(true);
QString directory = QFileDialog::getExistingDirectory(NULL, "Please choose a directory where to save log file");
ui.writeLogOnDirectoryLineEdit->setText(directory);
Application::getLogger()->writeToDirectory(directory);
ui.logFileNameLineEdit->setText(Application::getLogger()->getLogFileFullPath());
Log::getLogger()->writeToDirectory(directory);
ui.logFileNameLineEdit->setText(Log::getLogger()->getLogFileFullPath());
ui.writeLogOnDirectoryLineEdit->blockSignals(signalState);
}
void LoggerSettings::logDirectoryTextEditChanged() {
QString directory = ui.writeLogOnDirectoryLineEdit->text();
Application::getLogger()->writeToDirectory(directory);
ui.logFileNameLineEdit->setText(Application::getLogger()->getLogFileFullPath());
Log::getLogger()->writeToDirectory(directory);
ui.logFileNameLineEdit->setText(Log::getLogger()->getLogFileFullPath());
}
......
......@@ -26,6 +26,7 @@
// CamiTK
#include <Application.h>
#include <Log.h>
#include <ExtensionManager.h>
// Qt
......
......@@ -22,11 +22,14 @@
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#include "OpenFile.h"
// CamiTK includes
#include <Application.h>
#include <ExtensionManager.h>
#include <Property.h>
#include "OpenFile.h"
#include <Log.h>
// Qt includes
#include <QFileDialog>
......
......@@ -30,6 +30,7 @@
#include <ImageComponentExtension.h>
#include <MeshComponent.h>
#include <MeshComponentExtension.h>
#include <Log.h>
#include <QFileDialog>
......
......@@ -31,8 +31,10 @@
// includes from CamiTK
#include <Application.h>
#include <Log.h>
// includes from VTK
#include <vtkExtractVOI.h>
#include <InteractiveViewer.h>
// local includes
#include "BoxVOIWidget.h"
......
......@@ -49,9 +49,7 @@
// CamiTK
#include <InteractiveViewer.h>
#include <Core.h>
// Deprecated. Use Appllication logger management instead
//#include <Log.h>
#include <Application.h>
#include <Log.h>
#include <InteractiveViewer.h>
#include <RendererWidget.h>
#include <ImageComponent.h>
......
......@@ -53,8 +53,7 @@
#include <MeshComponent.h>
#include <InteractiveViewer.h>
#include <RendererWidget.h>
// Deprecated. Use Appllication logger management instead
//#include <Log.h>
#include <Log.h>
using namespace camitk;
......
......@@ -30,13 +30,14 @@
#include <QString>
#include <QFileDialog>
#include <QTextStream>
// -- Qt XML stuff
#include <QtXml/QDomDocument>
#include <QtXml/QDomElement>
#include <QtXml/QDomNodeList>
// Deprecated. Use Appllication logger management instead
//#include <Log.h>
//-- CamiTK
#include <Log.h>
using namespace camitk;
......
......@@ -27,8 +27,8 @@
#include <MeshComponent.h>
#include <Application.h>
// Deprecated. Use Appllication logger management instead
//#include <Log.h>
#include <Log.h>
using namespace camitk;
#include <vtkUnstructuredGrid.h>
......
......@@ -26,6 +26,7 @@
#include "ChangeColor.h"
#include <Component.h>
#include <Log.h>
using namespace camitk;
......
......@@ -2,8 +2,7 @@
#include "ComputeNormals.h"
#include <Application.h>
#include <MeshComponent.h>
// Deprecated. Use Appllication logger management instead
//#include <Log.h>
#include <Log.h>
#include <Property.h>
// Vtk includes
......
......@@ -26,8 +26,7 @@
#include "ExtractSelection.h"
#include <MeshComponent.h>
// Deprecated. Use Appllication logger management instead
//#include <Log.h>
#include <Log.h>
#include <Application.h>
#include <vtkExtractSelection.h>
......
......@@ -25,8 +25,7 @@
#include "MeshPicking.h"
#include <MeshComponent.h>
// Deprecated. Use Appllication logger management instead
//#include <Log.h>
#include <Log.h>
#include <Application.h>
#include <InteractiveViewer.h>
using namespace camitk;
......
......@@ -24,8 +24,6 @@
****************************************************************************/
#include "MeshQuality.h"
#include <MeshComponent.h>
// Deprecated. Use Appllication logger management instead
//#include <Log.h>
#include <Application.h>
#include <InteractiveViewer.h>
using namespace camitk;
......
......@@ -24,7 +24,7 @@
****************************************************************************/
// CamiTK includes
#include "MeshToImageStencil.h"
#include <Application.h>
#include <Log.h>
#include <Property.h>
// Qt includes
......
......@@ -26,8 +26,7 @@
#include "RigidTransform.h"
#include <Component.h>
#include <InteractiveViewer.h>
// Deprecated. Use Appllication logger management instead
//#include <Log.h>
#include <Log.h>
#include <Application.h>
using namespace camitk;
......
Markdown is supported
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