[postgis-tickets] r14964 - Add LWDEBUGGF macro

Sandro Santilli strk at kbt.io
Thu Jun 16 04:26:00 PDT 2016


Author: strk
Date: 2016-06-16 04:25:59 -0700 (Thu, 16 Jun 2016)
New Revision: 14964

Modified:
   trunk/liblwgeom/lwgeom_log.h
Log:
Add LWDEBUGGF macro

Modified: trunk/liblwgeom/lwgeom_log.h
===================================================================
--- trunk/liblwgeom/lwgeom_log.h	2016-06-16 10:45:12 UTC (rev 14963)
+++ trunk/liblwgeom/lwgeom_log.h	2016-06-16 11:25:59 UTC (rev 14964)
@@ -64,6 +64,18 @@
     lwfree(wkt); \
   } while (0);
 
+/* Display a formatted notice and a WKT representation of a geometry
+ * at the given debug level */
+#define LWDEBUGGF(level, geom, fmt, ...) \
+  if (POSTGIS_DEBUG_LEVEL >= level) \
+  do { \
+    size_t sz; \
+    char *wkt = lwgeom_to_wkt(geom, WKT_EXTENDED, 15, &sz); \
+    /* char *wkt = lwgeom_to_hexwkb(geom, WKT_EXTENDED, &sz); */ \
+    LWDEBUGF(level, fmt ": %s", __VA_ARGS__, wkt); \
+    lwfree(wkt); \
+  } while (0);
+
 #else /* POSTGIS_DEBUG_LEVEL <= 0 */
 
 /* Empty prototype that can be optimised away by the compiler



More information about the postgis-tickets mailing list