]> vaikene.ee Git - evaf/blobdiff - src/libs/Common/ilogger.h
More work on the common library and the main GUI application.
[evaf] / src / libs / Common / ilogger.h
index ecc4858bb8d4a11330b026858de7c6ed411786cc..81d80160fbcfb707648f3fce57f953731d387e72 100644 (file)
@@ -79,7 +79,7 @@ public:
      * are expected to be linked against the Common library, then this is the preferred method of obtaining
      * the iLogger interface. The other method is by using the iRegistry interface.
      */
-    static iLogger::instance();
+    static iLogger * instance();
 
     /**
      * Returns the current default source name.
@@ -110,7 +110,7 @@ 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.
@@ -244,4 +244,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