Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup handling of NETCDF_ENABLE_SET_LOG_LEVEL and NETCDF_ENABLE_SET_LOG_LEVEL_FUNC #2931

Merged
merged 5 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -532,22 +532,15 @@ else()
set(NETCDF_ENABLE_HDF4 OFF)
endif()

# Option Logging, only valid for netcdf4.
# Option Logging, only valid for netcdf4 dispatchers.
option(NETCDF_ENABLE_LOGGING "Enable Logging." OFF)
if(NOT NETCDF_ENABLE_NETCDF4)
set(NETCDF_ENABLE_LOGGING OFF)
endif()
if(NETCDF_ENABLE_LOGGING)
target_compile_definitions(netcdf PRIVATE LOGGING NETCDF_ENABLE_SET_LOG_LEVEL)
set(LOGGING ON)
set(NETCDF_ENABLE_SET_LOG_LEVEL ON)
endif()
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)
target_compile_definitions(netcdf PRIVATE -DNETCDF_ENABLE_SET_LOG_LEVEL)
set(NETCDF_ENABLE_SET_LOG_LEVEL ON)
set(NETCDF_ENABLE_LOGGING OFF)
endif()

set(LOGGING ${NETCDF_ENABLE_LOGGING})
set(NETCDF_ENABLE_SET_LOG_LEVEL ${NETCDF_ENABLE_LOGGING})

# Option to allow for strict null file padding.
# See https://github.com/Unidata/netcdf-c/issues/657 for more information
option(NETCDF_ENABLE_STRICT_NULL_BYTE_HEADER_PADDING "Enable strict null byte header padding." OFF)
Expand Down
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ This file contains a high-level description of this package's evolution. Release

## 4.9.3 - TBD

* Cleanup the option code for NETCDF_ENABLE_SET_LOG_LEVEL\[_FUNC\] See [Github #2931](https://github.com/Unidata/netcdf-c/issues/2931) for more information.
* Fix duplicate definition when using aws-sdk-cpp. See [Github #2928](https://github.com/Unidata/netcdf-c/issues/2928) for more information.
* Cleanup various obsolete options and do some code refactoring. See [Github #2926](https://github.com/Unidata/netcdf-c/issues/2926) for more information.
* Convert the Zarr-related ENABLE_XXX options to NETCDF_ENABLE_XXX options (part of the cmake overhaul). See [Github #2923](https://github.com/Unidata/netcdf-c/issues/2923) for more information.
* Refactor macro `_FillValue` to `NC_FillValue` to avoid conflict with libc++ headers. See [Github #2858](https://github.com/Unidata/netcdf-c/issues/2858) for more information.
Expand Down
6 changes: 2 additions & 4 deletions config.h.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -475,10 +475,8 @@ with zip */
#cmakedefine LOGGING 1

/* If true, define nc_set_log_level. */
#cmakedefine ENABLE_SET_LOG_LEVEL 1

/* If true, define nc_set_log_level_func */
#cmakedefine NETCDF_ENABLE_SET_LOG_LEVEL_FUNC 1
#cmakedefine NETCDF_ENABLE_LOGGING 1
#cmakedefine NETCDF_ENABLE_SET_LOG_LEVEL 1

/* min blocksize for posixio. */
#cmakedefine NCIO_MINBLOCKSIZE ${NCIO_MINBLOCKSIZE}
Expand Down
18 changes: 8 additions & 10 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -450,17 +450,15 @@ AC_ARG_ENABLE([logging],
Ignored if netCDF-4 is not enabled.])])
test "x$enable_logging" = xyes || enable_logging=no
AC_MSG_RESULT([$enable_logging])

# Does the user want to turn off nc_set_log_level() function? (It will
# always be defined 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_ARG_ENABLE([set_log_level_func], [AS_HELP_STRING([--disable-set-log-level-func],
[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
if test "x$enable_set_log_level_func" = xyes -a "x$enable_hdf5" = xyes; then
AC_DEFINE([ENABLE_SET_LOG_LEVEL], 1, [If true, define nc_set_log_level.])
if test "x$enable_logging" = xyes; then
enable_set_log_level_func=yes
enable_set_log_level=yes
AC_DEFINE([NETCDF_ENABLE_SET_LOG_LEVEL], 1, [If true, enable nc_set_log_level function.])
else
enable_set_log_level_func=no
enable_set_log_level=no
fi
AC_MSG_RESULT($enable_set_log_level_func)


# CURLOPT_USERNAME is not defined until curl version 7.19.1
# CURLOPT_PASSWORD is not defined until curl version 7.19.1
Expand Down
6 changes: 2 additions & 4 deletions include/nc_logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@ void nc_log(int severity, const char *fmt, ...);

#define BAIL_QUIET BAIL

#ifdef USE_NETCDF4
#ifndef ENABLE_SET_LOG_LEVEL
#ifndef NETCDF_ENABLE_SET_LOG_LEVEL
/* Define away any calls to nc_set_log_level(), if its not enabled. */
#define nc_set_log_level(e)
#endif /* ENABLE_SET_LOG_LEVEL */
#endif
#endif /* NETCDF_ENABLE_SET_LOG_LEVEL */

#endif /* LOGGING */

Expand Down
4 changes: 2 additions & 2 deletions libsrc4/nc4internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1711,7 +1711,7 @@ nc4_normalize_name(const char *name, char *norm_name)
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
Expand Down Expand Up @@ -1812,7 +1812,7 @@ nc_set_log_level(int new_level)

return NC_NOERR;
}
#endif /* ENABLE_SET_LOG_LEVEL */
#endif /* NETCDF_ENABLE_SET_LOG_LEVEL */

#if LOGGING
#define MAX_NESTS 10
Expand Down
Loading