PostGIS  3.7.0dev-r@@SVN_REVISION@@
lwgeom_log.h
Go to the documentation of this file.
1 /**********************************************************************
2  *
3  * PostGIS - Spatial Types for PostgreSQL
4  * http://postgis.net
5  *
6  * PostGIS is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * PostGIS is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with PostGIS. If not, see <http://www.gnu.org/licenses/>.
18  *
19  **********************************************************************
20  *
21  * Copyright 2011 Sandro Santilli <strk@kbt.io>
22  * Copyright 2008 Paul Ramsey <pramsey@cleverelephant.ca>
23  * Copyright 2007-2008 Mark Cave-Ayland
24  * Copyright 2001-2006 Refractions Research Inc.
25  *
26  **********************************************************************/
27 
28 
29 #ifndef LWGEOM_LOG_H
30 #define LWGEOM_LOG_H 1
31 
32 #include <stdarg.h>
33 
34 /*
35  * Debug macros
36  */
37 #if POSTGIS_DEBUG_LEVEL > 0
38 
39 /* Display a notice at the given debug level */
40 #define LWDEBUG(level, msg) \
41  do { \
42  if (POSTGIS_DEBUG_LEVEL >= level) \
43  lwdebug(level, "[%s:%s:%d] " msg, __FILE__, __func__, __LINE__); \
44  } while (0);
45 
46 /* Display a formatted notice at the given debug level
47  * (like printf, with variadic arguments) */
48 #define LWDEBUGF(level, msg, ...) \
49  do { \
50  if (POSTGIS_DEBUG_LEVEL >= level) \
51  lwdebug(level, "[%s:%s:%d] " msg, \
52  __FILE__, __func__, __LINE__, __VA_ARGS__); \
53  } while (0);
54 
55 #ifdef POSTGIS_DEBUG_GEOMETRY_WKB
56 /* Display a notice and a HEXWKB representation of a geometry
57  * at the given debug level */
58 #define LWDEBUGG(level, geom, msg) \
59  if (POSTGIS_DEBUG_LEVEL >= level) \
60  do { \
61  char *wkt = lwgeom_to_hexwkb_buffer(geom, WKB_EXTENDED); \
62  LWDEBUGF(level, msg ": %s", wkt); \
63  lwfree(wkt); \
64  } while (0);
65 /* Display a formatted notice and a HEXWKB representation of a geometry
66  * at the given debug level */
67 #define LWDEBUGGF(level, geom, fmt, ...) \
68  if (POSTGIS_DEBUG_LEVEL >= level) \
69  do { \
70  char *wkt = lwgeom_to_hexwkb_buffer(geom, WKT_EXTENDED); \
71  LWDEBUGF(level, fmt ": %s", __VA_ARGS__, wkt); \
72  lwfree(wkt); \
73  } while (0);
74 #else /* ndef POSTGIS_DEBUG_GEOMETRY_WKB */
75 /* Display a notice and an HEXWKB representation of a geometry
76  * at the given debug level */
77 #define LWDEBUGG(level, geom, msg) \
78  if (POSTGIS_DEBUG_LEVEL >= level) \
79  do { \
80  size_t sz; \
81  char *wkt = lwgeom_to_wkt(geom, WKT_EXTENDED, 15, &sz); \
82  LWDEBUGF(level, msg ": %s", wkt); \
83  lwfree(wkt); \
84  } while (0);
85 /* Display a formatted notice and a WKT representation of a geometry
86  * at the given debug level */
87 #define LWDEBUGGF(level, geom, fmt, ...) \
88  if (POSTGIS_DEBUG_LEVEL >= level) \
89  do { \
90  size_t sz; \
91  char *wkt = lwgeom_to_wkt(geom, WKT_EXTENDED, 15, &sz); \
92  LWDEBUGF(level, fmt ": %s", __VA_ARGS__, wkt); \
93  lwfree(wkt); \
94  } while (0);
95 #endif
96 
97 #else /* POSTGIS_DEBUG_LEVEL <= 0 */
98 
99 /* Empty prototype that can be optimised away by the compiler
100  * for non-debug builds */
101 #define LWDEBUG(level, msg) \
102  ((void) 0)
103 
104 /* Empty prototype that can be optimised away by the compiler
105  * for non-debug builds */
106 #define LWDEBUGF(level, msg, ...) \
107  ((void) 0)
108 
109 /* Empty prototype that can be optimised away by the compiler
110  * for non-debug builds */
111 #define LWDEBUGG(level, geom, msg) \
112  ((void) 0)
113 
114 /* Empty prototype that can be optimised away by the compiler
115  * for non-debug builds */
116 #define LWDEBUGGF(level, geom, fmt, ...) \
117  ((void) 0)
118 
119 #endif /* POSTGIS_DEBUG_LEVEL <= 0 */
120 
129 void lwnotice(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
130 
139 void lwerror(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
140 
148 void lwdebug(int level, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
149 
150 
151 
152 #endif /* LWGEOM_LOG_H */
#define __attribute__(x)
Definition: liblwgeom.h:228
void lwnotice(const char *fmt,...) __attribute__((format(printf
Write a notice out to the notice handler.
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
void void void lwdebug(int level, const char *fmt,...) __attribute__((format(printf
Write a debug message out.
def fmt
Definition: pixval.py:94