Computer Assisted Medical Intervention Tool Kit  version 5.2
InterfaceLogger.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2024 Univ. Grenoble Alpes, CNRS, Grenoble INP - UGA, TIMC, 38000 Grenoble, France
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 
26 #ifndef INTERFACELOGGER_H
27 #define INTERFACELOGGER_H
28 
29 // -- Core stuff
30 #include "CamiTKAPI.h"
31 
32 class QObject;
33 
34 #include <QDir>
35 #include <QFileInfo>
36 
37 namespace camitk {
38 
52 
53 public:
54 
55 #ifdef ERROR
56 #define CAMITK_WINDOWS_SYSTEM_ERROR_SAFEGUARD ERROR
57 #undef ERROR
58 #endif
60  enum LogLevel {
61  NONE = 0,
62  ERROR = 1,
63  WARNING = 2,
64  INFO = 3,
65  TRACE = 4,
66  };
67 
68 #ifdef CAMITK_WINDOWS_SYSTEM_ERROR_SAFEGUARD
69 #define ERROR CAMITK_WINDOWS_SYSTEM_ERROR_SAFEGUARD
70 #endif
71 
73  virtual ~InterfaceLogger() = default;
74 
77  virtual LogLevel getLogLevel() = 0;
78 
81  virtual void setLogLevel(LogLevel level) = 0;
82 
85  virtual void setLogToStandardOutput(bool writeToStdOut) = 0;
86 
90  virtual bool getLogToStandardOutput() = 0;
91 
99  virtual bool setLogToFile(bool writeToFile) = 0;
100 
114  virtual bool setLogFileDirectory(QDir directoryName, bool moveExistingLogFile = true) = 0;
115 
117  virtual bool getLogToFile() = 0;
118 
120  virtual QFileInfo getLogFileInfo() = 0;
121 
125  virtual void setMessageBoxLevel(LogLevel level) = 0;
126 
129 
134  virtual void setDebugInformation(bool) = 0;
135 
137  virtual bool getDebugInformation() = 0;
138 
144  virtual void setTimeStampInformation(bool showTimeStamp) = 0;
145 
147  virtual bool getTimeStampInformation() = 0;
148 
160  virtual QString log(const QString msg, const LogLevel level, char const* fileName, char const* methodName, int lineNumber, const QObject* sender = nullptr) = 0;
161 };
162 
163 }
164 
165 #endif // INTERFACELOGGER_H
#define CAMITK_API
Definition: CamiTKAPI.h:49
The CamiTK logger interface provides a flexible tracing system to CamiTK applications.
Definition: InterfaceLogger.h:51
virtual LogLevel getMessageBoxLevel()=0
virtual void setDebugInformation(bool)=0
Allows the logger to add debug information to the log message.
virtual bool getLogToFile()=0
check if the logger is currently writing on a file
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....
virtual void setMessageBoxLevel(LogLevel level)=0
Set the lowest log level that will open modal message box for messages instead of (silently/undisrupt...
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...
virtual void setLogToStandardOutput(bool writeToStdOut)=0
Allows the logger to write on std::cout.
virtual ~InterfaceLogger()=default
empty virtual destructor, to avoid memory leak
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 ...
virtual bool getLogToStandardOutput()=0
check if the logger is currently writing on standard output (std::cout)
virtual void setLogLevel(LogLevel level)=0
Sets Current verbosity level of the log.
virtual bool getTimeStampInformation()=0
virtual bool getDebugInformation()=0
virtual LogLevel getLogLevel()=0
Get the current verbosity level of the log.
virtual bool setLogToFile(bool writeToFile)=0
Ask the logger to write to the log file.
virtual QFileInfo getLogFileInfo()=0
LogLevel
: how chatty should the log output be...
Definition: InterfaceLogger.h:60
Definition: Action.cpp:36