[niepce] Fix the assert code to actually show the function name as well as the assert.



commit f74d3d5e97ba6c492cc6925a2e3000e30652d29d
Author: Hub Figuiere <hub figuiere net>
Date:   Sun Nov 6 10:12:47 2011 -0800

    Fix the assert code to actually show the function name as well as the assert.

 src/fwk/base/debug.cpp |   22 ++++++++++++++++------
 src/fwk/base/debug.hpp |   32 +++++++++++++++++++++-----------
 2 files changed, 37 insertions(+), 17 deletions(-)
---
diff --git a/src/fwk/base/debug.cpp b/src/fwk/base/debug.cpp
index 5a6fca3..d54186b 100644
--- a/src/fwk/base/debug.cpp
+++ b/src/fwk/base/debug.cpp
@@ -66,13 +66,14 @@ namespace fwk {
 	/** assert 
 	 * 
 	 */
-	void dbg_assert(bool condvalue, const char* cond, const char* filen,
-					int linen, const char* reason)
+	void dbg_assert(bool condvalue, const char* cond, 
+                        const char* func, const char* filen,
+                        int linen, const char* reason)
 	{
-		if(!condvalue) {
-			_print("ASSERT: ", "%s:%d %s", cond, filen, linen, reason);
-
-		}
+            if(!condvalue) {
+                _print("ASSERT: ", "[%s] %s:%d %s", func, cond, filen, linen, reason);
+                
+            }
 	}
 
 
@@ -121,3 +122,12 @@ namespace fwk {
 	}
 
 }
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0))
+  indent-tabs-mode:nil
+  fill-column:80
+  End:
+*/
diff --git a/src/fwk/base/debug.hpp b/src/fwk/base/debug.hpp
index 73fdd30..247dd0a 100644
--- a/src/fwk/base/debug.hpp
+++ b/src/fwk/base/debug.hpp
@@ -41,7 +41,7 @@ namespace fwk {
 
 #ifdef DEBUG
 #define DBG_ASSERT(cond, reason)	\
-	fwk::dbg_assert(cond, #cond, __FILE__, __LINE__, reason)
+	fwk::dbg_assert(cond, #cond, __FUNCTION__, __FILE__, __LINE__, reason)
 #else
 #define DBG_ASSERT(cond, reason)	\
 	assert(cond)
@@ -60,15 +60,17 @@ namespace fwk {
 	void dbg_print(const char* fmt, const char* func, ...)
     __attribute__ ((format (printf, 1, 3)));
 
-	/** assert 
-	 * @param condvalue the value of the assert, true, assert
-	 * @param cond the text of the condition
-	 * @param filen the file name __FILE__
-	 * @param linen the line number __LINE__
-	 * @param reason the reason of the assert
-	 */
-	void dbg_assert(bool condvalue, const char* cond, const char* filen,
-					int linen, const char* reason);
+/** assert 
+ * @param condvalue the value of the assert, true, assert
+ * @param cond the text of the condition
+ * @param func the function it happens in __FUNCTION__
+ * @param filen the file name __FILE__
+ * @param linen the line number __LINE__
+ * @param reason the reason of the assert
+ */
+void dbg_assert(bool condvalue, const char* cond, const char* func,
+                const char* filen,
+                int linen, const char* reason);
 
 	/** print error message. printf format.
 	 * Call with the ERR_OUT macro.
@@ -80,5 +82,13 @@ namespace fwk {
 
 }
 
-
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0))
+  indent-tabs-mode:nil
+  fill-column:80
+  End:
+*/
 #endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]