Computer Assisted Medical Intervention Tool Kit  version 6.0
Loading...
Searching...
No Matches
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-2025 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 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>
36class QFile;
37class QTextStream;
38
39namespace camitk {
40
123
125
126public :
128 CamiTKLogger();
129
131 ~CamiTKLogger() override;
132
135 LogLevel getLogLevel() override;
136
139 void setLogLevel(LogLevel level) override;
140
143 void setLogToStandardOutput(bool writeToStdOut) override;
144
148 bool getLogToStandardOutput() override;
149
157 bool setLogToFile(bool writeToFile) override;
158
175 bool setLogFileDirectory(QDir directoryName, bool moveExistingLogFile = true) override;
176
178 bool getLogToFile() override;
179
181 QFileInfo getLogFileInfo() override;
182
188 void setMessageBoxLevel(LogLevel level) override;
189
191 LogLevel getMessageBoxLevel() override;
192
197 void setDebugInformation(bool) override;
198
200 bool getDebugInformation() override;
201
207 void setTimeStampInformation(bool showTimeStamp) override;
208
210 bool getTimeStampInformation() override;
211
223 QString log(const QString msg, const LogLevel level, char const* fileName, char const* methodName, int lineNumber, const QObject* sender = nullptr) override final;
224
225
226protected:
228 virtual QString buildLogMessage(QString message, LogLevel level, char const* fileName, char const* methodName, int lineNumber, const QObject* sender = nullptr);
229
230private:
232 QString getCamiTKAPIInformation(const QObject* sender);
233
235 bool openLogFile(bool moveFile = false, QFileInfo fileToMove = QFileInfo());
236
238 void closeLogFile();
239
242
244 InterfaceLogger::LogLevel messageBoxLevel;
245
247 bool logToStdOut;
248
250 bool logToFile;
251
253 bool displayDebugInformation;
254
256 bool displayTimeStampInformation;
257
259 QDir logFileDirectory;
260
262 QFile* logFile;
263
265 QTextStream* logStream;
266
268 QDateTime logStartTime;
269
270};
271
272}
273
274#endif // CAMITKLOGGER_H
#define CAMITK_API
Definition CamiTKAPI.h:66
QFileInfo getLogFileInfo() override
Definition CamiTKLogger.cpp:197
bool getTimeStampInformation() override
Definition CamiTKLogger.cpp:241
bool getLogToStandardOutput() override
check if the logger is currently writing on standard output (std::cout)
Definition CamiTKLogger.cpp:90
LogLevel getLogLevel() override
Get Current verbosity level of the log:
Definition CamiTKLogger.cpp:69
void setMessageBoxLevel(LogLevel level) override
Set the lowest log level that will open a modal message box for messages instead of simply (silently/...
Definition CamiTKLogger.cpp:207
void setDebugInformation(bool) override
Allows the logger to add debug information to the log message.
Definition CamiTKLogger.cpp:220
virtual QString buildLogMessage(QString message, LogLevel level, char const *fileName, char const *methodName, int lineNumber, const QObject *sender=nullptr)
Builds a log message of correct format.
Definition CamiTKLogger.cpp:300
LogLevel getMessageBoxLevel() override
Definition CamiTKLogger.cpp:215
bool setLogToFile(bool writeToFile) override
Allows the logger to write to the log file.
Definition CamiTKLogger.cpp:95
QString log(const QString msg, const LogLevel level, char const *fileName, char const *methodName, int lineNumber, const QObject *sender=nullptr) override final
Log a message: If the logger is allowed to write on standard output, it will display the message (and...
Definition CamiTKLogger.cpp:246
bool getDebugInformation() override
Definition CamiTKLogger.cpp:228
void setLogLevel(LogLevel level) override
Sets Current verbosity level of the log:
Definition CamiTKLogger.cpp:74
bool setLogFileDirectory(QDir directoryName, bool moveExistingLogFile=true) override
Set the specific directory to write to (default is the subdirectory "CamiTK" in the system temporary ...
Definition CamiTKLogger.cpp:111
CamiTKLogger()
Default constructor.
Definition CamiTKLogger.cpp:49
void setLogToStandardOutput(bool writeToStdOut) override
Allows the logger to write on std::cout.
Definition CamiTKLogger.cpp:82
bool getLogToFile() override
check if the logger is currently writing on a file
Definition CamiTKLogger.cpp:132
void setTimeStampInformation(bool showTimeStamp) override
By default a logger should always show the time-stamp in the form of "yyyy-MM-dd HH:mm:ss....
Definition CamiTKLogger.cpp:233
The CamiTK logger interface provides a flexible tracing system to CamiTK applications.
Definition InterfaceLogger.h:51
LogLevel
: how chatty should the log output be...
Definition InterfaceLogger.h:60
Definition Action.cpp:40