30#include <QLoggingCategory>
72 static GmLogLevel str2Level(
const char* levelStr);
81#define gmLog(category, level, ...) qCDebug((category).qtCategory(level), __VA_ARGS__)
83#define gmTrace(category, ...) qCDebug((category).qtCategory(GM_TRACE), __VA_ARGS__)
84#define gmExtInfo(category, ...) qCDebug((category).qtCategory(GM_EXT_INFO), __VA_ARGS__)
85#define gmInfo(category, ...) qCDebug((category).qtCategory(GM_INFO), __VA_ARGS__)
86#define gmWarn(category, ...) qCDebug((category).qtCategory(GM_WARNING), __VA_ARGS__)
87#define gmError(category, ...) qCDebug((category).qtCategory(GM_ERROR), __VA_ARGS__)
88#define gmFatal(category, ...) qCDebug((category).qtCategory(GM_FATAL), __VA_ARGS__)
89#define gmTime(category, ...) qCDebug((category).qtCategory(GM_TIME), __VA_ARGS__)
90#define gmMemory(category, ...) qCDebug((category).qtCategory(GM_MEMORY), __VA_ARGS__)
92#define gmLogMsg(category, level, msg) qCDebug((category).qtCategory(level), qPrintable(msg))
94#define gmTraceMsg(category, msg) qCDebug((category).qtCategory(GM_TRACE), qPrintable(msg))
95#define gmExtInfoMsg(category, msg) qCDebug((category).qtCategory(GM_EXT_INFO), qPrintable(msg))
96#define gmInfoMsg(category, msg) qCDebug((category).qtCategory(GM_INFO), qPrintable(msg))
97#define gmWarnMsg(category, msg) qCDebug((category).qtCategory(GM_WARNING), qPrintable(msg))
98#define gmErrorMsg(category, msg) qCDebug((category).qtCategory(GM_ERROR), qPrintable(msg))
99#define gmFatalMsg(category, msg) qCDebug((category).qtCategory(GM_FATAL), qPrintable(msg))
100#define gmTimeMsg(category, msg) qCDebug((category).qtCategory(GM_TIME), qPrintable(msg))
101#define gmMemoryMsg(category, msg) qCDebug((category).qtCategory(GM_MEMORY), qPrintable(msg))
109 void logMessage(
int level,
QString msg);
135 int maxSize = 120,
int maxBreak = 30);
Class representing a category with multiple logging levels.
Definition gmLog.h:58
QLoggingCategory & qtCategory(GmLogLevel level) const
Returns the "Qt category" that represents the requested level.
Definition gmLog.h:70
void setEnabled(GmLogLevel level, bool mode)
Enables or disables log messages for the requested level.
Definition gmLog.h:67
bool isEnabled(GmLogLevel level) const
Returns true if messages for this log level are enabled, false otherwise.
Definition gmLog.h:64
RAII object to clear the identation level to log messages, restoring to the previous identation when ...
Definition gmLog.h:161
RAII object to add an identation level to log messages, reverting the settings when the object is des...
Definition gmLog.h:149
Aux class whose only purpose is to allow loggers to emit a logMessage signal, if configured to do so.
Definition gmLog.h:105
Declaration of useful configuration definitions for the Core library.
#define GMC_API_EXPORT
Macro for controlling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_L...
Definition gmCoreConfig.h:35
int GmLogIdentClear()
Clears the current identation level, returning the old one.
Definition gmLog.cpp:572
void GmLogIdent(int offset)
Changes the current identation level.
Definition gmLog.cpp:563
GMC_API_EXPORT void GmSetLogFile(QString logfile, bool flush, const GmLogCategory &logger)
Enables and configures file logging.
Definition gmLog.cpp:319
GMC_API_EXPORT bool GmSetLoggerDecorations(bool mode)
Updates the current logger decoration mode. Returns the previous mode.
Definition gmLog.cpp:517
GMC_API_EXPORT bool GmSetShowThreadId(bool mode)
Enables or disables showing the thread id before each message. Returns the previous mode.
Definition gmLog.cpp:376
GmLogLevel
Available log levels list.
Definition gmLog.h:36
@ GM_COUNT
Number of log levels.
Definition gmLog.h:47
@ GM_TRACE
Trace information to help system debugging. Much more info than you want.
Definition gmLog.h:37
@ GM_MEMORY
Reporting memory information. New category so as to be easy to disable all memory messages for tests ...
Definition gmLog.h:44
@ GM_EXT_INFO
Extended information. Probably more than you wanted.
Definition gmLog.h:38
@ GM_ERROR
Reporting an error from which the system can continue (maybe not with its total capacity)
Definition gmLog.h:41
@ GM_FATAL
Reporting a fatal error. The system cannot continue.
Definition gmLog.h:42
@ GM_TIME
Reporting timing information. New category so as to be easy to disable all timing messages for tests ...
Definition gmLog.h:43
@ GM_INFO
Information regarding system evolution and config. Should be the "right" level of messages.
Definition gmLog.h:39
@ GM_WARNING
A warning message reporting something strange but not necessarilly an error.
Definition gmLog.h:40
GMC_API_EXPORT void GmCloseLogFile()
Closes the log file if enabled.
Definition gmLog.cpp:343
GMC_API_EXPORT void GmLogWrappedMsg(const GmLogCategory &logger, GmLogLevel level, const QString &msg, int maxSize=120, int maxBreak=30)
Logs the given message breaking lines bigger than maxSize. Message breaking is preferentially done on...
Definition gmLog.cpp:531
GMC_API_EXPORT const QStringList & GmLogStringList()
Returns the logging string list (has contents only if GmSetStringListLogging(true) was called before)
Definition gmLog.cpp:428
GMC_API_EXPORT void GmLogInit()
Initializes the logging facilities.
Definition gmLog.cpp:276
GMC_API_EXPORT bool GmLoggerDecorations(void)
Returns the current logger decoration mode. When set to true, code logging value tables should add de...
Definition gmLog.cpp:511
GMC_API_EXPORT void GmLogIdent(int offset)
Changes the current identation level.
Definition gmLog.cpp:563
GMC_API_EXPORT bool GmSetShowLoggerName(bool mode)
Enables or disables showing the logger name before each message. Returns the previous mode.
Definition gmLog.cpp:365
GMC_API_EXPORT bool GmSetConsoleLogging(bool mode)
Enables or disables logging to the console. Returns the previous mode.
Definition gmLog.cpp:302
GMC_API_EXPORT const QObject * GmSetLoggingSignal(bool enable)
Enables or disables logging to the logMessage signal. Returns the object that will be used to emit th...
Definition gmLog.cpp:437
GMC_API_EXPORT void GmLogMemoryUsage(const GmLogCategory &logger, const QString &msg)
Log the current memory usage and the difference from the last call to GmLogMemoryUsage that printed s...
Definition gmLog.cpp:585
GMC_API_EXPORT bool GmSetStringListLogging(bool mode, QStringList *targetList=NULL)
Enables or disables logging to a string list. This is useful for capturing messages for testing purpo...
Definition gmLog.cpp:407
GMC_API_EXPORT const GmLogCategory & GmPanicLogger()
Returns the global "panic" logger, usually used to report memory allocation fails deep inside class s...
Definition gmLog.cpp:647
GMC_API_EXPORT void GmFlushLogFile()
Flushes the log file if enabled.
Definition gmLog.cpp:356
GMC_API_EXPORT int GmLogIdentClear()
Clears the current identation level, returning the old one.
Definition gmLog.cpp:572
GMC_API_EXPORT void GmSetLogLevels(const QList< QPair< QString, bool > > &rules)
Load a new set of logging rules from a rules list. Adds the no qt rules option on top of the given on...
Definition gmLog.cpp:447
GMC_API_EXPORT bool GmSetHideRepeatedWarnings(bool mode)
Enables or disables skipping repeated warning messages. Returns the previous mode.
Definition gmLog.cpp:387
GMC_API_EXPORT QString GmLogFormatMemory(size_t s)
Return a string with the memory size converted to kB, MB or GB, adding the unit to the converted (if ...
Definition gmLog.cpp:630