aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-12-17 19:17:44 -0800
committerGarrett D'Amore <garrett@damore.org>2024-12-17 19:17:44 -0800
commitd83f5aea789f896c90208567a9e56599a439e90a (patch)
tree012f75df4dc6b71078710cfbcb9230d5b3cb3e6e /src
parent7c51e7b1807fb2daa214e5bc99799a1327a666c8 (diff)
downloadnng-d83f5aea789f896c90208567a9e56599a439e90a.tar.gz
nng-d83f5aea789f896c90208567a9e56599a439e90a.tar.bz2
nng-d83f5aea789f896c90208567a9e56599a439e90a.zip
syslog: test for existence
Some POSIX emulations may lack a reasonable syslog function (although syslog is required per the Open Group). For now we just check for it, and don't use it if it isn't present.
Diffstat (limited to 'src')
-rw-r--r--src/core/CMakeLists.txt1
-rw-r--r--src/core/log.c6
2 files changed, 4 insertions, 3 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 81f8d1ee..ba8b1ca8 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -15,6 +15,7 @@ nng_check_sym(strnlen string.h NNG_HAVE_STRNLEN)
nng_check_sym(strcasecmp string.h NNG_HAVE_STRCASECMP)
nng_check_sym(strncasecmp string.h NNG_HAVE_STRNCASECMP)
nng_check_sym(localtime_r time.h NNG_HAVE_LOCALTIME_R)
+nng_check_sym(syslog syslog.h NNG_HAVE_SYSLOG)
nng_sources(
defs.h
diff --git a/src/core/log.c b/src/core/log.c
index 0084b06e..bbdac063 100644
--- a/src/core/log.c
+++ b/src/core/log.c
@@ -16,7 +16,7 @@
#ifdef NNG_PLATFORM_WINDOWS
#include <io.h>
#endif
-#ifdef NNG_PLATFORM_POSIX
+#ifdef NNG_HAVE_SYSLOG
#include <syslog.h>
#include <unistd.h>
#endif
@@ -90,7 +90,7 @@ stderr_logger(nng_log_level level, nng_log_facility facility,
#ifdef NNG_PLATFORM_WINDOWS
// NB: We are blithely assuming the user has a modern console.
colors = _isatty(_fileno(stderr));
-#elif defined(NNG_PLATFORM_POSIX)
+#elif defined(NNG_HAVE_SYSLOG)
// Only assuming we can use colors (and attributes) if stderr is a tty
// and $TERM is reasonable. We assume the terminal supports ECMA-48,
// which is true on every reasonable system these days.
@@ -186,7 +186,7 @@ void
nng_system_logger(nng_log_level level, nng_log_facility facility,
const char *msgid, const char *msg)
{
-#ifdef NNG_PLATFORM_POSIX
+#ifdef NNG_HAVE_SYSLOG
int pri;
switch (level) {
case NNG_LOG_ERR: