aboutsummaryrefslogtreecommitdiff
path: root/src/pj_log.c
diff options
context:
space:
mode:
authorThomas Knudsen <busstoptaktik@users.noreply.github.com>2017-11-28 18:34:02 +1300
committerGitHub <noreply@github.com>2017-11-28 18:34:02 +1300
commit1c1d04b45d76366f54e104f9346879fd48bfde8e (patch)
tree28b9812adef7549676de8bd48f8c8aa44eb7adfb /src/pj_log.c
parent8c6fe8b673c9876e7301d4a890403a931540c17c (diff)
downloadPROJ-1c1d04b45d76366f54e104f9346879fd48bfde8e.tar.gz
PROJ-1c1d04b45d76366f54e104f9346879fd48bfde8e.zip
Enable selective debug printout through negative PROJ_DEBUG values (#689)
* Enable selective debug printout through negative PROJ_DEBUG values
Diffstat (limited to 'src/pj_log.c')
-rw-r--r--src/pj_log.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/pj_log.c b/src/pj_log.c
index 2525d050..bab5f078 100644
--- a/src/pj_log.c
+++ b/src/pj_log.c
@@ -51,8 +51,17 @@ void pj_vlog( projCtx ctx, int level, const char *fmt, va_list args )
{
char *msg_buf;
+ int debug_level = ctx->debug_level;
+ int shutup_unless_errno_set = debug_level < 0;
- if( level > ctx->debug_level )
+ /* For negative debug levels, we first start logging when errno is set */
+ if (ctx->last_errno==0 && shutup_unless_errno_set)
+ return;
+
+ if (debug_level < 0)
+ debug_level = -debug_level;
+
+ if( level > debug_level )
return;
msg_buf = (char *) malloc(100000);