aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2021-07-22 23:04:37 +0200
committerEven Rouault <even.rouault@spatialys.com>2021-07-22 23:04:37 +0200
commit7e0bd99d231e849cd714221d0258ad05f409b494 (patch)
tree6ff5b40b876a13cb39d9efa1d70ab3545d0d96f6 /src
parent15639d8f45a6a37783f18cc61cd719b059b99c8d (diff)
downloadPROJ-7e0bd99d231e849cd714221d0258ad05f409b494.tar.gz
PROJ-7e0bd99d231e849cd714221d0258ad05f409b494.zip
Add pj_log_active() to determine if logging is active
Diffstat (limited to 'src')
-rw-r--r--src/log.cpp23
-rw-r--r--src/proj_internal.h1
-rw-r--r--src/proj_symbol_rename.h1
3 files changed, 19 insertions, 6 deletions
diff --git a/src/log.cpp b/src/log.cpp
index 4a2cc73d..9c96f53a 100644
--- a/src/log.cpp
+++ b/src/log.cpp
@@ -46,25 +46,36 @@ void pj_stderr_logger( void *app_data, int level, const char *msg )
}
/************************************************************************/
-/* pj_vlog() */
+/* pj_log_active() */
/************************************************************************/
-static
-void pj_vlog( PJ_CONTEXT *ctx, int level, const PJ* P, const char *fmt, va_list args )
-
+bool pj_log_active( PJ_CONTEXT *ctx, int level )
{
- char *msg_buf;
int debug_level = ctx->debug_level;
int shutup_unless_errno_set = debug_level < 0;
/* For negative debug levels, we first start logging when errno is set */
if (ctx->last_errno==0 && shutup_unless_errno_set)
- return;
+ return false;
if (debug_level < 0)
debug_level = -debug_level;
if( level > debug_level )
+ return false;
+ return true;
+}
+
+/************************************************************************/
+/* pj_vlog() */
+/************************************************************************/
+
+static
+void pj_vlog( PJ_CONTEXT *ctx, int level, const PJ* P, const char *fmt, va_list args )
+
+{
+ char *msg_buf;
+ if( !pj_log_active(ctx, level) )
return;
constexpr size_t BUF_SIZE = 100000;
diff --git a/src/proj_internal.h b/src/proj_internal.h
index 582bb3c5..6edb6aec 100644
--- a/src/proj_internal.h
+++ b/src/proj_internal.h
@@ -918,6 +918,7 @@ void pj_acquire_lock(void);
void pj_release_lock(void);
void pj_cleanup_lock(void);
+bool pj_log_active( PJ_CONTEXT *ctx, int level );
void pj_log( PJ_CONTEXT * ctx, int level, const char *fmt, ... );
void pj_stderr_logger( void *, int, const char * );
diff --git a/src/proj_symbol_rename.h b/src/proj_symbol_rename.h
index 7fbe4242..6f9e8ab6 100644
--- a/src/proj_symbol_rename.h
+++ b/src/proj_symbol_rename.h
@@ -71,6 +71,7 @@
#define pj_is_latlong internal_pj_is_latlong
#define pj_latlong_from_proj internal_pj_latlong_from_proj
#define pj_log internal_pj_log
+#define pj_log_active internal_pj_log_active
#define pj_malloc internal_pj_malloc
#define pj_open_lib internal_pj_open_lib
#define pj_pr_list internal_pj_pr_list