PostGIS  2.5.0beta2dev-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 /* Display a notice and a WKT representation of a geometry
56  * at the given debug level */
57 #define LWDEBUGG(level, geom, msg) \
58  if (POSTGIS_DEBUG_LEVEL >= level) \
59  do { \
60  size_t sz; \
61  char *wkt = lwgeom_to_wkt(geom, WKT_EXTENDED, 15, &sz); \
62  /* char *wkt = lwgeom_to_hexwkb(geom, WKT_EXTENDED, &sz); */ \
63  LWDEBUGF(level, msg ": %s", wkt); \
64  lwfree(wkt); \
65  } while (0);
66 
67 /* Display a formatted notice and a WKT representation of a geometry
68  * at the given debug level */
69 #define LWDEBUGGF(level, geom, fmt, ...) \
70  if (POSTGIS_DEBUG_LEVEL >= level) \
71  do { \
72  size_t sz; \
73  char *wkt = lwgeom_to_wkt(geom, WKT_EXTENDED, 15, &sz); \
74  /* char *wkt = lwgeom_to_hexwkb(geom, WKT_EXTENDED, &sz); */ \
75  LWDEBUGF(level, fmt ": %s", __VA_ARGS__, wkt); \
76  lwfree(wkt); \
77  } while (0);
78 
79 #else /* POSTGIS_DEBUG_LEVEL <= 0 */
80 
81 /* Empty prototype that can be optimised away by the compiler
82  * for non-debug builds */
83 #define LWDEBUG(level, msg) \
84  ((void) 0)
85 
86 /* Empty prototype that can be optimised away by the compiler
87  * for non-debug builds */
88 #define LWDEBUGF(level, msg, ...) \
89  ((void) 0)
90 
91 /* Empty prototype that can be optimised away by the compiler
92  * for non-debug builds */
93 #define LWDEBUGG(level, geom, msg) \
94  ((void) 0)
95 
96 /* Empty prototype that can be optimised away by the compiler
97  * for non-debug builds */
98 #define LWDEBUGGF(level, geom, fmt, ...) \
99  ((void) 0)
100 
101 #endif /* POSTGIS_DEBUG_LEVEL <= 0 */
102 
111 void lwnotice(const char *fmt, ...);
112 
121 void lwerror(const char *fmt, ...);
122 
130 void lwdebug(int level, const char *fmt, ...);
131 
132 
133 
134 #endif /* LWGEOM_LOG_H */
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:177
def fmt
Definition: pixval.py:92
void lwdebug(int level, const char *fmt,...)
Write a debug message out.
Definition: lwutil.c:203
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190