Skip to content

Commit

Permalink
syslog: test for existence
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gdamore committed Dec 18, 2024
1 parent 7c51e7b commit d83f5ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/core/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit d83f5ae

Please sign in to comment.