netcdf-c/include/nc_logging.h
Dennis Heimbigner d85bb6fe20 The big change for this commit is complete the
disengagement of enable-netcdf4 from enable-hdf5.
That is, with the advent of nczarr, it is possible
to turn off hdf5 but still need netcdf-4 enabled
because nczarr uses libsrc4, but not libhdf5.
This change involves a bunch of things:
1. Modify configure.ac and CMakelist to make enable_hdf5
   control if hdf5 support is provided. For back compatibility,
   disable-netcdf4 is treated as disable-hdf5. But internally,
   netcdf4 support is controlled only by the enabling of formats
   that require it.
2. In support of #1, modify .travis.yml to use enable/disable-hdf5
   instead of enable/disable-netcdf4.
3. test_common.in is modified to track selected features,
   including enable-hdf5 and enable-s3-tests. This is used in
   selected tests that mix netcdf-3 and netcdf4 tests.
4. The conflation of USE_HDF5 and USE_NETCDF4 is common in
   code, tests, and build files, so all of those had to be weeded out.
5. It turns out that some of the NC4_dim functions really are HDF5 specific,
   but are not treated as such. So they are moved from nc4dim.c to
   hdf5dim.c or hdf5dispatch.c
6. Some generic functions in libhdf5 can be (and were) moved to libsrc4.
2020-08-12 15:42:50 -06:00

72 lines
1.6 KiB
C

/* Copyright 2018, University Corporation for Atmospheric Research. See
COPYRIGHT file for copying and redistribution conditions. */
/**
* @file @internal This file is part of netcdf-4, a netCDF-like
* interface for HDF5, or a HDF5 backend for netCDF, depending on your
* point of view.
*
* This file contains macros and prototypes relating to logging.
*
* @author Ed Hartnett
*/
#ifndef _NCLOGGING_
#define _NCLOGGING_
#include <stdlib.h>
#include <assert.h>
#ifdef LOGGING
/* To log something... */
void nc_log(int severity, const char *fmt, ...);
void nc_log_hdf5(void);
#define LOG(e) nc_log e
/* To log based on error code, and set retval. */
#define BAIL2(e) \
do { \
retval = e; \
LOG((0, "file %s, line %d.\n%s", __FILE__, __LINE__, nc_strerror(e))); \
nc_log_hdf5(); \
} while (0)
/* To set retval and jump to exit, without logging error message. */
#define BAIL_QUIET(e) \
do { \
retval = e; \
goto exit; \
} while (0)
#else /* LOGGING */
/* These definitions will be used unless LOGGING is defined. */
#define LOG(e)
#define BAIL2(e) \
do { \
retval = e; \
} while (0)
#define BAIL_QUIET BAIL
#ifdef USE_NETCDF4
#ifndef 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 /* LOGGING */
/* To log an error message (if 'LOGGING' is defined), set retval, and jump to exit. */
#define BAIL(e) \
do { \
BAIL2(e); \
goto exit; \
} while (0)
#endif /* _NCLOGGING_ */