From 56507ab5c4db009be5251bde832f594fe5ed3d5e Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 21 Apr 2024 12:23:07 -0700 Subject: 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. --- src/core/pipe.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/core/pipe.c') diff --git a/src/core/pipe.c b/src/core/pipe.c index 10a1f35a..2fa8d017 100644 --- a/src/core/pipe.c +++ b/src/core/pipe.c @@ -1,5 +1,5 @@ // -// Copyright 2023 Staysail Systems, Inc. +// Copyright 2024 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // Copyright 2018 Devolutions // @@ -10,6 +10,7 @@ // #include "core/nng_impl.h" +#include "nng/nng.h" #include "sockimpl.h" #include @@ -409,3 +410,14 @@ nni_pipe_bump_error(nni_pipe *p, int err) nni_listener_bump_error(p->p_listener, err); } } + +char * +nni_pipe_peer_addr(nni_pipe *p, char buf[NNG_MAXADDRSTRLEN]) +{ + nng_sockaddr sa; + size_t sz = sizeof(sa); + sa.s_family = AF_UNSPEC; + nni_pipe_getopt(p, NNG_OPT_REMADDR, &sa, &sz, NNI_TYPE_SOCKADDR); + nng_str_sockaddr(&sa, buf, NNG_MAXADDRSTRLEN); + return (buf); +} -- cgit v1.2.3-70-g09d2