Formats minimally release source files based on former clang-format
This commit is contained in:
387 files changed
+37323
-38074
No files matched your search
@@ -19,9 +19,10 @@
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
// keep in sync with log4qt/level.h
|
||||
enum class LogLevel {
|
||||
class INGLLogger;
|
||||
// keep in sync with log4qt/level.h
|
||||
enum class LogLevel
|
||||
{
|
||||
Undefined = 0,
|
||||
Trace = 64,
|
||||
Debug = 96,
|
||||
@@ -29,41 +30,44 @@ enum class LogLevel {
|
||||
Warning = 150,
|
||||
Error = 182,
|
||||
Fatal = 214,
|
||||
};
|
||||
};
|
||||
|
||||
class LogStreamHelper
|
||||
{
|
||||
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(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(); // after INGLLogger class definition
|
||||
|
||||
template <typename T> inline LogStreamHelper& operator<<(const T& val);
|
||||
template <typename T> inline LogStreamHelper &operator<<(const T &val);
|
||||
|
||||
private:
|
||||
std::ostringstream m_buffer;
|
||||
NGL::INGLLogger& m_logger;
|
||||
NGL::INGLLogger &m_logger;
|
||||
const LogLevel m_level;
|
||||
const int m_line;
|
||||
const char* const m_file;
|
||||
const char* const m_func;
|
||||
};
|
||||
const char *const m_file;
|
||||
const char *const m_func;
|
||||
};
|
||||
|
||||
// Interface class for source code logging.
|
||||
// Use NGLLoggerBootstrap to create an instance of this interface.
|
||||
// Look below in this headerfile for the macros with which to insert logging
|
||||
// code into your source code.
|
||||
// Lookup the log4cxx documentation (http://logging.apache.org/log4cxx/) for
|
||||
// information on logger-hierarchies, logging-levels, and configuration files.
|
||||
class INGLLogger
|
||||
{
|
||||
// Interface class for source code logging.
|
||||
// Use NGLLoggerBootstrap to create an instance of this interface.
|
||||
// Look below in this headerfile for the macros with which to insert logging
|
||||
// code into your source code.
|
||||
// Lookup the log4cxx documentation (http://logging.apache.org/log4cxx/) for
|
||||
// information on logger-hierarchies, logging-levels, and configuration files.
|
||||
class INGLLogger
|
||||
{
|
||||
public:
|
||||
INGLLogger(const INGLLogger&) = delete;
|
||||
INGLLogger& operator=(const INGLLogger&) = delete;
|
||||
INGLLogger(const INGLLogger &) = delete;
|
||||
INGLLogger &operator=(const INGLLogger &) = delete;
|
||||
INGLLogger() = default;
|
||||
virtual ~INGLLogger() = default;
|
||||
|
||||
@@ -73,8 +77,8 @@ class INGLLogger
|
||||
// a dottet sequence (i.e. "NGL.thisandthat.mylogger"). The same name will
|
||||
// always return the same interface-instance. It is not required to create
|
||||
// the parent nodes.
|
||||
virtual INGLLogger& getNGLLogger(const char* fullqualifiedname) = 0;
|
||||
virtual INGLLogger& getNGLLogger(const std::string& fullqualifiedname) = 0;
|
||||
virtual INGLLogger &getNGLLogger(const char *fullqualifiedname) = 0;
|
||||
virtual INGLLogger &getNGLLogger(const std::string &fullqualifiedname) = 0;
|
||||
|
||||
// True if this level is enabled.
|
||||
virtual bool isTraceEnabled() const = 0;
|
||||
@@ -87,147 +91,136 @@ class INGLLogger
|
||||
|
||||
// Submit a LOG message.
|
||||
// Use __FILE__ and __NAME__ macros.
|
||||
virtual void log(LogLevel level, const INGLLogger::String& message, const char* file = nullptr, int line = -1,
|
||||
const char* function = nullptr) = 0;
|
||||
virtual void log(LogLevel level, const INGLLogger::String &message, const char *file = nullptr, int line = -1, const char *function = nullptr) = 0;
|
||||
|
||||
// Submit an TRACE message.
|
||||
virtual void logTrace(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;
|
||||
// Submit an DEBUG message.
|
||||
virtual void logDebug(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;
|
||||
// Submit an INFO message.
|
||||
virtual void logInfo(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;
|
||||
// Submit a WARNING message.
|
||||
virtual void logWarning(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;
|
||||
// Submit an ERROR message.
|
||||
virtual void logError(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;
|
||||
// Submit a FATAL message.
|
||||
virtual void logFatal(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;
|
||||
|
||||
// Writes a startup message into the logfile
|
||||
virtual void logStartup(const char* file, int line, const char* function = nullptr) = 0;
|
||||
virtual void logStartup(const char *file, int line, const char *function = nullptr) = 0;
|
||||
// Writes a shutdown message into the logfile
|
||||
virtual void logShutdown(const char* file, int line, const char* function = nullptr) = 0;
|
||||
virtual void logShutdown(const char *file, int line, const char *function = nullptr) = 0;
|
||||
|
||||
// Get this loggers fullqualified name.
|
||||
virtual std::string getLoggerName() const = 0;
|
||||
|
||||
virtual void setNoSpace(bool bNoSpace) = 0;
|
||||
virtual bool noSpace() const = 0;
|
||||
};
|
||||
};
|
||||
|
||||
//
|
||||
// LogStreamHelper
|
||||
//
|
||||
inline LogStreamHelper::~LogStreamHelper()
|
||||
{
|
||||
//
|
||||
// LogStreamHelper
|
||||
//
|
||||
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)
|
||||
{
|
||||
template <typename T> inline LogStreamHelper &LogStreamHelper::operator<<(const T &val)
|
||||
{
|
||||
m_buffer << val;
|
||||
if (!m_logger.noSpace())
|
||||
m_buffer << " ";
|
||||
m_buffer << " ";
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace NGL
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& stream, const QByteArray& str)
|
||||
inline std::ostream &operator<<(std::ostream &stream, const QByteArray &str)
|
||||
{
|
||||
stream << std::string(str.data(), str.size());
|
||||
return stream;
|
||||
stream << std::string(str.data(), str.size());
|
||||
return stream;
|
||||
}
|
||||
|
||||
//
|
||||
// operator to ease logging (at least via NglLogging)
|
||||
//
|
||||
inline std::ostream& operator<<(std::ostream& stream, const QPointF& value)
|
||||
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;
|
||||
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)
|
||||
inline std::ostream &operator<<(std::ostream &stream, const QPoint &value)
|
||||
{
|
||||
stream << "QPoint(" << value.x() << "#" << value.y() << ")";
|
||||
return stream;
|
||||
stream << "QPoint(" << value.x() << "#" << value.y() << ")";
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& stream, const QSize& value)
|
||||
inline std::ostream &operator<<(std::ostream &stream, const QSize &value)
|
||||
{
|
||||
stream << "QSize(w=" << value.width() << ";h=" << value.height() << ")";
|
||||
return stream;
|
||||
stream << "QSize(w=" << value.width() << ";h=" << value.height() << ")";
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& stream, const QSizeF& value)
|
||||
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;
|
||||
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)
|
||||
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;
|
||||
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)
|
||||
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;
|
||||
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)
|
||||
inline std::ostream &operator<<(std::ostream &stream, const QList<int> &value)
|
||||
{
|
||||
stream << "QList<int>(" << value.size() << "): ";
|
||||
for (int i : value)
|
||||
stream << i << ";";
|
||||
return stream;
|
||||
stream << "QList<int>(" << value.size() << "): ";
|
||||
for (int i : value)
|
||||
stream << i << ";";
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& stream, const QList<QPointF>& value)
|
||||
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;
|
||||
stream << "QList<QPointF>(" << value.size() << "): ";
|
||||
for (const QPointF &item : value)
|
||||
stream << item << ";";
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& stream, const QString& str)
|
||||
inline std::ostream &operator<<(std::ostream &stream, const QString &str)
|
||||
{
|
||||
return stream << str.toUtf8();
|
||||
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);
|
||||
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());
|
||||
}
|
||||
} // namespace NGLLoggerHelper
|
||||
inline void hexDumpHelper(NGL::INGLLogger &logger, NGL::LogLevel level, const QByteArray &data)
|
||||
{
|
||||
return hexDumpHelper(logger, level, data.data(), data.size());
|
||||
}
|
||||
} // namespace NGLLoggerHelper
|
||||
|
||||
NGLLOGGER_EXPORT NGL::INGLLogger& getMemoryLogger();
|
||||
NGLLOGGER_EXPORT std::string getMemoryData();
|
||||
NGLLOGGER_EXPORT NGL::INGLLogger &getMemoryLogger();
|
||||
NGLLOGGER_EXPORT std::string getMemoryData();
|
||||
|
||||
} // namespace NGL
|
||||
|
||||
@@ -241,43 +234,43 @@ NGLLOGGER_EXPORT std::string getMemoryData();
|
||||
#define NOTICE_LOG(logger) NGL::LogStreamHelper(logger, NGL::LogLevel::Info, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
|
||||
#ifdef LTS_DEBUG
|
||||
#define TRACE_LOG(logger) \
|
||||
for (bool log_level_enabled = (logger).isTraceEnabled(); log_level_enabled; log_level_enabled = false) \
|
||||
NGL::LogStreamHelper(logger, NGL::LogLevel::Trace, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
#define TRACE_LOG(logger) \
|
||||
for (bool log_level_enabled = (logger).isTraceEnabled(); log_level_enabled; log_level_enabled = false) \
|
||||
NGL::LogStreamHelper(logger, NGL::LogLevel::Trace, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
#else
|
||||
#define TRACE_LOG(logger) \
|
||||
for (; false;) \
|
||||
NGL::LogStreamHelper(logger, NGL::LogLevel::Trace, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
#define TRACE_LOG(logger) \
|
||||
for (; false;) \
|
||||
NGL::LogStreamHelper(logger, NGL::LogLevel::Trace, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
#endif
|
||||
|
||||
#define DEBUG_LOG(logger) \
|
||||
for (bool log_level_enabled = (logger).isDebugEnabled(); log_level_enabled; log_level_enabled = false) \
|
||||
::NGL::LogStreamHelper(logger, ::NGL::LogLevel::Debug, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
#define DEBUG_LOG(logger) \
|
||||
for (bool log_level_enabled = (logger).isDebugEnabled(); log_level_enabled; log_level_enabled = false) \
|
||||
::NGL::LogStreamHelper(logger, ::NGL::LogLevel::Debug, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
|
||||
#define INFO_LOG(logger) \
|
||||
for (bool log_level_enabled = (logger).isInfoEnabled(); log_level_enabled; log_level_enabled = false) \
|
||||
::NGL::LogStreamHelper(logger, ::NGL::LogLevel::Info, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
#define INFO_LOG(logger) \
|
||||
for (bool log_level_enabled = (logger).isInfoEnabled(); log_level_enabled; log_level_enabled = false) \
|
||||
::NGL::LogStreamHelper(logger, ::NGL::LogLevel::Info, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
|
||||
#define WARNING_LOG(logger) \
|
||||
for (bool log_level_enabled = (logger).isWarningEnabled(); log_level_enabled; log_level_enabled = false) \
|
||||
::NGL::LogStreamHelper(logger, ::NGL::LogLevel::Warning, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
#define WARNING_LOG(logger) \
|
||||
for (bool log_level_enabled = (logger).isWarningEnabled(); log_level_enabled; log_level_enabled = false) \
|
||||
::NGL::LogStreamHelper(logger, ::NGL::LogLevel::Warning, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
|
||||
#define ERROR_LOG(logger) \
|
||||
for (bool log_level_enabled = (logger).isErrorEnabled(); log_level_enabled; log_level_enabled = false) \
|
||||
::NGL::LogStreamHelper(logger, ::NGL::LogLevel::Error, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
#define ERROR_LOG(logger) \
|
||||
for (bool log_level_enabled = (logger).isErrorEnabled(); log_level_enabled; log_level_enabled = false) \
|
||||
::NGL::LogStreamHelper(logger, ::NGL::LogLevel::Error, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
|
||||
#define FATAL_LOG(logger) \
|
||||
for (bool log_level_enabled = (logger).isFatalEnabled(); log_level_enabled; log_level_enabled = false) \
|
||||
::NGL::LogStreamHelper(logger, ::NGL::LogLevel::Fatal, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
#define FATAL_LOG(logger) \
|
||||
for (bool log_level_enabled = (logger).isFatalEnabled(); log_level_enabled; log_level_enabled = false) \
|
||||
::NGL::LogStreamHelper(logger, ::NGL::LogLevel::Fatal, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
|
||||
#define STARTUP_LOG(logger) \
|
||||
{ \
|
||||
(logger).logStartup(__FILE__, __LINE__, Q_FUNC_INFO); \
|
||||
}
|
||||
#define SHUTDOWN_LOG(logger) \
|
||||
{ \
|
||||
(logger).logShutdown(__FILE__, __LINE__, Q_FUNC_INFO); \
|
||||
}
|
||||
#define STARTUP_LOG(logger) \
|
||||
{ \
|
||||
(logger).logStartup(__FILE__, __LINE__, Q_FUNC_INFO); \
|
||||
}
|
||||
#define SHUTDOWN_LOG(logger) \
|
||||
{ \
|
||||
(logger).logShutdown(__FILE__, __LINE__, Q_FUNC_INFO); \
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
||||
@@ -286,10 +279,8 @@ NGLLOGGER_EXPORT std::string getMemoryData();
|
||||
// do something nasty
|
||||
// MEMORY_LOG() << " after something nasty";
|
||||
|
||||
#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__, Q_FUNC_INFO) \
|
||||
<< NGL::getMemoryData()
|
||||
#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__, Q_FUNC_INFO) << NGL::getMemoryData()
|
||||
|
||||
//==============================================================================
|
||||
Executable → Regular
+35
-54
@@ -1,77 +1,58 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "MurmurHash2.h"
|
||||
#include <QtCore/qcompilerdetection.h>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
unsigned int MurmurHash2 ( const void * key, int len, unsigned int seed )
|
||||
{
|
||||
|
||||
|
||||
unsigned int MurmurHash2(const void *key, int len, unsigned int seed)
|
||||
{
|
||||
|
||||
const unsigned int m = 0x5bd1e995;
|
||||
const int r = 24;
|
||||
|
||||
|
||||
const unsigned int m = 0x5bd1e995;
|
||||
const int r = 24;
|
||||
|
||||
unsigned int h = seed ^ len;
|
||||
|
||||
|
||||
unsigned int h = seed ^ len;
|
||||
|
||||
const unsigned char * data = (const unsigned char *)key;
|
||||
|
||||
while(len >= 4)
|
||||
{
|
||||
unsigned int k = *(reinterpret_cast<const unsigned int *>(data));
|
||||
const unsigned char *data = (const unsigned char *)key;
|
||||
|
||||
k *= m;
|
||||
k ^= k >> r;
|
||||
k *= m;
|
||||
while (len >= 4)
|
||||
{
|
||||
unsigned int k = *(reinterpret_cast<const unsigned int *>(data));
|
||||
|
||||
h *= m;
|
||||
h ^= k;
|
||||
k *= m;
|
||||
k ^= k >> r;
|
||||
k *= m;
|
||||
|
||||
data += 4;
|
||||
len -= 4;
|
||||
}
|
||||
h *= m;
|
||||
h ^= k;
|
||||
|
||||
|
||||
data += 4;
|
||||
len -= 4;
|
||||
}
|
||||
|
||||
switch(len)
|
||||
{
|
||||
case 3: h ^= data[2] << 16;
|
||||
Q_FALLTHROUGH();
|
||||
case 2: h ^= data[1] << 8;
|
||||
Q_FALLTHROUGH();
|
||||
case 1: h ^= data[0];
|
||||
h *= m;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
h ^= h >> 13;
|
||||
switch (len)
|
||||
{
|
||||
case 3:
|
||||
h ^= data[2] << 16;
|
||||
Q_FALLTHROUGH();
|
||||
case 2:
|
||||
h ^= data[1] << 8;
|
||||
Q_FALLTHROUGH();
|
||||
case 1:
|
||||
h ^= data[0];
|
||||
h *= m;
|
||||
h ^= h >> 15;
|
||||
};
|
||||
|
||||
return h;
|
||||
|
||||
h ^= h >> 13;
|
||||
h *= m;
|
||||
h ^= h >> 15;
|
||||
|
||||
return h;
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable → Regular
+1
-1
@@ -5,5 +5,5 @@
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
unsigned int MurmurHash2 ( const void * key, int len, unsigned int seed = 0 );
|
||||
unsigned int MurmurHash2(const void *key, int len, unsigned int seed = 0);
|
||||
}
|
||||
Executable → Regular
+144
-189
@@ -27,82 +27,73 @@
|
||||
namespace NGL
|
||||
{
|
||||
|
||||
void LtsRollingFileAppender::setLtsLogfileName(const QString <sLogfileName)
|
||||
{
|
||||
m_ltsLogfileName = ltsLogfileName;
|
||||
}
|
||||
void LtsRollingFileAppender::setLtsLogfileName(const QString <sLogfileName)
|
||||
{
|
||||
m_ltsLogfileName = ltsLogfileName;
|
||||
}
|
||||
|
||||
void LtsRollingFileAppender::activateOptions()
|
||||
{
|
||||
if (!m_ltsLogfileName.isEmpty())
|
||||
setFile(m_ltsLogfileName);
|
||||
void LtsRollingFileAppender::activateOptions()
|
||||
{
|
||||
if (!m_ltsLogfileName.isEmpty())
|
||||
setFile(m_ltsLogfileName);
|
||||
#ifdef HAVE_LOG4QT
|
||||
Log4Qt::RollingFileAppender::activateOptions();
|
||||
Log4Qt::RollingFileAppender::activateOptions();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
QString LtsRollingFileAppender::m_ltsLogfileName;
|
||||
QString LtsRollingFileAppender::m_ltsLogfileName;
|
||||
#ifdef HAVE_LOG4QT
|
||||
static Log4Qt::Appender *createLtsRollingFileAppender()
|
||||
{
|
||||
auto ret = new LtsRollingFileAppender;
|
||||
ret->setAppendFile(true);
|
||||
return ret;
|
||||
}
|
||||
static Log4Qt::Appender *createLtsRollingFileAppender()
|
||||
{
|
||||
auto ret = new LtsRollingFileAppender;
|
||||
ret->setAppendFile(true);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
class CleanupHelper final
|
||||
{
|
||||
public:
|
||||
CleanupHelper() = default;
|
||||
~CleanupHelper();
|
||||
std::mutex &getLoggerMapMutex();
|
||||
|
||||
std::unordered_map<unsigned int, NGL::NGLLogger *> m_loggermap;
|
||||
|
||||
protected:
|
||||
std::mutex m_loggermapmutex;
|
||||
};
|
||||
|
||||
|
||||
NGL::NGLLogger *NGL::NGLLogger::rootlogger_ptr = nullptr;
|
||||
|
||||
class CleanupHelper final
|
||||
{
|
||||
public:
|
||||
CleanupHelper() = default;
|
||||
~CleanupHelper();
|
||||
std::mutex &getLoggerMapMutex();
|
||||
|
||||
std::unordered_map<unsigned int, NGL::NGLLogger *> m_loggermap;
|
||||
protected:
|
||||
std::mutex m_loggermapmutex;
|
||||
};
|
||||
NGL::CleanupHelper NGL::NGLLogger::s_cleanup;
|
||||
|
||||
|
||||
CleanupHelper::~CleanupHelper()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_loggermapmutex);
|
||||
|
||||
for (auto it : m_loggermap)
|
||||
delete it.second;
|
||||
m_loggermap.clear();
|
||||
|
||||
delete NGL::NGLLogger::rootlogger_ptr;
|
||||
NGL::NGLLogger::rootlogger_ptr = nullptr;
|
||||
}
|
||||
|
||||
NGL::NGLLogger *NGL::NGLLogger::rootlogger_ptr = nullptr;
|
||||
|
||||
NGL::CleanupHelper NGL::NGLLogger::s_cleanup;
|
||||
|
||||
|
||||
|
||||
|
||||
CleanupHelper::~CleanupHelper()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_loggermapmutex);
|
||||
|
||||
for (auto it : m_loggermap)
|
||||
delete it.second;
|
||||
m_loggermap.clear();
|
||||
|
||||
delete NGL::NGLLogger::rootlogger_ptr;
|
||||
NGL::NGLLogger::rootlogger_ptr = nullptr;
|
||||
std::mutex &CleanupHelper::getLoggerMapMutex()
|
||||
{
|
||||
return m_loggermapmutex;
|
||||
}
|
||||
}
|
||||
|
||||
std::mutex &CleanupHelper::getLoggerMapMutex()
|
||||
{
|
||||
return m_loggermapmutex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
NGL::NGLLogger::NGLLogger(const std::string &fullqualifiedname)
|
||||
: name(fullqualifiedname)
|
||||
, currentLevel(LogLevel::Undefined)
|
||||
, m_bNoSpace(true)
|
||||
: name(fullqualifiedname)
|
||||
, currentLevel(LogLevel::Undefined)
|
||||
, m_bNoSpace(true)
|
||||
{
|
||||
#ifdef HAVE_LOG4QT
|
||||
if (!fullqualifiedname.empty())
|
||||
@@ -113,17 +104,13 @@ NGL::NGLLogger::NGLLogger(const std::string &fullqualifiedname)
|
||||
else
|
||||
{
|
||||
logger_ptr = Log4Qt::LogManager::loggerRepository()->rootLogger();
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
configChanged();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NGL::INGLLogger &NGL::NGLLogger::getNGLLogger(const char *fullqualifiedname)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(s_cleanup.getLoggerMapMutex());
|
||||
@@ -135,9 +122,6 @@ NGL::INGLLogger &NGL::NGLLogger::getNGLLogger(const char *fullqualifiedname)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NGL::INGLLogger &NGL::NGLLogger::getNGLLogger(const std::string &fullqualifiedname)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(s_cleanup.getLoggerMapMutex());
|
||||
@@ -149,9 +133,6 @@ NGL::INGLLogger &NGL::NGLLogger::getNGLLogger(const std::string &fullqualifiedna
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void NGL::NGLLogger::log(LogLevel level, const INGLLogger::String &message, const char *file, int line, const char *function)
|
||||
{
|
||||
#ifdef HAVE_LOG4QT
|
||||
@@ -182,9 +163,6 @@ void NGL::NGLLogger::log(LogLevel level, const INGLLogger::String &message, cons
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void NGL::NGLLogger::logTrace(const INGLLogger::String &message, const char *file, int line, const char *function)
|
||||
{
|
||||
if (currentLevel >= LogLevel::Trace)
|
||||
@@ -192,9 +170,6 @@ void NGL::NGLLogger::logTrace(const INGLLogger::String &message, const char *fil
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void NGL::NGLLogger::logDebug(const INGLLogger::String &message, const char *file, int line, const char *function)
|
||||
{
|
||||
if (currentLevel >= LogLevel::Debug)
|
||||
@@ -202,9 +177,6 @@ void NGL::NGLLogger::logDebug(const INGLLogger::String &message, const char *fil
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void NGL::NGLLogger::logInfo(const INGLLogger::String &message, const char *file, int line, const char *function)
|
||||
{
|
||||
if (currentLevel >= LogLevel::Info)
|
||||
@@ -212,9 +184,6 @@ void NGL::NGLLogger::logInfo(const INGLLogger::String &message, const char *file
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void NGL::NGLLogger::logWarning(const INGLLogger::String &message, const char *file, int line, const char *function)
|
||||
{
|
||||
if (currentLevel >= LogLevel::Warning)
|
||||
@@ -222,9 +191,6 @@ void NGL::NGLLogger::logWarning(const INGLLogger::String &message, const char *f
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void NGL::NGLLogger::logError(const INGLLogger::String &message, const char *file, int line, const char *function)
|
||||
{
|
||||
if (currentLevel >= LogLevel::Error)
|
||||
@@ -232,17 +198,12 @@ void NGL::NGLLogger::logError(const INGLLogger::String &message, const char *fil
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void NGL::NGLLogger::logFatal(const INGLLogger::String &message, const char *file, int line, const char *function)
|
||||
{
|
||||
log(LogLevel::Fatal, message, file, line, function);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef LTS_VERSION_MAJOR
|
||||
#define LTS_VERSION_MAJOR "undefined"
|
||||
#endif
|
||||
@@ -266,52 +227,58 @@ static const char ver_jenkins[] = JENKINS_BUILD_NUMBER;
|
||||
|
||||
void NGL::NGLLogger::logStartup(const char *file, int line, const char *function)
|
||||
{
|
||||
log(LogLevel::Info, QStringLiteral("Application is started (%1.%2-%3 rev%4 from %5)")
|
||||
.arg(QString::fromLatin1(ver_major),
|
||||
QString::fromLatin1(ver_minor),
|
||||
QString::fromLatin1(ver_jenkins),
|
||||
QString::fromLatin1(ver_patch),
|
||||
QString::fromLatin1(ver_date)).toUtf8().constData(), file, line, function);
|
||||
log(LogLevel::Info,
|
||||
QStringLiteral("Application is started (%1.%2-%3 rev%4 from %5)")
|
||||
.arg(QString::fromLatin1(ver_major),
|
||||
QString::fromLatin1(ver_minor),
|
||||
QString::fromLatin1(ver_jenkins),
|
||||
QString::fromLatin1(ver_patch),
|
||||
QString::fromLatin1(ver_date))
|
||||
.toUtf8()
|
||||
.constData(),
|
||||
file,
|
||||
line,
|
||||
function);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void NGL::NGLLogger::logShutdown(const char *file, int line, const char *function)
|
||||
{
|
||||
log(LogLevel::Info, QStringLiteral("Application is shut down (%1.%2-%3 rev%4 from %5)")
|
||||
.arg(QString::fromLatin1(ver_major),
|
||||
QString::fromLatin1(ver_minor),
|
||||
QString::fromLatin1(ver_jenkins),
|
||||
QString::fromLatin1(ver_patch),
|
||||
QString::fromLatin1(ver_date)).toUtf8().constData(), file, line, function);
|
||||
log(LogLevel::Info,
|
||||
QStringLiteral("Application is shut down (%1.%2-%3 rev%4 from %5)")
|
||||
.arg(QString::fromLatin1(ver_major),
|
||||
QString::fromLatin1(ver_minor),
|
||||
QString::fromLatin1(ver_jenkins),
|
||||
QString::fromLatin1(ver_patch),
|
||||
QString::fromLatin1(ver_date))
|
||||
.toUtf8()
|
||||
.constData(),
|
||||
file,
|
||||
line,
|
||||
function);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NGL::NGLLogger &NGL::NGLLogger::getNGLRootLogger()
|
||||
{
|
||||
if (!rootlogger_ptr) throw NotCreatedError();
|
||||
if (!rootlogger_ptr)
|
||||
throw NotCreatedError();
|
||||
return *rootlogger_ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef HAVE_LOG4QT
|
||||
static QString findConfigFile(const QString &configfilename)
|
||||
{
|
||||
if (configfilename.isEmpty())
|
||||
return QString();
|
||||
|
||||
|
||||
|
||||
QFileInfo fi(configfilename);
|
||||
if (fi.isFile() && fi.isReadable())
|
||||
return fi.absoluteFilePath();
|
||||
|
||||
|
||||
|
||||
QString p = QCoreApplication::applicationDirPath() + QLatin1Char('/') + configfilename;
|
||||
fi.setFile(p);
|
||||
if (fi.isFile() && fi.isReadable())
|
||||
@@ -322,16 +289,12 @@ static QString findConfigFile(const QString &configfilename)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
NGL::NGLLogger &NGL::NGLLogger::createNGLRootLogger(const QString &configfilename,
|
||||
bool ignorealreadycreated,
|
||||
const QString &logOutputName,
|
||||
bool quiet)
|
||||
NGL::NGLLogger &NGL::NGLLogger::createNGLRootLogger(const QString &configfilename, bool ignorealreadycreated, const QString &logOutputName, bool quiet)
|
||||
{
|
||||
if (rootlogger_ptr)
|
||||
{
|
||||
if (!ignorealreadycreated) throw AlreadyCreatedError();
|
||||
if (!ignorealreadycreated)
|
||||
throw AlreadyCreatedError();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -344,8 +307,7 @@ NGL::NGLLogger &NGL::NGLLogger::createNGLRootLogger(const QString &configfilenam
|
||||
if (!filename.isEmpty())
|
||||
{
|
||||
Log4Qt::PropertyConfigurator::configureAndWatch(filename);
|
||||
QObject::connect(Log4Qt::ConfiguratorHelper::instance(), &Log4Qt::ConfiguratorHelper::configurationFileChanged,
|
||||
[]() { configurationFileChanged(); });
|
||||
QObject::connect(Log4Qt::ConfiguratorHelper::instance(), &Log4Qt::ConfiguratorHelper::configurationFileChanged, []() { configurationFileChanged(); });
|
||||
const auto l = Log4Qt::ConfiguratorHelper::instance()->configureError();
|
||||
for (const auto &t : l)
|
||||
std::cerr << t.message().toUtf8().data() << std::endl;
|
||||
@@ -355,19 +317,14 @@ NGL::NGLLogger &NGL::NGLLogger::createNGLRootLogger(const QString &configfilenam
|
||||
else
|
||||
{
|
||||
if (!quiet)
|
||||
std::cerr << "Could not find log4cxx configuration file " << configfilename << std::endl
|
||||
<< "Using default logging to stdout" << std::endl;
|
||||
std::cerr << "Could not find log4cxx configuration file " << configfilename << std::endl << "Using default logging to stdout" << std::endl;
|
||||
|
||||
|
||||
|
||||
Log4Qt::Properties props;
|
||||
props.setProperty(QLatin1String("log4j.rootLogger"),
|
||||
QLatin1String("WARN, stdout"));
|
||||
props.setProperty(QLatin1String("log4j.appender.stdout"),
|
||||
QLatin1String("org.apache.log4j.ConsoleAppender"));
|
||||
props.setProperty(QLatin1String("log4j.appender.stdout.layout"),
|
||||
QLatin1String("org.apache.log4j.PatternLayout"));
|
||||
props.setProperty(QLatin1String("log4j.appender.stdout.layout.ConversionPattern"),
|
||||
QLatin1String("%d %-5p %c |#| %m (%.50F:%L) %n"));
|
||||
props.setProperty(QLatin1String("log4j.rootLogger"), QLatin1String("WARN, stdout"));
|
||||
props.setProperty(QLatin1String("log4j.appender.stdout"), QLatin1String("org.apache.log4j.ConsoleAppender"));
|
||||
props.setProperty(QLatin1String("log4j.appender.stdout.layout"), QLatin1String("org.apache.log4j.PatternLayout"));
|
||||
props.setProperty(QLatin1String("log4j.appender.stdout.layout.ConversionPattern"), QLatin1String("%d %-5p %c |#| %m (%.50F:%L) %n"));
|
||||
Log4Qt::PropertyConfigurator::configure(props);
|
||||
}
|
||||
rootlogger_ptr->configChanged();
|
||||
@@ -407,82 +364,80 @@ void NGL::NGLLogger::configChanged()
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
namespace NGLLoggerHelper
|
||||
{
|
||||
|
||||
void hexDumpHelper(NGL::INGLLogger &logger, NGL::LogLevel level,
|
||||
const void *a_data, const unsigned int a_size)
|
||||
{
|
||||
if (!logger.isLevelEnabled(level) || !a_data)
|
||||
return;
|
||||
|
||||
unsigned char *data = (unsigned char *)a_data;
|
||||
QByteArray baBuf;
|
||||
for (unsigned int i = 0; i < a_size; i++)
|
||||
namespace NGLLoggerHelper
|
||||
{
|
||||
if (0 == (i % 8))
|
||||
baBuf = QByteArray::number(i, 16).rightJustified(8, '0').toUpper();
|
||||
baBuf += " " + QByteArray::number(data[i], 16).rightJustified(2, '0').toUpper();
|
||||
if (7 == (i % 8))
|
||||
logger.log(level, baBuf.constData(), __FILE__, __LINE__);
|
||||
|
||||
void hexDumpHelper(NGL::INGLLogger &logger, NGL::LogLevel level, const void *a_data, const unsigned int a_size)
|
||||
{
|
||||
if (!logger.isLevelEnabled(level) || !a_data)
|
||||
return;
|
||||
|
||||
unsigned char *data = (unsigned char *)a_data;
|
||||
QByteArray baBuf;
|
||||
for (unsigned int i = 0; i < a_size; i++)
|
||||
{
|
||||
if (0 == (i % 8))
|
||||
baBuf = QByteArray::number(i, 16).rightJustified(8, '0').toUpper();
|
||||
baBuf += " " + QByteArray::number(data[i], 16).rightJustified(2, '0').toUpper();
|
||||
if (7 == (i % 8))
|
||||
logger.log(level, baBuf.constData(), __FILE__, __LINE__);
|
||||
}
|
||||
if (a_size % 8)
|
||||
logger.log(level, baBuf.constData(), __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
}
|
||||
if (a_size % 8)
|
||||
logger.log(level, baBuf.constData(), __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
NGL::INGLLogger& getMemoryLogger()
|
||||
{
|
||||
try
|
||||
NGL::INGLLogger &getMemoryLogger()
|
||||
{
|
||||
return NGLLogger::getNGLRootLogger().getNGLLogger("memorystate");
|
||||
|
||||
try
|
||||
{
|
||||
return NGLLogger::getNGLRootLogger().getNGLLogger("memorystate");
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
fprintf(stderr, "Error retrieving logger: %s", ex.what());
|
||||
abort();
|
||||
}
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
|
||||
int parseLine(char *line)
|
||||
{
|
||||
fprintf(stderr, "Error retrieving logger: %s", ex.what());
|
||||
abort();
|
||||
|
||||
int i = strlen(line);
|
||||
const char *p = line;
|
||||
while (*p < '0' || *p > '9')
|
||||
p++;
|
||||
line[i - 3] = '\0';
|
||||
i = atoi(p);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
int parseLine(char* line){
|
||||
|
||||
int i = strlen(line);
|
||||
const char* p = line;
|
||||
while (*p <'0' || *p > '9') p++;
|
||||
line[i-3] = '\0';
|
||||
i = atoi(p);
|
||||
return i;
|
||||
}
|
||||
int getMemoryValue()
|
||||
{
|
||||
|
||||
int getMemoryValue()
|
||||
{
|
||||
|
||||
FILE* file = fopen("/proc/self/status", "r");
|
||||
int result = -1;
|
||||
char line[128];
|
||||
FILE *file = fopen("/proc/self/status", "r");
|
||||
int result = -1;
|
||||
char line[128];
|
||||
|
||||
while (fgets(line, 128, file) != NULL){
|
||||
while (fgets(line, 128, file) != NULL)
|
||||
{
|
||||
|
||||
if (strncmp(line, "VmRSS:", 6) == 0){
|
||||
if (strncmp(line, "VmRSS:", 6) == 0)
|
||||
{
|
||||
result = parseLine(line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string getMemoryData()
|
||||
{
|
||||
return QStringLiteral("VmRSS: %1 kB #").arg(QString::number(getMemoryValue())).toStdString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
std::string getMemoryData()
|
||||
{
|
||||
return QStringLiteral("VmRSS: %1 kB #").arg(QString::number(getMemoryValue())).toStdString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Executable → Regular
+67
-62
@@ -21,85 +21,90 @@
|
||||
namespace NGL
|
||||
{
|
||||
|
||||
class CleanupHelper;
|
||||
class CleanupHelper;
|
||||
|
||||
#ifdef HAVE_LOG4QT
|
||||
class LtsRollingFileAppender final : public Log4Qt::RollingFileAppender
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using Log4Qt::RollingFileAppender::RollingFileAppender;
|
||||
class LtsRollingFileAppender final : public Log4Qt::RollingFileAppender
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using Log4Qt::RollingFileAppender::RollingFileAppender;
|
||||
#else
|
||||
class LtsRollingFileAppender final : public Log4Qt::RollingFileAppender
|
||||
{
|
||||
public:
|
||||
explicit LtsRollingFileAppender(QObject *parent = nullptr) : Log4Qt::RollingFileAppender(parent) {}
|
||||
class LtsRollingFileAppender final : public Log4Qt::RollingFileAppender
|
||||
{
|
||||
public:
|
||||
explicit LtsRollingFileAppender(QObject *parent = nullptr)
|
||||
: Log4Qt::RollingFileAppender(parent)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
static void setLtsLogfileName(const QString <sLogfileName);
|
||||
void activateOptions() override;
|
||||
private:
|
||||
static QString m_ltsLogfileName;
|
||||
};
|
||||
static void setLtsLogfileName(const QString <sLogfileName);
|
||||
void activateOptions() override;
|
||||
|
||||
class NGLLogger final : public INGLLogger
|
||||
{
|
||||
explicit NGLLogger(const std::string &fullqualifiedname);
|
||||
public:
|
||||
private:
|
||||
static QString m_ltsLogfileName;
|
||||
};
|
||||
|
||||
class NotCreatedError {};
|
||||
class AlreadyCreatedError {};
|
||||
class NGLLogger final : public INGLLogger
|
||||
{
|
||||
explicit NGLLogger(const std::string &fullqualifiedname);
|
||||
|
||||
INGLLogger &getNGLLogger(const char *fullqualifiedname) override;
|
||||
INGLLogger &getNGLLogger(const std::string &fullqualifiedname) override;
|
||||
public:
|
||||
class NotCreatedError
|
||||
{
|
||||
};
|
||||
class AlreadyCreatedError
|
||||
{
|
||||
};
|
||||
|
||||
inline bool isTraceEnabled() const override { return currentLevel <= LogLevel::Trace; }
|
||||
inline bool isDebugEnabled() const override { return currentLevel <= LogLevel::Debug; }
|
||||
inline bool isInfoEnabled() const override { return currentLevel <= LogLevel::Info; }
|
||||
inline bool isWarningEnabled() const override { return currentLevel <= LogLevel::Warning; }
|
||||
inline bool isErrorEnabled() const override { return currentLevel <= LogLevel::Error; }
|
||||
inline bool isFatalEnabled() const override { return currentLevel <= LogLevel::Fatal; }
|
||||
inline bool isLevelEnabled(LogLevel level) const override { return currentLevel <= level; }
|
||||
INGLLogger &getNGLLogger(const char *fullqualifiedname) override;
|
||||
INGLLogger &getNGLLogger(const std::string &fullqualifiedname) override;
|
||||
|
||||
void log(LogLevel level, const INGLLogger::String &message, const char *file = nullptr, int line = -1, const char *function = nullptr) override;
|
||||
void logTrace(const INGLLogger::String &message, const char *file = nullptr, int line = -1, const char *function = nullptr) override;
|
||||
void logDebug(const INGLLogger::String &message, const char *file = nullptr, int line = -1, const char *function = nullptr) override;
|
||||
void logInfo(const INGLLogger::String &message, const char *file = nullptr, int line = -1, const char *function = nullptr) override;
|
||||
void logWarning(const INGLLogger::String &message, const char *file = nullptr, int line = -1, const char *function = nullptr) override;
|
||||
void logError(const INGLLogger::String &message, const char *file = nullptr, int line = -1, const char *function = nullptr) override;
|
||||
void logFatal(const INGLLogger::String &message, const char *file = nullptr, int line = -1, const char *function = nullptr) override;
|
||||
inline bool isTraceEnabled() const override { return currentLevel <= LogLevel::Trace; }
|
||||
inline bool isDebugEnabled() const override { return currentLevel <= LogLevel::Debug; }
|
||||
inline bool isInfoEnabled() const override { return currentLevel <= LogLevel::Info; }
|
||||
inline bool isWarningEnabled() const override { return currentLevel <= LogLevel::Warning; }
|
||||
inline bool isErrorEnabled() const override { return currentLevel <= LogLevel::Error; }
|
||||
inline bool isFatalEnabled() const override { return currentLevel <= LogLevel::Fatal; }
|
||||
inline bool isLevelEnabled(LogLevel level) const override { return currentLevel <= level; }
|
||||
|
||||
void logStartup(const char *file, int line, const char *function = nullptr) override;
|
||||
void logShutdown(const char *file, int line, const char *function = nullptr) override;
|
||||
void log(LogLevel level, const INGLLogger::String &message, const char *file = nullptr, int line = -1, const char *function = nullptr) override;
|
||||
void logTrace(const INGLLogger::String &message, const char *file = nullptr, int line = -1, const char *function = nullptr) override;
|
||||
void logDebug(const INGLLogger::String &message, const char *file = nullptr, int line = -1, const char *function = nullptr) override;
|
||||
void logInfo(const INGLLogger::String &message, const char *file = nullptr, int line = -1, const char *function = nullptr) override;
|
||||
void logWarning(const INGLLogger::String &message, const char *file = nullptr, int line = -1, const char *function = nullptr) override;
|
||||
void logError(const INGLLogger::String &message, const char *file = nullptr, int line = -1, const char *function = nullptr) override;
|
||||
void logFatal(const INGLLogger::String &message, const char *file = nullptr, int line = -1, const char *function = nullptr) override;
|
||||
|
||||
inline void setNoSpace(bool bNoSpace) override { m_bNoSpace = bNoSpace; }
|
||||
inline bool noSpace() const override { return m_bNoSpace; }
|
||||
void logStartup(const char *file, int line, const char *function = nullptr) override;
|
||||
void logShutdown(const char *file, int line, const char *function = nullptr) override;
|
||||
|
||||
inline std::string getLoggerName() const override { return name; }
|
||||
inline void setNoSpace(bool bNoSpace) override { m_bNoSpace = bNoSpace; }
|
||||
inline bool noSpace() const override { return m_bNoSpace; }
|
||||
|
||||
static NGLLogger &getNGLRootLogger();
|
||||
static NGLLogger &createNGLRootLogger(const QString &configfilename,
|
||||
bool ignorealreadycreated,
|
||||
const QString &logOutputName = QString(),
|
||||
bool quiet = false);
|
||||
inline std::string getLoggerName() const override { return name; }
|
||||
|
||||
Log4Qt::Logger *log4qtLogger() { return logger_ptr; }
|
||||
protected:
|
||||
static void configurationFileChanged();
|
||||
void configChanged();
|
||||
static NGLLogger &getNGLRootLogger();
|
||||
static NGLLogger &createNGLRootLogger(const QString &configfilename, bool ignorealreadycreated, const QString &logOutputName = QString(), bool quiet = false);
|
||||
|
||||
private:
|
||||
Log4Qt::Logger *log4qtLogger() { return logger_ptr; }
|
||||
|
||||
Log4Qt::Logger *logger_ptr;
|
||||
const std::string name;
|
||||
LogLevel currentLevel;
|
||||
bool m_bNoSpace;
|
||||
protected:
|
||||
static void configurationFileChanged();
|
||||
void configChanged();
|
||||
|
||||
static NGLLogger *rootlogger_ptr;
|
||||
private:
|
||||
Log4Qt::Logger *logger_ptr;
|
||||
const std::string name;
|
||||
LogLevel currentLevel;
|
||||
bool m_bNoSpace;
|
||||
|
||||
friend class CleanupHelper;
|
||||
static CleanupHelper s_cleanup;
|
||||
static NGLLogger *rootlogger_ptr;
|
||||
|
||||
friend class XMLWatchdog;
|
||||
};
|
||||
friend class CleanupHelper;
|
||||
static CleanupHelper s_cleanup;
|
||||
|
||||
}
|
||||
friend class XMLWatchdog;
|
||||
};
|
||||
|
||||
}
|
||||
Executable → Regular
+2
-15
@@ -5,26 +5,13 @@
|
||||
#include "NGLLogger.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NGL::INGLLogger & NGL::NGLLoggerBootstrap::getNGLRootLogger()
|
||||
NGL::INGLLogger &NGL::NGLLoggerBootstrap::getNGLRootLogger()
|
||||
{
|
||||
return NGL::NGLLogger::getNGLRootLogger();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NGL::INGLLogger & NGL::NGLLoggerBootstrap::createNGLRootLogger(const QString &configfilename,
|
||||
bool ignorealreadycreated,
|
||||
const QString &logOutputName,
|
||||
bool quiet)
|
||||
NGL::INGLLogger &NGL::NGLLoggerBootstrap::createNGLRootLogger(const QString &configfilename, bool ignorealreadycreated, const QString &logOutputName, bool quiet)
|
||||
{
|
||||
return NGL::NGLLogger::createNGLRootLogger(configfilename, ignorealreadycreated, logOutputName, quiet);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,36 +9,31 @@
|
||||
namespace NGL
|
||||
{
|
||||
|
||||
namespace NGLLoggerBootstrap
|
||||
{
|
||||
class AlreadyCreatedError final : public std::exception
|
||||
{
|
||||
const char* what() const noexcept override
|
||||
namespace NGLLoggerBootstrap
|
||||
{
|
||||
class AlreadyCreatedError final : public std::exception
|
||||
{
|
||||
return "NGLLogger rootlogger already created!";
|
||||
}
|
||||
};
|
||||
const char *what() const noexcept override { return "NGLLogger rootlogger already created!"; }
|
||||
};
|
||||
|
||||
class NotCreatedError final : public std::exception
|
||||
{
|
||||
const char* what() const noexcept override
|
||||
class NotCreatedError final : public std::exception
|
||||
{
|
||||
return "NGLLogger rootlogger not yet created!";
|
||||
const char *what() const noexcept override { return "NGLLogger rootlogger not yet created!"; }
|
||||
};
|
||||
|
||||
NGLLOGGER_EXPORT INGLLogger &getNGLRootLogger();
|
||||
|
||||
NGLLOGGER_EXPORT INGLLogger &createNGLRootLogger(const QString &configfilename,
|
||||
bool ignorealreadycreated,
|
||||
const QString &logOutputName = QString(),
|
||||
bool quiet = false);
|
||||
|
||||
inline INGLLogger &createNGLRootLogger(const char *configfilename, bool ignorealreadycreated, const QString &logOutputName = QString())
|
||||
{
|
||||
return createNGLRootLogger(QString::fromUtf8(configfilename), ignorealreadycreated, logOutputName);
|
||||
}
|
||||
};
|
||||
|
||||
NGLLOGGER_EXPORT INGLLogger& getNGLRootLogger();
|
||||
|
||||
NGLLOGGER_EXPORT INGLLogger& createNGLRootLogger(const QString& configfilename, bool ignorealreadycreated,
|
||||
const QString& logOutputName = QString(), bool quiet = false);
|
||||
|
||||
inline INGLLogger& createNGLRootLogger(const char* configfilename, bool ignorealreadycreated,
|
||||
const QString& logOutputName = QString())
|
||||
{
|
||||
return createNGLRootLogger(QString::fromUtf8(configfilename), ignorealreadycreated, logOutputName);
|
||||
}
|
||||
|
||||
} // namespace NGLLoggerBootstrap
|
||||
} // namespace NGLLoggerBootstrap
|
||||
|
||||
} // namespace NGL
|
||||
|
||||
|
||||
Executable → Regular
+14
-14
@@ -4,19 +4,19 @@
|
||||
#define NGLLOGGER_EXPORT_H
|
||||
|
||||
#ifndef NGLLOGGER_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define NGLLOGGER_EXPORT
|
||||
# else
|
||||
# ifdef WIN32
|
||||
# ifdef MAKE_NGLLOGGER_LIB
|
||||
# define NGLLOGGER_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
# define NGLLOGGER_EXPORT __declspec(dllimport)
|
||||
# endif
|
||||
# else
|
||||
# define NGLLOGGER_EXPORT __attribute__((visibility("default")))
|
||||
# endif
|
||||
# endif
|
||||
#ifdef BUILD_STATIC_LIBRARIES
|
||||
#define NGLLOGGER_EXPORT
|
||||
#else
|
||||
#ifdef WIN32
|
||||
#ifdef MAKE_NGLLOGGER_LIB
|
||||
#define NGLLOGGER_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define NGLLOGGER_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define NGLLOGGER_EXPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -8,106 +8,123 @@
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
namespace Log4Qt {
|
||||
|
||||
// Minimal Logger class stub (no Q_OBJECT to avoid MOC requirements)
|
||||
class Logger
|
||||
namespace Log4Qt
|
||||
{
|
||||
public:
|
||||
|
||||
// Minimal Logger class stub (no Q_OBJECT to avoid MOC requirements)
|
||||
class Logger
|
||||
{
|
||||
public:
|
||||
explicit Logger(QObject *parent = nullptr) { Q_UNUSED(parent); }
|
||||
virtual ~Logger() = default;
|
||||
|
||||
|
||||
inline void trace(const QString &message) { Q_UNUSED(message); }
|
||||
inline void debug(const QString &message) { qDebug() << message; }
|
||||
inline void info(const QString &message) { qDebug() << message; }
|
||||
inline void warning(const QString &message) { qWarning() << message; }
|
||||
inline void error(const QString &message) { qCritical() << message; }
|
||||
inline void fatal(const QString &message) { qCritical() << message; }
|
||||
|
||||
|
||||
inline bool isTraceEnabled() const { return true; }
|
||||
inline bool isDebugEnabled() const { return true; }
|
||||
inline bool isInfoEnabled() const { return true; }
|
||||
inline bool isWarnEnabled() const { return true; }
|
||||
inline bool isErrorEnabled() const { return true; }
|
||||
};
|
||||
};
|
||||
|
||||
// Minimal RollingFileAppender stub
|
||||
class RollingFileAppender : public Logger
|
||||
{
|
||||
public:
|
||||
explicit RollingFileAppender(QObject *parent = nullptr) : Logger(parent) {}
|
||||
// Minimal RollingFileAppender stub
|
||||
class RollingFileAppender : public Logger
|
||||
{
|
||||
public:
|
||||
explicit RollingFileAppender(QObject *parent = nullptr)
|
||||
: Logger(parent)
|
||||
{
|
||||
}
|
||||
~RollingFileAppender() override = default;
|
||||
|
||||
|
||||
inline void setFile(const QString &filename) { Q_UNUSED(filename); }
|
||||
inline void setAppendFile(bool append) { Q_UNUSED(append); }
|
||||
virtual void activateOptions() {}
|
||||
};
|
||||
};
|
||||
|
||||
// Minimal LogManager stub
|
||||
class LogManager
|
||||
{
|
||||
public:
|
||||
static LogManager *instance() {
|
||||
static LogManager inst;
|
||||
return &inst;
|
||||
// Minimal LogManager stub
|
||||
class LogManager
|
||||
{
|
||||
public:
|
||||
static LogManager *instance()
|
||||
{
|
||||
static LogManager inst;
|
||||
return &inst;
|
||||
}
|
||||
|
||||
Logger *logger(const QString &name) {
|
||||
static Logger dummy;
|
||||
Q_UNUSED(name);
|
||||
return &dummy;
|
||||
|
||||
Logger *logger(const QString &name)
|
||||
{
|
||||
static Logger dummy;
|
||||
Q_UNUSED(name);
|
||||
return &dummy;
|
||||
}
|
||||
|
||||
|
||||
void setDefaultLogger(Logger *logger) { Q_UNUSED(logger); }
|
||||
};
|
||||
};
|
||||
|
||||
// Minimal PropertyConfigurator stub
|
||||
class PropertyConfigurator
|
||||
{
|
||||
public:
|
||||
static bool doConfigure(const QString &configFile) {
|
||||
Q_UNUSED(configFile);
|
||||
return false;
|
||||
// Minimal PropertyConfigurator stub
|
||||
class PropertyConfigurator
|
||||
{
|
||||
public:
|
||||
static bool doConfigure(const QString &configFile)
|
||||
{
|
||||
Q_UNUSED(configFile);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Minimal LoggerRepository stub
|
||||
class LoggerRepository
|
||||
{
|
||||
public:
|
||||
// Minimal LoggerRepository stub
|
||||
class LoggerRepository
|
||||
{
|
||||
public:
|
||||
inline void setThreshold(int level) { Q_UNUSED(level); }
|
||||
};
|
||||
};
|
||||
|
||||
// Minimal ConfiguratorHelper stub
|
||||
namespace Helpers {
|
||||
class ConfiguratorHelper {
|
||||
// Minimal ConfiguratorHelper stub
|
||||
namespace Helpers
|
||||
{
|
||||
class ConfiguratorHelper
|
||||
{
|
||||
public:
|
||||
static ConfiguratorHelper *instance() {
|
||||
static ConfiguratorHelper inst;
|
||||
return &inst;
|
||||
}
|
||||
static ConfiguratorHelper *instance()
|
||||
{
|
||||
static ConfiguratorHelper inst;
|
||||
return &inst;
|
||||
}
|
||||
};
|
||||
|
||||
class Properties {
|
||||
|
||||
class Properties
|
||||
{
|
||||
public:
|
||||
Properties() {}
|
||||
inline void setProperty(const QString &key, const QString &value) {
|
||||
Q_UNUSED(key); Q_UNUSED(value);
|
||||
}
|
||||
Properties() {}
|
||||
inline void setProperty(const QString &key, const QString &value)
|
||||
{
|
||||
Q_UNUSED(key);
|
||||
Q_UNUSED(value);
|
||||
}
|
||||
};
|
||||
|
||||
class Factory {
|
||||
|
||||
class Factory
|
||||
{
|
||||
public:
|
||||
static Factory *instance() {
|
||||
static Factory inst;
|
||||
return &inst;
|
||||
}
|
||||
inline void registerAppender(const QString &name, void *creator) {
|
||||
Q_UNUSED(name); Q_UNUSED(creator);
|
||||
}
|
||||
static Factory *instance()
|
||||
{
|
||||
static Factory inst;
|
||||
return &inst;
|
||||
}
|
||||
inline void registerAppender(const QString &name, void *creator)
|
||||
{
|
||||
Q_UNUSED(name);
|
||||
Q_UNUSED(creator);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Log4Qt
|
||||
|
||||
#endif // LOG4QT_STUB_H
|
||||
#endif // LOG4QT_STUB_H
|
||||
Executable → Regular
+14
-14
@@ -8,26 +8,26 @@ int main(int argc, char **argv)
|
||||
|
||||
NGL::NGLLoggerBootstrap::createNGLRootLogger("log4cxx.props", false);
|
||||
|
||||
NGL::INGLLogger &l = NGL::NGLLoggerBootstrap::getNGLRootLogger(). getNGLLogger( "Gui" );
|
||||
NGL::INGLLogger &l = NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("Gui");
|
||||
|
||||
STARTUP_LOG(l);
|
||||
SHUTDOWN_LOG(l);
|
||||
NOTICE_LOG(l) << "Gui - NOTICE";
|
||||
TRACE_LOG(l) << "Gui - TRACE";
|
||||
DEBUG_LOG(l) << "Gui - DEBUG";
|
||||
INFO_LOG(l) << "Gui - INFO";
|
||||
NOTICE_LOG(l) << "Gui - NOTICE";
|
||||
TRACE_LOG(l) << "Gui - TRACE";
|
||||
DEBUG_LOG(l) << "Gui - DEBUG";
|
||||
INFO_LOG(l) << "Gui - INFO";
|
||||
WARNING_LOG(l) << "Gui - WARNING";
|
||||
ERROR_LOG(l) << "Gui - ERROR";
|
||||
FATAL_LOG(l) << "Gui - FATAL";
|
||||
ERROR_LOG(l) << "Gui - ERROR";
|
||||
FATAL_LOG(l) << "Gui - FATAL";
|
||||
|
||||
NGL::INGLLogger &l2 = NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger( "Gui.AES" );
|
||||
NOTICE_LOG(l2) << "Gui.AES - NOTICE";
|
||||
TRACE_LOG(l2) << "Gui.AES - TRACE";
|
||||
DEBUG_LOG(l2) << "Gui.AES - DEBUG";
|
||||
INFO_LOG(l2) << "Gui.AES - INFO";
|
||||
NGL::INGLLogger &l2 = NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("Gui.AES");
|
||||
NOTICE_LOG(l2) << "Gui.AES - NOTICE";
|
||||
TRACE_LOG(l2) << "Gui.AES - TRACE";
|
||||
DEBUG_LOG(l2) << "Gui.AES - DEBUG";
|
||||
INFO_LOG(l2) << "Gui.AES - INFO";
|
||||
WARNING_LOG(l2) << "Gui.AES - WARNING";
|
||||
ERROR_LOG(l2) << "Gui.AES - ERROR";
|
||||
FATAL_LOG(l2) << "Gui.AES - FATAL";
|
||||
ERROR_LOG(l2) << "Gui.AES - ERROR";
|
||||
FATAL_LOG(l2) << "Gui.AES - FATAL";
|
||||
SHUTDOWN_LOG(l2)
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user