Cleanup handling of NETCDF_ENABLE_SET_LOG_LEVEL and NETCDF_ENABLE_SET_LOG_LEVEL_FUNC

The NETCDF_ENABLE_SET_LOG_LEVEL_FUNC option is apparently not used, but
is effectively used to set NETCDF_ENABLE_SET_LOG_LEVEL.
This is not clear from the build files CMakeLists.txt and configure.ac.
So this PR cleanups the code to make it more clear what is going on.
This commit is contained in:
Dennis Heimbigner 2024-05-24 16:48:04 -06:00
parent 09a5fa333d
commit fd637fd460
5 changed files with 30 additions and 25 deletions

View File

@ -532,20 +532,20 @@ else()
set(NETCDF_ENABLE_HDF4 OFF) set(NETCDF_ENABLE_HDF4 OFF)
endif() endif()
# Option Logging, only valid for netcdf4. # Option Logging, only valid for netcdf4 dispatchers.
option(NETCDF_ENABLE_LOGGING "Enable Logging." OFF) option(NETCDF_ENABLE_LOGGING "Enable Logging." OFF)
if(NOT NETCDF_ENABLE_NETCDF4) if(NOT NETCDF_ENABLE_NETCDF4)
set(NETCDF_ENABLE_LOGGING OFF) set(NETCDF_ENABLE_LOGGING OFF)
endif() endif()
if(NETCDF_ENABLE_LOGGING) if(NETCDF_ENABLE_LOGGING)
target_compile_definitions(netcdf PRIVATE LOGGING NETCDF_ENABLE_SET_LOG_LEVEL) set(LOGGING ON CACHE BOOL "") # Alias
set(LOGGING ON)
set(NETCDF_ENABLE_SET_LOG_LEVEL ON)
endif() endif()
option(NETCDF_ENABLE_SET_LOG_LEVEL_FUNC "Enable definition of nc_set_log_level()." ON) option(NETCDF_ENABLE_SET_LOG_LEVEL_FUNC "Enable definition of nc_set_log_level()." ON)
if(NETCDF_ENABLE_NETCDF4 AND NOT NETCDF_ENABLE_LOGGING AND NETCDF_ENABLE_SET_LOG_LEVEL_FUNC) if(LOGGING AND NETCDF_ENABLE_SET_LOG_LEVEL_FUNC)
target_compile_definitions(netcdf PRIVATE -DNETCDF_ENABLE_SET_LOG_LEVEL) set(NETCDF_ENABLE_SET_LOG_LEVEL ON CACHE BOOL "")
set(NETCDF_ENABLE_SET_LOG_LEVEL ON) else()
set(NETCDF_ENABLE_SET_LOG_LEVEL OFF CACHE BOOL "")
endif() endif()
# Option to allow for strict null file padding. # Option to allow for strict null file padding.

View File

@ -475,10 +475,7 @@ with zip */
#cmakedefine LOGGING 1 #cmakedefine LOGGING 1
/* If true, define nc_set_log_level. */ /* If true, define nc_set_log_level. */
#cmakedefine ENABLE_SET_LOG_LEVEL 1 #cmakedefine NETCDF_ENABLE_SET_LOG_LEVEL 1
/* If true, define nc_set_log_level_func */
#cmakedefine NETCDF_ENABLE_SET_LOG_LEVEL_FUNC 1
/* min blocksize for posixio. */ /* min blocksize for posixio. */
#cmakedefine NCIO_MINBLOCKSIZE ${NCIO_MINBLOCKSIZE} #cmakedefine NCIO_MINBLOCKSIZE ${NCIO_MINBLOCKSIZE}

View File

@ -451,16 +451,26 @@ AC_ARG_ENABLE([logging],
test "x$enable_logging" = xyes || enable_logging=no test "x$enable_logging" = xyes || enable_logging=no
AC_MSG_RESULT([$enable_logging]) AC_MSG_RESULT([$enable_logging])
# Does the user want to turn off nc_set_log_level() function? (It will # Does the user want to disable the nc_set_log_level() function? (It will
# always be defined if --enable-logging is used.) # always be defined (possibly as a no-op) if --enable-logging is used.)
AC_MSG_CHECKING([whether nc_set_log_level() function is included (will do nothing unless enable-logging is also used)]) AC_MSG_CHECKING([whether nc_set_log_level() function is enabled (will do nothing unless enable-logging is also used)])
AC_ARG_ENABLE([set_log_level_func], [AS_HELP_STRING([--disable-set-log-level-func], AC_ARG_ENABLE([set-log-level-func], [AS_HELP_STRING([--disable-set-log-level-func],
[disable the nc_set_log_level function])]) [disable the nc_set_log_level function])])
test "x$enable_set_log_level_func" = xno -a "x$enable_logging" = xno || enable_set_log_level_func=yes test "x$enable_set_log_level_func" = xno || enable_set_log_level_func=yes
if test "x$enable_set_log_level_func" = xyes -a "x$enable_hdf5" = xyes; then if test "x$enable_logging" = xno; then
AC_DEFINE([ENABLE_SET_LOG_LEVEL], 1, [If true, define nc_set_log_level.]) enable_set_log_level_func=no
fi
# alias to enable_set_log_level
if test "x$enable_set_log_level_func" = xyes; then
enable_set_log_level=yes
else
enable_set_log_level=no
fi
AC_MSG_RESULT($enable_set_log_level)
if test "x$enable_set_log_level" = xyes ; then
AC_DEFINE([NETCDF_ENABLE_SET_LOG_LEVEL], 1, [If true, enable nc_set_log_level function.])
fi fi
AC_MSG_RESULT($enable_set_log_level_func)
# CURLOPT_USERNAME is not defined until curl version 7.19.1 # CURLOPT_USERNAME is not defined until curl version 7.19.1
# CURLOPT_PASSWORD is not defined until curl version 7.19.1 # CURLOPT_PASSWORD is not defined until curl version 7.19.1

View File

@ -52,12 +52,10 @@ void nc_log(int severity, const char *fmt, ...);
#define BAIL_QUIET BAIL #define BAIL_QUIET BAIL
#ifdef USE_NETCDF4 #ifndef NETCDF_ENABLE_SET_LOG_LEVEL
#ifndef ENABLE_SET_LOG_LEVEL
/* Define away any calls to nc_set_log_level(), if its not enabled. */ /* Define away any calls to nc_set_log_level(), if its not enabled. */
#define nc_set_log_level(e) #define nc_set_log_level(e)
#endif /* ENABLE_SET_LOG_LEVEL */ #endif /* NETCDF_ENABLE_SET_LOG_LEVEL */
#endif
#endif /* LOGGING */ #endif /* LOGGING */

View File

@ -1711,7 +1711,7 @@ nc4_normalize_name(const char *name, char *norm_name)
return NC_NOERR; return NC_NOERR;
} }
#ifdef ENABLE_SET_LOG_LEVEL #ifdef NETCDF_ENABLE_SET_LOG_LEVEL
/** /**
* Initialize parallel I/O logging. For parallel I/O builds, open log * Initialize parallel I/O logging. For parallel I/O builds, open log
@ -1812,7 +1812,7 @@ nc_set_log_level(int new_level)
return NC_NOERR; return NC_NOERR;
} }
#endif /* ENABLE_SET_LOG_LEVEL */ #endif /* NETCDF_ENABLE_SET_LOG_LEVEL */
#if LOGGING #if LOGGING
#define MAX_NESTS 10 #define MAX_NESTS 10