Computer Assited Medical Intervention Tool Kit  version 5.0
CamiTKLogger.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2021 Univ. Grenoble Alpes, CNRS, Grenoble INP, 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 CAMITKLOGGER_H
27 #define CAMITKLOGGER_H
28 
29 // -- Core stuff
30 #include "CamiTKAPI.h"
31 #include "InterfaceLogger.h"
32 
33 // -- Qt stuff
34 #include <QDir>
35 #include <QDateTime>
36 class QFile;
37 class QTextStream;
38 
39 namespace camitk {
40 
124 
125 public :
127  CamiTKLogger();
128 
130  ~CamiTKLogger() override;
131 
134  LogLevel getLogLevel() override;
135 
138  void setLogLevel(LogLevel level) override;
139 
142  void setLogToStandardOutput(bool writeToStdOut) override;
143 
147  bool getLogToStandardOutput() override;
148 
156  bool setLogToFile(bool writeToFile) override;
157 
174  bool setLogFileDirectory(QDir directoryName, bool moveExistingLogFile = true) override;
175 
177  bool getLogToFile() override;
178 
180  QFileInfo getLogFileInfo() override;
181 
187  void setMessageBoxLevel(LogLevel level) override;
188 
190  LogLevel getMessageBoxLevel() override;
191 
196  void setDebugInformation(bool) override;
197 
199  bool getDebugInformation() override;
200 
206  void setTimeStampInformation(bool showTimeStamp) override;
207 
209  bool getTimeStampInformation() override;
210 
222  QString log(const QString msg, const LogLevel level, char const* fileName, char const* methodName, int lineNumber, const QObject* sender = nullptr) override final;
223 
224 
225 protected:
227  virtual QString buildLogMessage(QString message, LogLevel level, char const* fileName, char const* methodName, int lineNumber, const QObject* sender = nullptr);
228 
229 private:
231  QString getCamiTKAPIInformation(const QObject* sender);
232 
234  bool openLogFile(bool moveFile = false, QFileInfo fileToMove = QFileInfo());
235 
237  void closeLogFile();
238 
241 
244 
247 
249  bool logToFile;
250 
253 
256 
259 
261  QFile* logFile;
262 
264  QTextStream* logStream;
265 
267  QDateTime logStartTime;
268 
269 };
270 
271 }
272 
273 #endif // CAMITKLOGGER_H
camitk::CamiTKLogger::CamiTKLogger
CamiTKLogger()
Default constructor.
Definition: CamiTKLogger.cpp:72
camitk::CamiTKLogger::logFile
QFile * logFile
Current log file (the stream is flushed log message by log message)
Definition: CamiTKLogger.h:261
camitk::MainWindow::getName
QString getName() const
Get the main window title.
Definition: MainWindow.cpp:218
camitk::CamiTKLogger::logToStdOut
bool logToStdOut
is the logger currently writing everything to the standard output
Definition: CamiTKLogger.h:246
camitk::CamiTKLogger::displayDebugInformation
bool displayDebugInformation
display debug information (file/class name, method name and line number)
Definition: CamiTKLogger.h:252
CamiTKAPI.h
InterfaceLogger.h
camitk::CamiTKLogger::logFileDirectory
QDir logFileDirectory
Current directory for the log file.
Definition: CamiTKLogger.h:258
camitk::ComponentExtension
This class describes what is a generic Component extension. To add a ComponentExtension to CamiTK cor...
Definition: ComponentExtension.h:83
camitk::Action::getName
QString getName() const
get the name of the action
Definition: Action.h:338
Action.h
camitk::CamiTKLogger::logToFile
bool logToFile
is the logger currently writing everything to a file
Definition: CamiTKLogger.h:249
ActionExtension.h
Log.h
camitk::CamiTKLogger
This is the default logger for CamiTK.
Definition: CamiTKLogger.h:123
camitk::Action
Action class is an abstract class that enables you to build a action (generally on a component)....
Definition: Action.h:231
camitk::ViewerExtension::getName
virtual QString getName()=0
returns the viewer extension name (to be overriden in the derived class)
camitk::CamiTKLogger::level
InterfaceLogger::LogLevel level
current log level
Definition: CamiTKLogger.h:240
camitk::Application
The generic/default application. Once this class is intanciated in the main, everything is setup....
Definition: Application.h:82
camitk::CamiTKLogger::messageBoxLevel
InterfaceLogger::LogLevel messageBoxLevel
current level for message boxes
Definition: CamiTKLogger.h:243
ComponentExtension.h
camitk::CamiTKLogger::logStream
QTextStream * logStream
Current stream to output to the log file.
Definition: CamiTKLogger.h:264
camitk::Component::getName
QString getName() const override
get the name to be displayed
Definition: sdk/libraries/core/component/Component.h:907
ViewerExtension.h
camitk::InterfaceLogger::LogLevel
LogLevel
Definition: InterfaceLogger.h:60
camitk::CamiTKLogger::logStartTime
QDateTime logStartTime
instantiation time
Definition: CamiTKLogger.h:267
CamiTKLogger.h
camitk::CamiTKLogger::displayTimeStampInformation
bool displayTimeStampInformation
display time stamp information (in the form "yyyy-MM-dd HH:mm:ss.zzz")
Definition: CamiTKLogger.h:255
MainWindow.h
camitk::Application::getName
static QString getName()
get the application name
Definition: Application.cpp:203
camitk::MainWindow
This class is the base class for your application. It sets up the main window and creates a menubar,...
Definition: MainWindow.h:89
camitk::ActionExtension
This class describes what is a generic Action extension. To add a ActionExtension to CamiTK core,...
Definition: ActionExtension.h:80
camitk::Viewer
Viewer is an abstract class that is the base class for all viewers.
Definition: Viewer.h:180
Viewer.h
camitk::ViewerExtension
This class describes what is a generic Action extension. To add a ActionExtension to CamiTK core,...
Definition: ViewerExtension.h:108
camitk::ActionExtension::getName
virtual QString getName()=0
returns the action extension name (to be overriden in your ActionExtension)
camitk::ComponentExtension::getName
virtual QString getName() const =0
camitk::InterfaceLogger
The CamiTK logger interface provides a flexible tracing system to CamiTK applications....
Definition: InterfaceLogger.h:51
camitk::Component
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:302
Application.h
CAMITK_API
#define CAMITK_API
Definition: CamiTKAPI.h:49
camitk
Definition: Action.cpp:35