QtDataSync  4.2.0
A simple offline-first synchronisation framework, to synchronize data of Qt applications between devices
logger.h
Go to the documentation of this file.
1 #ifndef QTDATASYNC_LOGGER_H
2 #define QTDATASYNC_LOGGER_H
3 
4 #include <QtCore/qglobal.h>
5 #include <QtCore/qdebug.h>
6 #include <QtCore/qloggingcategory.h>
7 
8 #include "QtDataSync/qtdatasync_global.h"
9 
10 namespace QtDataSync {
11 
12 class LoggerPrivate;
14 class Q_DATASYNC_EXPORT Logger : public QObject
15 {
16  Q_OBJECT
17 
18 public:
20  explicit Logger(QByteArray subCategory, const QString &setupName, QObject *parent = nullptr);
21  ~Logger() override;
22 
24  const QLoggingCategory &loggingCategory() const;
25 
27  Q_NORETURN void reportFatalError(const QString &error, const char *file, int line, const char *function);
29  Q_NORETURN void reportFatalError(const char *error, const char *file, int line, const char *function);
30 
31 private:
33 };
34 
35 }
36 
38 #define QT_DATASYNC_LOG_BASE QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC)
39 #define QT_DATASYNC_LOG_CAT QTDATASYNC_LOG->loggingCategory()
41 #define logDebug() QT_DATASYNC_LOG_BASE.debug(QT_DATASYNC_LOG_CAT)
43 #define logInfo() QT_DATASYNC_LOG_BASE.info(QT_DATASYNC_LOG_CAT)
45 #define logWarning() QT_DATASYNC_LOG_BASE.warning(QT_DATASYNC_LOG_CAT)
47 #define logCritical() QT_DATASYNC_LOG_BASE.critical(QT_DATASYNC_LOG_CAT)
49 #define logFatal(error) QTDATASYNC_LOG->reportFatalError(error, QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC)
51 
53 #endif // QTDATASYNC_LOGGER_H
The primary namespace of the QtDataSync library.
A Helper class for simple and structured logging.
Definition: logger.h:14