diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-04-21 12:23:07 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-21 12:23:07 -0700 |
| commit | 56507ab5c4db009be5251bde832f594fe5ed3d5e (patch) | |
| tree | c70e7d669c3548a5c58ab27c0fc6118a96580863 /src/testing/nuts.h | |
| parent | 3593eba5272bf627b99a2521b3f025141a49bcad (diff) | |
| download | nng-56507ab5c4db009be5251bde832f594fe5ed3d5e.tar.gz nng-56507ab5c4db009be5251bde832f594fe5ed3d5e.tar.bz2 nng-56507ab5c4db009be5251bde832f594fe5ed3d5e.zip | |
Logging improvements (#1816)
* Add nng_str_sockaddr to get string representation of socket address.
* Added nng_log_get_level() is meant to allow users to obtain the
current level and avoid some possibly expensive operations just
to collect debugging information when debugging is not in effect.
We use a custom logger for NUTS, and this fits within the NUTS
test framework well, so that if -v is supplied we get more content.
All tests now get this by default.
Diffstat (limited to 'src/testing/nuts.h')
| -rw-r--r-- | src/testing/nuts.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/testing/nuts.h b/src/testing/nuts.h index f24f7136..da0f525f 100644 --- a/src/testing/nuts.h +++ b/src/testing/nuts.h @@ -17,9 +17,18 @@ #ifndef NNG_TESTING_NUTS_H #define NNG_TESTING_NUTS_H +#include <nng/nng.h> +extern void nuts_logger( + nng_log_level, nng_log_facility, const char *, const char *); + // Call nng_fini during test finalization -- this avoids leak warnings. extern void nng_fini(void); #define TEST_FINI nng_fini() +#define TEST_INIT \ + do { \ + nng_log_set_logger(nuts_logger); \ + nng_log_set_level(NNG_LOG_DEBUG); \ + } while (0) #include "acutest.h" #include <stdbool.h> @@ -27,7 +36,6 @@ extern void nng_fini(void); #include <string.h> // The following headers are provided for test code convenience. -#include <nng/nng.h> #include <nng/protocol/bus0/bus.h> #include <nng/protocol/pair0/pair.h> #include <nng/protocol/pair1/pair.h> @@ -210,6 +218,11 @@ extern const char *nuts_garbled_crt; nng_log_set_level(level); \ } while (0) +#define NUTS_LOGGING() \ + do { \ + nng_log_set_logger(nuts_logger); \ + nng_log_set_level(NNG_LOG_DEBUG); \ + } while (0) #ifdef __cplusplus }; #endif |
