Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

* FIX [log] fix incompatible UNIX DOmain socket logging in windows #1006

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions src/supplemental/nanolib/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
#include "nng/supplemental/nanolib/file.h"
#include "core/nng_impl.h"
#include "core/defs.h"
#include <sys/socket.h>
#include <sys/un.h>
#include <errno.h>

#define INDEX_FILE_NAME ".idx"

#define MAX_CALLBACKS 10

#if NNG_PLATFORM_WINDOWS
#define nano_localtime(t, pTm) localtime_s(pTm, t)
#else
#if defined(SUPP_SYSLOG)
#include <syslog.h>
static int syslog_socket = -1;
Expand All @@ -17,15 +18,12 @@ static const char *log_ident = NULL;
static int log_option = 0;
static int log_facility = LOG_USER;
#endif

#define MAX_CALLBACKS 10

#if NNG_PLATFORM_WINDOWS
#define nano_localtime(t, pTm) localtime_s(pTm, t)
#else
#include <sys/types.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <errno.h>
#define nano_localtime(t, pTm) localtime_r(t, pTm)
#endif

Expand Down Expand Up @@ -145,7 +143,7 @@ log_add_syslog(const char *log_name, uint8_t level, void *mtx)
openlog(log_name, LOG_PID, LOG_DAEMON | convert_syslog_level(level));
log_add_callback(syslog_callback, NULL, level, mtx, NULL);
}

#ifdef NNG_PLATFORM_WINDOWS
void
uds_openlog(const char *uds_path, const char *ident, int option, int facility)
{
Expand Down Expand Up @@ -226,6 +224,7 @@ log_add_uds(const char *uds_path, const char *log_name, uint8_t level, void *mtx
uds_openlog(uds_path, log_name, LOG_PID, LOG_DAEMON | convert_syslog_level(level));
log_add_callback(uds_syslog_callback, NULL, level, mtx, NULL);
}
#endif

#else

Expand Down
Loading