Computer Assisted Medical Intervention Tool Kit  version 5.2
camitk::InterfaceLogger Class Referenceabstract

The CamiTK logger interface provides a flexible tracing system to CamiTK applications. More...

#include <InterfaceLogger.h>

+ Inheritance diagram for camitk::InterfaceLogger:
+ Collaboration diagram for camitk::InterfaceLogger:

Public Types

enum  LogLevel {
  NONE = 0 , ERROR = 1 , WARNING = 2 , INFO = 3 ,
  TRACE = 4
}
 : how chatty should the log output be... More...
 

Public Member Functions

virtual bool getDebugInformation ()=0
 
virtual QFileInfo getLogFileInfo ()=0
 
virtual LogLevel getLogLevel ()=0
 Get the current verbosity level of the log. More...
 
virtual bool getLogToFile ()=0
 check if the logger is currently writing on a file More...
 
virtual bool getLogToStandardOutput ()=0
 check if the logger is currently writing on standard output (std::cout) More...
 
virtual LogLevel getMessageBoxLevel ()=0
 
virtual bool getTimeStampInformation ()=0
 
virtual QString log (const QString msg, const LogLevel level, char const *fileName, char const *methodName, int lineNumber, const QObject *sender=nullptr)=0
 Log a message: If the logger is allowed to write on standard output, it will display the message (and timestamp) on the standard output If the logger is allowed to write on a file, it will also display the message in the log file. More...
 
virtual void setDebugInformation (bool)=0
 Allows the logger to add debug information to the log message. More...
 
virtual bool setLogFileDirectory (QDir directoryName, bool moveExistingLogFile=true)=0
 Set the specific directory to write to (default is the subdirectory "CamiTK" in the system temporary directory). More...
 
virtual void setLogLevel (LogLevel level)=0
 Sets Current verbosity level of the log. More...
 
virtual bool setLogToFile (bool writeToFile)=0
 Ask the logger to write to the log file. More...
 
virtual void setLogToStandardOutput (bool writeToStdOut)=0
 Allows the logger to write on std::cout. More...
 
virtual void setMessageBoxLevel (LogLevel level)=0
 Set the lowest log level that will open modal message box for messages instead of (silently/undisruptedly) write on std output. More...
 
virtual void setTimeStampInformation (bool showTimeStamp)=0
 By default a logger should always show the time-stamp in the form of "yyyy-MM-dd HH:mm:ss.zzz" In test environment, reproducible log message might be prefered. More...
 
virtual ~InterfaceLogger ()=default
 empty virtual destructor, to avoid memory leak More...
 

Detailed Description

The CamiTK logger interface provides a flexible tracing system to CamiTK applications.

Messages can logged on the standard output or on a file (or both) and can also show QMessageBox dialog.

CamiTK Logger Interface defines the API for all logger used by CamiTK applications.

For more information about how to use log

See also
Log and CamiTKLogger

Member Enumeration Documentation

◆ LogLevel

: how chatty should the log output be...

See also
getLogLevel()
Enumerator
NONE 

No message is logged.

ERROR 

Only error messages are logged.

WARNING 

Only Warning and Error messages are logged.

INFO 

information, warning and error messages are logged

TRACE 

all types of messages are logged

Constructor & Destructor Documentation

◆ ~InterfaceLogger()

virtual camitk::InterfaceLogger::~InterfaceLogger ( )
virtualdefault

empty virtual destructor, to avoid memory leak

Member Function Documentation

◆ getDebugInformation()

virtual bool camitk::InterfaceLogger::getDebugInformation ( )
pure virtual
Returns
true if the logger is currently printing the debug information in the log message.

Implemented in camitk::CamiTKLogger.

◆ getLogFileInfo()

virtual QFileInfo camitk::InterfaceLogger::getLogFileInfo ( )
pure virtual
Returns
the current file information about the current log file

Implemented in camitk::CamiTKLogger.

◆ getLogLevel()

virtual LogLevel camitk::InterfaceLogger::getLogLevel ( )
pure virtual

Get the current verbosity level of the log.

Implemented in camitk::CamiTKLogger.

◆ getLogToFile()

virtual bool camitk::InterfaceLogger::getLogToFile ( )
pure virtual

check if the logger is currently writing on a file

Implemented in camitk::CamiTKLogger.

◆ getLogToStandardOutput()

virtual bool camitk::InterfaceLogger::getLogToStandardOutput ( )
pure virtual

check if the logger is currently writing on standard output (std::cout)

Returns
true if the logger is currently writing on std output, false otherwise.

Implemented in camitk::CamiTKLogger.

◆ getMessageBoxLevel()

virtual LogLevel camitk::InterfaceLogger::getMessageBoxLevel ( )
pure virtual
Returns
get the current lowest log level that will generate modal message box

Implemented in camitk::CamiTKLogger.

◆ getTimeStampInformation()

virtual bool camitk::InterfaceLogger::getTimeStampInformation ( )
pure virtual
Returns
true if the logger is currently printing the time stamp information in the log messages.

Implemented in camitk::CamiTKLogger.

◆ log()

virtual QString camitk::InterfaceLogger::log ( const QString  msg,
const LogLevel  level,
char const *  fileName,
char const *  methodName,
int  lineNumber,
const QObject *  sender = nullptr 
)
pure virtual

Log a message: If the logger is allowed to write on standard output, it will display the message (and timestamp) on the standard output If the logger is allowed to write on a file, it will also display the message in the log file.

The level parameter gives the current message level that has to be compared with the logger level: if this level is greater or equals to the current log level, the current message will be logged.

Example: if the logger level is at WARNING, only ERROR and WARNING level messages will be displayed.

If in a static method or a non QObject class, then call this method with an empty last parameter.

Implemented in camitk::CamiTKLogger.

◆ setDebugInformation()

virtual void camitk::InterfaceLogger::setDebugInformation ( bool  )
pure virtual

Allows the logger to add debug information to the log message.

Debug information contains the filename, line number and method names where the log was called. Note that the exact content of the method name debug information depends on the compiler.

Implemented in camitk::CamiTKLogger.

Referenced by main().

+ Here is the caller graph for this function:

◆ setLogFileDirectory()

virtual bool camitk::InterfaceLogger::setLogFileDirectory ( QDir  directoryName,
bool  moveExistingLogFile = true 
)
pure virtual

Set the specific directory to write to (default is the subdirectory "CamiTK" in the system temporary directory).

If the log directory is different than the existing one:

  • if moveExistingLogFile is true (default), the current log file is moved to the new directory, new messages will be appened
  • if moveExistingLogFile is false, a new log file is generated, previous log file is kept untouched in the previous temporary directory
Parameters
directoryNamethe new directory to use for the log file
moveExistingLogFileif true, the existing log file is move to the new directory and use to append the log messages from now.
Returns
if the logger is already logging to a file, returns true if the log file could have been created in the given directory, otherwise returns the log to file status.

Implemented in camitk::CamiTKLogger.

Referenced by main().

+ Here is the caller graph for this function:

◆ setLogLevel()

virtual void camitk::InterfaceLogger::setLogLevel ( LogLevel  level)
pure virtual

Sets Current verbosity level of the log.

Implemented in camitk::CamiTKLogger.

Referenced by main().

+ Here is the caller graph for this function:

◆ setLogToFile()

virtual bool camitk::InterfaceLogger::setLogToFile ( bool  writeToFile)
pure virtual

Ask the logger to write to the log file.

By default, the directory to write to is the subdirectory "CamiTK" in the system temporary directory. The file name itself will be determined by the logger.

Returns
true if the logger is going to log into the file (if the parameter is true, it also means that there was no error in opening the logfile for writing in the log file directory)

Implemented in camitk::CamiTKLogger.

Referenced by main().

+ Here is the caller graph for this function:

◆ setLogToStandardOutput()

virtual void camitk::InterfaceLogger::setLogToStandardOutput ( bool  writeToStdOut)
pure virtual

Allows the logger to write on std::cout.

Implemented in camitk::CamiTKLogger.

◆ setMessageBoxLevel()

virtual void camitk::InterfaceLogger::setMessageBoxLevel ( LogLevel  level)
pure virtual

Set the lowest log level that will open modal message box for messages instead of (silently/undisruptedly) write on std output.

Implemented in camitk::CamiTKLogger.

Referenced by main().

+ Here is the caller graph for this function:

◆ setTimeStampInformation()

virtual void camitk::InterfaceLogger::setTimeStampInformation ( bool  showTimeStamp)
pure virtual

By default a logger should always show the time-stamp in the form of "yyyy-MM-dd HH:mm:ss.zzz" In test environment, reproducible log message might be prefered.

In this case the time stamp can be disabled.

Parameters
showTimeStampif false the time stamp is not printed in log message.

Implemented in camitk::CamiTKLogger.

Referenced by main().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: