X-Git-Url: https://vaikene.ee/gitweb/pswgen11.html?a=blobdiff_plain;f=src%2Flibs%2FCommon%2Filogger.h;h=71dbd14cd9a34c9133449f2923ea04ec62f7b4aa;hb=f01d61fb753b347bbff2ffb7f224650ac3f9d81e;hp=4a75e3e42390ed026aca7ae880de3ac220bc9cfc;hpb=5815060246f84e8efdf3143b4e8c7d00778168cf;p=evaf
diff --git a/src/libs/Common/ilogger.h b/src/libs/Common/ilogger.h
index 4a75e3e..71dbd14 100644
--- a/src/libs/Common/ilogger.h
+++ b/src/libs/Common/ilogger.h
@@ -62,7 +62,8 @@ public:
Error, ///< Unexpected issues in the software that could be solved automatically.
Warning, ///< Expected issues in the software that will be solved automatically.
Info, ///< General information output by the application or modules.
- Debug ///< Information for debugging purposes.
+ Debug, ///< Information for debugging purposes.
+ Count ///< Number of severity levels
};
/// Interface constructor
@@ -99,7 +100,7 @@ public:
* Returns the current severity level
* @param source Name of the source or default if omitted.
*/
- virtual Severity severity(QString const & source = 0) const = 0;
+ virtual Severity severity(QString const & source = 0) = 0;
/**
* Changes the current severity level.
@@ -110,13 +111,13 @@ public:
* are output. With this function the severity level can be changed so that also less important
* messages are output.
*/
- virtual void setSeverity(Severity severity, QString const & source) = 0;
+ virtual void setSeverity(Severity severity, QString const & source = 0) = 0;
/**
* Returns the current maximum size of log files in KiB.
* @param source Name of the source or default if omitted.
*/
- virtual uint maxSize(QString const & source = 0) const = 0;
+ virtual uint maxSize(QString const & source = 0) = 0;
/**
* Changes the maximum size of log files for the given source
@@ -136,7 +137,7 @@ public:
* Returns the maximum number of log files.
* @param source Name of the source or default if omitted.
*/
- virtual uint maxCount(QString const & source = 0) const = 0;
+ virtual uint maxCount(QString const & source = 0) = 0;
/**
* Changes the maximum number of log files
@@ -226,6 +227,22 @@ public:
*/
virtual FatalMsgHandler installFatalMsgHandler(FatalMsgHandler newHandler) = 0;
+
+signals:
+
+ /**
+ * Logger event signal
+ * @param severity Severity of the message
+ * @param text The message
+ * @param source Source of the message
+ * @param where Where the message was output
+ *
+ * This signal is emitted for every message output with the iLogger interface. Connect
+ * your receiver to this signal if you want to add your own message handling. For example,
+ * use this signal to show messages in a log window etc.
+ */
+ void loggerEvent(Common::iLogger::Severity severity, QString const & text, QString const & source, QString const & where);
+
};
} // namespace eVaf::Common
@@ -244,4 +261,89 @@ void COMMON_EXPORT qInfo(char const * const msg, ...)
#endif
;
+/**
+ * Macro for fatal error messages.
+ *
+ * This macro expands to a fatal error message output with the location in the source code where the error
+ * occurred.
+ */
+#define EVAF_FATAL_ERROR(...) \
+ do { \
+ eVaf::Common::iLogger::instance()->write( \
+ eVaf::Common::iLogger::Fatal, \
+ eVaf::Common::iLogger::instance()->printf(__VA_ARGS__), \
+ 0, \
+ eVaf::Common::iLogger::instance()->printf("%s:%s:%d", __FILE__, __FUNCTION__, __LINE__) \
+ ); \
+ } while (0)
+
+/**
+ * Macro for error messages.
+ *
+ * This macro expands to an error message output with the location in the source code where the error
+ * occurred.
+ */
+#define EVAF_ERROR(...) \
+ do { \
+ eVaf::Common::iLogger::instance()->write( \
+ eVaf::Common::iLogger::Error, \
+ eVaf::Common::iLogger::instance()->printf(__VA_ARGS__), \
+ 0, \
+ eVaf::Common::iLogger::instance()->printf("%s:%s:%d", __FILE__, __FUNCTION__, __LINE__) \
+ ); \
+ } while (0)
+
+/**
+ * Macro for warning messages.
+ *
+ * This macro expands to a warning message output with the location in the source code where the warning
+ * occurred.
+ */
+#define EVAF_WARNING(...) \
+ do { \
+ eVaf::Common::iLogger::instance()->write( \
+ eVaf::Common::iLogger::Warning, \
+ eVaf::Common::iLogger::instance()->printf(__VA_ARGS__), \
+ 0, \
+ eVaf::Common::iLogger::instance()->printf("%s:%s:%d", __FILE__, __FUNCTION__, __LINE__) \
+ ); \
+ } while (0)
+
+/**
+ * Macro for info messages.
+ *
+ * This macro expands to an info message output with the location in the source code where the message
+ * is output.
+ */
+#define EVAF_INFO(...) \
+ do { \
+ eVaf::Common::iLogger::instance()->write( \
+ eVaf::Common::iLogger::Info, \
+ eVaf::Common::iLogger::instance()->printf(__VA_ARGS__), \
+ 0, \
+ eVaf::Common::iLogger::instance()->printf("%s:%s:%d", __FILE__, __FUNCTION__, __LINE__) \
+ ); \
+ } while (0)
+
+/**
+ * Macro for debug messages.
+ *
+ * This macro expands to a debug message output with the location in the source code where the message
+ * is output. All the debug messages are supressed when the NDEBUG directive is defined.
+ */
+#ifndef NDEBUG
+# define EVAF_DEBUG(...) \
+ do { \
+ eVaf::Common::iLogger::instance()->write( \
+ eVaf::Common::iLogger::Debug, \
+ eVaf::Common::iLogger::instance()->printf(__VA_ARGS__), \
+ 0, \
+ eVaf::Common::iLogger::instance()->printf("%s:%s:%d", __FILE__, __FUNCTION__, __LINE__) \
+ ); \
+ } while (0)
+#else
+# define EVAF_DEBUG(...) \
+ do { } while (0)
+#endif
+
#endif // ilogger.h