Skip to content

Feature/loggerinterface

Emmanuel Promayon requested to merge feature/loggerinterface into develop

Add a proper logger for CamiTK applications

Steps to finish (refer to internal specification doc)

DONE

  • resolve conflicts
  • move new macros (currently in Application.h) to Log.h and include Log.h in Application.cpp not Application.h. In Log.h include Application.h, InterfaceLogger.h, and the macros
  • change NULL to nullptr in macros and tab to space
  • set static void setLogger(InterfaceLogger * logger) protected
  • set static InterfaceLogger * getLogger();
  • can we move applicationLogger to a static field of getLogger() to implement proper singleton. Use case to consider: an Application class deriving from camitk::Application does not want to use a CamiTKLogger instance but another type of logger. Will this strategy work. Ex: CamiTKSM constructor instanciate FooLogger and wants applicationLogger to reference this instanciate.
  • document CAMITK_STATIC_* macro or find another more simple way of taking into account loggin in static methods
  • log file directory should be defined by default and should be a tmp directory. There should a way to get the name of this directory in the GUI
  • CamiTKLogger::writeToFile should be true by default. Log file directory should be defined by default. CamiTKLogger has a new QFile field and a getLogFile()::QFile (and not setLogFile())
  • describe how CamiTKLogger works in api doc
  • is a static field QMutex mutex; in CamiTKLogger a good idea/practice?
  • rename buildLogLessage
  • modify log("Ahrrrrggghhhh.... Log Writer is being destructed !!! See you soon CamiTK !!! (now, closing files properly...)", InterfaceLogger::TRACE, NULL); in ~CamiTKLogger
  • check if ~CamiTKLogger is called or not
  • check if there is another solution than to have the log file constantly opened (might be a problem if application crash, the file might be destroyed/in a bad state). Check flush() is safe enough. Do not open/close file all the time
  • In LoggerSetting use application settings file to save message box level, log level, log file directory, write to standard out,
  • InterfaceLogger API → writeToDirectory → setLogDirectory + setWriteToFile(bool) (= test if directory is writable)
  • Add debug functionality using __LINE__ and __FILE__ (through an encapsulated bool field in InterfaceLogger)
  • setLogFileDirectory : add boolean, true by default. If true, move the previous log file to the new directory without changing its name and append to it
  • add boolean flag to enable/disable the timestamp

TODO

  • add CAMITK_DISABLE_LOG option (it should not be NDEBUG, as log should also be available for "Release"
  • have the console at the bottom of the main window + show/hide in the status bar + icon to show number of error/warning/info/trace like in atom editor
  • write test code for logger / verbosity level
  • Write a test application to unit test CamiTKLogger
Edited by Emmanuel Promayon

Merge request reports