![]() |
GemaCoreLib
The GeMA Core library
|
Declaration of support functions and macros for information logging. More...
Go to the source code of this file.
Classes | |
class | GmLogCategory |
Class representing a category with multiple logging levels. More... | |
class | GmLogSignalEmitter |
Aux class whose only purpose is to allow loggers to emit a logMessage signal, if configured to do so. More... | |
class | GmLogIdenter |
RAII object to add an identation level to log messages, reverting the settings when the object is destroyed. More... | |
class | GmLogIdentClearer |
RAII object to clear the identation level to log messages, restoring to the previous identation when the object is destroyed. More... | |
class | GmTimeMsg |
RAII object used to measure the elapsed time of an operation. More... | |
class | GmTimeAdder |
RAII class used to add the elapsed time to a counter received by reference. Counter is incremented in nano seconds. More... | |
Macros | |
#define | gmLog(category, level, ...) qCDebug((category).qtCategory(level), __VA_ARGS__) |
#define | gmTrace(category, ...) qCDebug((category).qtCategory(GM_TRACE), __VA_ARGS__) |
#define | gmExtInfo(category, ...) qCDebug((category).qtCategory(GM_EXT_INFO), __VA_ARGS__) |
#define | gmInfo(category, ...) qCDebug((category).qtCategory(GM_INFO), __VA_ARGS__) |
#define | gmWarn(category, ...) qCDebug((category).qtCategory(GM_WARNING), __VA_ARGS__) |
#define | gmError(category, ...) qCDebug((category).qtCategory(GM_ERROR), __VA_ARGS__) |
#define | gmFatal(category, ...) qCDebug((category).qtCategory(GM_FATAL), __VA_ARGS__) |
#define | gmTime(category, ...) qCDebug((category).qtCategory(GM_TIME), __VA_ARGS__) |
#define | gmMemory(category, ...) qCDebug((category).qtCategory(GM_MEMORY), __VA_ARGS__) |
#define | gmLogMsg(category, level, msg) qCDebug((category).qtCategory(level), qPrintable(msg)) |
#define | gmTraceMsg(category, msg) qCDebug((category).qtCategory(GM_TRACE), qPrintable(msg)) |
#define | gmExtInfoMsg(category, msg) qCDebug((category).qtCategory(GM_EXT_INFO), qPrintable(msg)) |
#define | gmInfoMsg(category, msg) qCDebug((category).qtCategory(GM_INFO), qPrintable(msg)) |
#define | gmWarnMsg(category, msg) qCDebug((category).qtCategory(GM_WARNING), qPrintable(msg)) |
#define | gmErrorMsg(category, msg) qCDebug((category).qtCategory(GM_ERROR), qPrintable(msg)) |
#define | gmFatalMsg(category, msg) qCDebug((category).qtCategory(GM_FATAL), qPrintable(msg)) |
#define | gmTimeMsg(category, msg) qCDebug((category).qtCategory(GM_TIME), qPrintable(msg)) |
#define | gmMemoryMsg(category, msg) qCDebug((category).qtCategory(GM_MEMORY), qPrintable(msg)) |
Enumerations | |
enum | GmLogLevel { GM_TRACE, GM_EXT_INFO, GM_INFO, GM_WARNING, GM_ERROR, GM_FATAL, GM_TIME, GM_MEMORY, GM_COUNT } |
Available log levels list. More... | |
Functions | |
GMC_API_EXPORT void | GmLogInit () |
Initializes the logging facilities. | |
GMC_API_EXPORT bool | GmSetConsoleLogging (bool mode) |
Enables or disables logging to the console. Returns the previous mode. | |
GMC_API_EXPORT void | GmSetLogFile (QString logfile, bool flush, const GmLogCategory &logger) |
Enables and configures file logging. More... | |
GMC_API_EXPORT void | GmCloseLogFile () |
Closes the log file if enabled. | |
GMC_API_EXPORT void | GmFlushLogFile () |
Flushes the log file if enabled. | |
GMC_API_EXPORT bool | GmSetShowLoggerName (bool mode) |
Enables or disables showing the logger name before each message. Returns the previous mode. | |
GMC_API_EXPORT bool | GmSetShowThreadId (bool mode) |
Enables or disables showing the thread id before each message. Returns the previous mode. | |
GMC_API_EXPORT bool | GmSetHideRepeatedWarnings (bool mode) |
Enables or disables skipping repeated warning messages. Returns the previous mode. | |
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 ones. | |
GMC_API_EXPORT void | GmSetLogLevels (LuaTable &tab, const QList< QPair< QString, bool > > &extraRules, const GmLogCategory &logger) |
Load a new set of logging rules from table tab, using logger to emmit warnings in case of errors on the table. More... | |
GMC_API_EXPORT bool | GmLoggerDecorations (void) |
Returns the current logger decoration mode. When set to true, code logging value tables should add decorations to aid regression tests. | |
GMC_API_EXPORT bool | GmSetLoggerDecorations (bool mode) |
Updates the current logger decoration mode. Returns the previous mode. | |
GMC_API_EXPORT bool | GmSetStringListLogging (bool mode, QStringList *targetList=NULL) |
Enables or disables logging to a string list. This is usefull for capturing messages for testing purposes. More... | |
GMC_API_EXPORT const QStringList & | GmLogStringList () |
Returns the logging string list (has contents only if GmSetStringListLogging(true) was called before) | |
GMC_API_EXPORT bool | GmSetCollectTimeStatistics (bool mode) |
Enables or disables the collection of time statistics from messages emmitted with GmTimeMsg. | |
GMC_API_EXPORT void | GmAddToTimeStatistics (const QString &msg, qint64 elapsedTime) |
Adds the given time to the global statistics for the giiven message used as identifir in calls to GmTimeMsg. | |
GMC_API_EXPORT void | GmLogTimeStatistics (const GmLogCategory &logger) |
Logs the current contents of the time statistics map using the given logger. Expects to be called from the main thread only. | |
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 the signal. | |
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 spaces but can end up being done anywhere if there is no space in the last maxBreak characters. | |
GMC_API_EXPORT void | GmLogIdent (int offset) |
Changes the current identation level. | |
GMC_API_EXPORT int | GmLogIdentClear () |
Clears the current identation level, returning the old one. | |
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 something (on the first call, gives the difference from the amount of memory in use when the memory manager was initialized in the GmLogInit() function. | |
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 needed) value. | |
GMC_API_EXPORT const GmLogCategory & | GmPanicLogger () |
Returns the global "panic" logger, usually used to report memory allocation fails deep inside class structures with no easy access to another logger. | |
Declaration of support functions and macros for information logging.
enum GmLogLevel |
Available log levels list.
GMC_API_EXPORT void GmSetLogFile | ( | QString | logfile, |
bool | flush, | ||
const GmLogCategory & | logger | ||
) |
Enables and configures file logging.
logfile | The log file name |
flush | Set to true for forcing a flush after each log write |
logger | Logger used to report success/problems while opening the log file |
GMC_API_EXPORT void GmSetLogLevels | ( | LuaTable & | tab, |
const QList< QPair< QString, bool > > & | extraRules, | ||
const GmLogCategory & | logger | ||
) |
Load a new set of logging rules from table tab, using logger to emmit warnings in case of errors on the table.
The table should be a list following the following syntax example: tab = {{'gema.simLoader.info', true }, {'*.trace', false}, {'gema.simLoader.*', true }, } Loaded rules are applied on top of the default ruels set in GmLogInit() Extra rules in 'extraRules' are applied on top of the Lua table rules and can be used to override some of those config file options.
GMC_API_EXPORT bool GmSetStringListLogging | ( | bool | mode, |
QStringList * | targetList | ||
) |
Enables or disables logging to a string list. This is usefull for capturing messages for testing purposes.
If targetList is different from NULL, the supplied list will be used to store log messages. Otherwise an internal list will be used. This parameter is relevant only when turning list logginng on.
When logging is disabled, if the target list is the internal list, it is also cleared. Returns the previous mode.