- NGL_ADD_LIBRARY2: 87 CMakeLists.txt konvertiert für Export-Header Generierung - 44 Export-Header Include-Pfade korrigiert (_export.h) - 81 DDS-Stub-Header generiert (*_dtc.h, *_fts.h, *_dts.h, *_ftc.h) - INGLLogger: Duplikat gelöscht, m_logger Member entfernt, variadische Makros - Q_FUNC_INFO Redefinition behoben (Qt6 definiert bereits) - FATAL_LOG Makro hinzugefügt - InfrastructureManagement DDS-Stubs (ism.hpp, ism_enums.hpp, ism_ftc.h) - FilterManagement DDS-Stubs (flt_ftc.h, flt_dts.h) - AreaEffectSimulation DDS-Stubs (aes.hpp, aes_enums.hpp) - SymbolAppearance Klasse vollständig definiert mit content() Methode - BuildingComponentFilter Klasse definiert mit Copy-Konstruktor - Ftc Factory: nullptr Return (abstract class) - AesFilter Klasse in aes.hpp hinzugefügt - Dtc Klasse in ppm.hpp mit participantChanged Signal - AesType Enum: alle 15 At* Werte definiert - AesEffectState_def: EsReceived hinzugefügt - DataModification Enum: eAdded/eModified/eRemoved - function_reply_object.h → core_types.h Include-Pfad (72 Dateien) - Enum-Class-Streaming Template-Operator in INGLLogger.h - ism_mounting_point.h: QImage → QtGui/QImage, QGuiApplication/QScreen - ism_data_plugin_interface.h: QSet Include, Include-Reihenfolge - QRegExp → QRegularExpression in tpm_js_parser.cpp - .underlying() Aufrufe zu direktem Enum-Vergleich korrigiert - Include-Pfade: aes.hpp in symbol_appearance_settings_impl.h und aes_display_filter_impl.h Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
316 lines
8.5 KiB
C++
Executable File
316 lines
8.5 KiB
C++
Executable File
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <sstream>
|
|
#include <type_traits>
|
|
#include <QString>
|
|
#include <QPointF>
|
|
#include <QSize>
|
|
#include <QRect>
|
|
#include <QRectF>
|
|
#include <QList>
|
|
#ifdef BUILDING_NGLLOGGER
|
|
#include "ngllogger_export.h"
|
|
#else
|
|
#define NGLLOGGER_EXPORT
|
|
#endif
|
|
|
|
namespace NGL
|
|
{
|
|
class INGLLogger;
|
|
|
|
enum class LogLevel
|
|
{
|
|
Undefined = 0,
|
|
Trace = 64,
|
|
Debug = 96,
|
|
Info = 128,
|
|
Warning = 150,
|
|
Error = 182,
|
|
Fatal = 214,
|
|
};
|
|
|
|
// Helper to stream enum classes as integers
|
|
template<typename T, typename = std::enable_if_t<std::is_enum_v<T>>>
|
|
inline std::ostream &operator<<(std::ostream &os, T value)
|
|
{
|
|
return os << static_cast<std::underlying_type_t<T>>(value);
|
|
}
|
|
|
|
class LogStreamHelper
|
|
{
|
|
public:
|
|
inline LogStreamHelper(INGLLogger &logger, LogLevel level, const char *const file, int line, const char *const function)
|
|
: m_logger(logger)
|
|
, m_level(level)
|
|
, m_line(line)
|
|
, m_file(file)
|
|
, m_func(function)
|
|
{}
|
|
inline ~LogStreamHelper();
|
|
|
|
template<typename T>
|
|
inline LogStreamHelper &operator<<(const T &val);
|
|
|
|
private:
|
|
INGLLogger &m_logger;
|
|
std::ostringstream m_buffer;
|
|
const LogLevel m_level;
|
|
const int m_line;
|
|
const char *const m_file;
|
|
const char *const m_func;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class INGLLogger
|
|
{
|
|
public:
|
|
INGLLogger(const INGLLogger &) = delete;
|
|
INGLLogger &operator=(const INGLLogger &) = delete;
|
|
INGLLogger() = default;
|
|
virtual ~INGLLogger() = default;
|
|
|
|
using String = std::string;
|
|
|
|
|
|
|
|
|
|
|
|
virtual INGLLogger &getNGLLogger(const char *fullqualifiedname) = 0;
|
|
virtual INGLLogger &getNGLLogger(const std::string &fullqualifiedname) = 0;
|
|
|
|
|
|
|
|
virtual bool isTraceEnabled() const = 0;
|
|
virtual bool isDebugEnabled() const = 0;
|
|
virtual bool isInfoEnabled() const = 0;
|
|
virtual bool isWarningEnabled() const = 0;
|
|
virtual bool isErrorEnabled() const = 0;
|
|
virtual bool isFatalEnabled() const = 0;
|
|
virtual bool isLevelEnabled(LogLevel level) const = 0;
|
|
|
|
|
|
|
|
virtual void log(LogLevel level, const INGLLogger::String &message, const char *file = nullptr, int line = -1, const char *function = nullptr) = 0;
|
|
|
|
|
|
virtual void logTrace(const INGLLogger::String &message, const char *file = nullptr, int line = -1, const char *function = nullptr) = 0;
|
|
|
|
virtual void logDebug(const INGLLogger::String &message, const char *file = nullptr, int line = -1, const char *function = nullptr) = 0;
|
|
|
|
virtual void logInfo(const INGLLogger::String &message, const char *file = nullptr, int line = -1, const char *function = nullptr) = 0;
|
|
|
|
virtual void logWarning(const INGLLogger::String &message, const char *file = nullptr, int line = -1, const char *function = nullptr) = 0;
|
|
|
|
virtual void logError(const INGLLogger::String &message, const char *file = nullptr, int line = -1, const char *function = nullptr) = 0;
|
|
|
|
virtual void logFatal(const INGLLogger::String &message, const char *file = nullptr, int line = -1, const char *function = nullptr) = 0;
|
|
|
|
|
|
virtual void logStartup(const char *file, int line, const char *function = nullptr) = 0;
|
|
|
|
virtual void logShutdown(const char *file, int line, const char *function = nullptr) = 0;
|
|
|
|
|
|
virtual std::string getLoggerName() const = 0;
|
|
|
|
virtual void setNoSpace(bool bNoSpace) = 0;
|
|
virtual bool noSpace() const = 0;
|
|
};
|
|
|
|
|
|
|
|
|
|
inline LogStreamHelper::~LogStreamHelper()
|
|
{
|
|
m_logger.log(m_level, m_buffer.str(), m_file, m_line, m_func);
|
|
}
|
|
|
|
template<typename T>
|
|
inline LogStreamHelper &LogStreamHelper::operator<<(const T &val)
|
|
{
|
|
m_buffer << val;
|
|
if (!m_logger.noSpace())
|
|
m_buffer << " ";
|
|
return *this;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
inline std::ostream &operator<<(std::ostream &stream, const QByteArray &str)
|
|
{
|
|
stream << std::string(str.data(), str.size());
|
|
return stream;
|
|
}
|
|
|
|
|
|
|
|
|
|
inline std::ostream &operator<<(std::ostream &stream,
|
|
const QPointF &value)
|
|
{
|
|
stream << "QPointF(" << QString::number(value.x(), 'f', 6).toStdString() << "#" << QString::number(value.y(), 'f', 6).toStdString() << ")";
|
|
return stream;
|
|
}
|
|
|
|
|
|
|
|
inline std::ostream &operator<< (std::ostream &stream,
|
|
const QPoint &value)
|
|
{
|
|
stream << "QPoint(" << value.x() << "#" << value.y() << ")";
|
|
return stream;
|
|
}
|
|
|
|
inline std::ostream &operator<< (std::ostream &stream,
|
|
const QSize &value)
|
|
{
|
|
stream << "QSize(w=" << value.width() << ";h=" << value.height() << ")";
|
|
return stream;
|
|
}
|
|
inline std::ostream &operator<< (std::ostream &stream,
|
|
const QSizeF &value)
|
|
{
|
|
stream << "QSize(w="
|
|
<< QString::number(value.width(), 'f', 6).toStdString() << ";h="
|
|
<< QString::number(value.height(), 'f', 6).toStdString()
|
|
<< ")";
|
|
return stream;
|
|
}
|
|
|
|
|
|
inline std::ostream &operator<< (std::ostream &stream,
|
|
const QRect &value)
|
|
{
|
|
stream << "QRect(center=" << value.center()
|
|
<< " w=" << value.width()
|
|
<< ";h=" << value.height()
|
|
<< " bottomLeft=" << value.bottomLeft()
|
|
<< " topRight=" << value.topRight()
|
|
<< ")";
|
|
return stream;
|
|
}
|
|
|
|
inline std::ostream &operator<< (std::ostream &stream,
|
|
const QRectF &value)
|
|
{
|
|
stream << "QRectF(center=" << value.center()
|
|
<< " w=" << QString::number(value.width(), 'f', 3).toStdString()
|
|
<< ";h=" << QString::number(value.height(), 'f', 3).toStdString()
|
|
<< " bottomLeft=" << value.bottomLeft()
|
|
<< " topRight=" << value.topRight()
|
|
<< ")";
|
|
return stream;
|
|
}
|
|
|
|
|
|
|
|
inline std::ostream &operator<< (std::ostream &stream,
|
|
const QList<int> &value)
|
|
{
|
|
stream << "QList<int>(" << value.size() << "): ";
|
|
for (int i : value)
|
|
stream << i << ";";
|
|
return stream;
|
|
}
|
|
|
|
|
|
inline std::ostream &operator<< (std::ostream &stream,
|
|
const QList<QPointF> &value)
|
|
{
|
|
stream << "QList<QPointF>(" << value.size() << "): ";
|
|
for (const QPointF &item : value)
|
|
stream << item << ";";
|
|
return stream;
|
|
}
|
|
|
|
|
|
inline std::ostream &operator<<(std::ostream &stream, const QString &str)
|
|
{
|
|
return stream << str.toUtf8();
|
|
}
|
|
|
|
namespace NGL
|
|
{
|
|
|
|
namespace NGLLoggerHelper
|
|
{
|
|
NGLLOGGER_EXPORT void hexDumpHelper(NGL::INGLLogger &logger,
|
|
NGL::LogLevel level,
|
|
const void *a_data,
|
|
const unsigned int a_size);
|
|
inline void hexDumpHelper(NGL::INGLLogger &logger,
|
|
NGL::LogLevel level,
|
|
const QByteArray &data)
|
|
{
|
|
return hexDumpHelper(logger, level, data.data(), data.size());
|
|
}
|
|
}
|
|
|
|
NGLLOGGER_EXPORT NGL::INGLLogger& getMemoryLogger();
|
|
NGLLOGGER_EXPORT std::string getMemoryData();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define NOTICE_LOG(...) \
|
|
NGL::LogStreamHelper(NGL::getMemoryLogger(), NGL::LogLevel::Info, __FILE__,__LINE__, __func__)
|
|
|
|
#ifdef LTS_DEBUG
|
|
#define TRACE_LOG(...) \
|
|
for (bool log_level_enabled = false; log_level_enabled; log_level_enabled = false) \
|
|
NGL::LogStreamHelper(NGL::getMemoryLogger(), NGL::LogLevel::Trace, __FILE__,__LINE__, __func__)
|
|
#else
|
|
#define TRACE_LOG(...) \
|
|
for ( ; false; ) \
|
|
NGL::LogStreamHelper(NGL::getMemoryLogger(), NGL::LogLevel::Trace, __FILE__,__LINE__, __func__)
|
|
#endif
|
|
|
|
#define DEBUG_LOG(...) \
|
|
for (bool log_level_enabled = false; log_level_enabled; log_level_enabled = false) \
|
|
NGL::LogStreamHelper(NGL::getMemoryLogger(), NGL::LogLevel::Debug, __FILE__,__LINE__, __func__)
|
|
|
|
#define INFO_LOG(...) \
|
|
for (bool log_level_enabled = false; log_level_enabled; log_level_enabled = false) \
|
|
NGL::LogStreamHelper(NGL::getMemoryLogger(), NGL::LogLevel::Info, __FILE__,__LINE__, __func__)
|
|
|
|
#define WARNING_LOG(...) \
|
|
for (bool log_level_enabled = false; log_level_enabled; log_level_enabled = false) \
|
|
NGL::LogStreamHelper(NGL::getMemoryLogger(), NGL::LogLevel::Warning, __FILE__,__LINE__, __func__)
|
|
|
|
#define ERROR_LOG(...) \
|
|
for (bool log_level_enabled = false; log_level_enabled; log_level_enabled = false) \
|
|
NGL::LogStreamHelper(NGL::getMemoryLogger(), NGL::LogLevel::Error, __FILE__,__LINE__, __func__)
|
|
|
|
#define FATAL_LOG(...) \
|
|
for (bool log_level_enabled = false; log_level_enabled; log_level_enabled = false) \
|
|
NGL::LogStreamHelper(NGL::getMemoryLogger(), NGL::LogLevel::Fatal, __FILE__,__LINE__, __func__)
|
|
|
|
#define STARTUP_LOG(...) { NGL::getMemoryLogger().logStartup(__FILE__, __LINE__, __func__); }
|
|
#define SHUTDOWN_LOG(...) { NGL::getMemoryLogger().logShutdown(__FILE__, __LINE__, __func__); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define MEMORY_LOG() \
|
|
for (bool log_level_enabled = (NGL::getMemoryLogger()).isInfoEnabled(); log_level_enabled; log_level_enabled = false) \
|
|
NGL::LogStreamHelper(NGL::getMemoryLogger(), NGL::LogLevel::Info, __FILE__,__LINE__, __func__) << NGL::getMemoryData()
|
|
|
|
|