aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/source/development/reference/datatypes.rst50
-rw-r--r--docs/source/development/reference/functions.rst28
-rw-r--r--src/pj_internal.c9
-rw-r--r--src/proj.h15
-rw-r--r--src/proj_internal.h16
5 files changed, 94 insertions, 24 deletions
diff --git a/docs/source/development/reference/datatypes.rst b/docs/source/development/reference/datatypes.rst
index 8966923a..2a335a15 100644
--- a/docs/source/development/reference/datatypes.rst
+++ b/docs/source/development/reference/datatypes.rst
@@ -744,3 +744,53 @@ Info structures
.. c:member:: char PJ_INIT_INFO.lastupdate
Date of last update of the init-file.
+
+
+Logging
+-------------------------------------------------------------------------------
+
+.. c:type:: PJ_LOG_LEVEL
+
+ Enum of logging levels in PROJ. Used to set the logging level in PROJ.
+ Usually using :c:func:`proj_log_level`.
+
+ .. c:member:: PJ_LOG_NONE
+
+ Don't log anything.
+
+ .. c:member:: PJ_LOG_ERROR
+
+ Log only errors.
+
+ .. c:member:: PJ_LOG_DEBUG
+
+ Log errors and additional debug information.
+
+ .. c:member:: PJ_LOG_TRACE
+
+ Highest logging level. Log everything including very detailed debug
+ information.
+
+ .. c:member:: PJ_LOG_TELL
+
+ Special logging level that when used in :c:func:`proj_log_level`
+ will return the current logging level set in PROJ.
+
+ .. versionadded:: 5.1.0
+
+.. c:type:: PJ_LOG_FUNC
+
+ Function prototype for the logging function used by PROJ.
+ Defined as
+
+ .. code-block:: C
+
+ typedef void (*PJ_LOG_FUNCTION)(void *, int, const char *);
+
+ where the :c:type:`void` pointer references a data structure used by the
+ calling application, the :c:type:`int` is used to set the logging level
+ and the :c:type:`const char` pointer is the string that will be logged
+ by the function.
+
+
+ .. versionadded:: 5.1.0
diff --git a/docs/source/development/reference/functions.rst b/docs/source/development/reference/functions.rst
index 3d141ae2..52f801e5 100644
--- a/docs/source/development/reference/functions.rst
+++ b/docs/source/development/reference/functions.rst
@@ -276,6 +276,34 @@ Change the error-state of :c:data:`P` to `err`.
.. note:: Available from version 5.1.0.
+
+Logging
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+.. c:function:: PJ_LOG_LEVEL proj_log_level (PJ_CONTEXT *ctx, PJ_LOG_LEVEL level)
+
+ Get and set logging level for a given context. Changes the log level to
+ :c:data:`level` and returns the previous logging level. If called with
+ :c:data:`level` set to :c:type:`PJ_LOG_TELL` the function returns the current
+ logging level without changing it.
+
+ :param PJ_CONTEXT* ctx: Threading context.
+ :param PJ_LOG_LEVEL level: New logging level.
+
+ :returns: :c:type:`PJ_LOG_LEVEL`
+
+ .. versionadded:: 5.1.0
+
+.. c:function:: void proj_log_func (PJ_CONTEXT *ctx, void *app_data, PJ_LOG_FUNCTION logf)
+
+ Override the internal log function of PROJ.
+
+ :param PJ_CONTEXT* ctx: Threading context.
+ :param void* app_data: Pointer to data structure used by the calling application.
+ :param PJ_LOG_FUNCTION logf: Log function that overrides the PROJ log function.
+
+ .. versionadded:: 5.1.0
+
Info functions
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
diff --git a/src/pj_internal.c b/src/pj_internal.c
index 4da47051..891e0b9f 100644
--- a/src/pj_internal.c
+++ b/src/pj_internal.c
@@ -364,11 +364,6 @@ to that context.
return;
}
-
-
-
-
-
/* logging */
/* pj_vlog resides in pj_log.c and relates to pj_log as vsprintf relates to sprintf */
@@ -376,11 +371,11 @@ void pj_vlog( projCtx ctx, int level, const char *fmt, va_list args );
/***************************************************************************************/
-enum proj_log_level proj_log_level (PJ_CONTEXT *ctx, enum proj_log_level log_level) {
+PJ_LOG_LEVEL proj_log_level (PJ_CONTEXT *ctx, PJ_LOG_LEVEL log_level) {
/****************************************************************************************
Set logging level 0-3. Higher number means more debug info. 0 turns it off
****************************************************************************************/
- enum proj_log_level previous;
+ PJ_LOG_LEVEL previous;
if (0==ctx)
ctx = pj_get_default_ctx();
if (0==ctx)
diff --git a/src/proj.h b/src/proj.h
index 7bc9b10e..3d64ed1a 100644
--- a/src/proj.h
+++ b/src/proj.h
@@ -268,6 +268,17 @@ struct PJ_INIT_INFO {
char lastupdate[16]; /* Date of last update in YYYY-MM-DD format */
};
+typedef enum PJ_LOG_LEVEL {
+ PJ_LOG_NONE = 0,
+ PJ_LOG_ERROR = 1,
+ PJ_LOG_DEBUG = 2,
+ PJ_LOG_TRACE = 3,
+ PJ_LOG_TELL = 4,
+ PJ_LOG_DEBUG_MAJOR = 2, /* for proj_api.h compatibility */
+ PJ_LOG_DEBUG_MINOR = 3 /* for proj_api.h compatibility */
+} PJ_LOG_LEVEL;
+
+typedef void (*PJ_LOG_FUNCTION)(void *, int, const char *);
/* The context type - properly namespaced synonym for projCtx */
@@ -342,7 +353,6 @@ double proj_xyz_dist (PJ_COORD a, PJ_COORD b);
PJ_COORD proj_geod (const PJ *P, PJ_COORD a, PJ_COORD b);
-
/* Set or read error level */
int proj_context_errno (PJ_CONTEXT *ctx);
int proj_errno (const PJ *P);
@@ -351,6 +361,9 @@ int proj_errno_reset (const PJ *P);
int proj_errno_restore (const PJ *P, int err);
const char* proj_errno_string (int err);
+PJ_LOG_LEVEL proj_log_level (PJ_CONTEXT *ctx, PJ_LOG_LEVEL level);
+void proj_log_func (PJ_CONTEXT *ctx, void *app_data, PJ_LOG_FUNCTION logf);
+
/* Scaling and angular distortion factors */
PJ_FACTORS proj_factors(PJ *P, PJ_COORD lp);
diff --git a/src/proj_internal.h b/src/proj_internal.h
index 3f6ccde0..1aca9201 100644
--- a/src/proj_internal.h
+++ b/src/proj_internal.h
@@ -97,25 +97,9 @@ double proj_vgrid_value(PJ *P, PJ_LP lp);
PJ_LP proj_hgrid_value(PJ *P, PJ_LP lp);
PJ_LP proj_hgrid_apply(PJ *P, PJ_LP lp, PJ_DIRECTION direction);
-/* High level functionality for handling thread contexts */
-enum proj_log_level {
- PJ_LOG_NONE = 0,
- PJ_LOG_ERROR = 1,
- PJ_LOG_DEBUG = 2,
- PJ_LOG_TRACE = 3,
- PJ_LOG_TELL = 4,
- PJ_LOG_DEBUG_MAJOR = 2, /* for proj_api.h compatibility */
- PJ_LOG_DEBUG_MINOR = 3 /* for proj_api.h compatibility */
-};
-
-/* Set logging level 0-3. Higher number means more debug info. 0 turns it off */
-enum proj_log_level proj_log_level (PJ_CONTEXT *ctx, enum proj_log_level log_level);
-typedef void (*PJ_LOG_FUNCTION)(void *, int, const char *);
-
void proj_log_error (PJ *P, const char *fmt, ...);
void proj_log_debug (PJ *P, const char *fmt, ...);
void proj_log_trace (PJ *P, const char *fmt, ...);
-void proj_log_func (PJ_CONTEXT *ctx, void *app_data, PJ_LOG_FUNCTION logf);
int pj_ellipsoid (PJ *);
void pj_inherit_ellipsoid_def (const PJ *src, PJ *dst);