File: nc_logging.h

package info (click to toggle)
netcdf-parallel 1%3A4.7.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 105,352 kB
  • sloc: ansic: 229,114; sh: 11,180; yacc: 2,561; makefile: 1,390; lex: 1,173; xml: 173; awk: 2
file content (71 lines) | stat: -rw-r--r-- 1,590 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* 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_NETCDF_4
#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_ */