From 17765f69c51a9bec4681c129b8cbc76e7374cce4 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 22 Feb 2013 14:37:29 +0100 Subject: Use local syslog (linux only) if no host is supplied. --- hugin_syslog.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hugin_syslog.c b/hugin_syslog.c index a2bd334..44c0f19 100644 --- a/hugin_syslog.c +++ b/hugin_syslog.c @@ -36,6 +36,7 @@ #include typedef SOCKET socket_t; #else +#include typedef int socket_t; #include #include @@ -52,6 +53,8 @@ typedef int socket_t; #warning hugin_syslog.c compiled but WITH_HUG_SYSLOG not defined #endif +#define DO_NOT_USE_REMOTE -2 + #define SYSLOG_MSGLEN 1024 #define SYSLOG_PRILEN 5 #define SYSLOG_TIMELEN 32 @@ -81,6 +84,9 @@ static void wsastartup() void hug_syslog_init(const char* host, int port) { + hug_syslog_sock = DO_NOT_USE_REMOTE; + + if(host == NULL) return; #ifdef WIN32 wsastartup(); @@ -211,6 +217,17 @@ void hug_syslog_createheader() { void hug_syslog_output(char* msg) { + if(hug_syslog_sock == DO_NOT_USE_REMOTE) { +#ifdef WIN32 + // TODO: We need to do something reasoanble on win32: + // See Windows Event Log Functions: + // http://msdn.microsoft.com/en-us/library/windows/desktop/aa385784.aspx +#else + syslog(LOG_DEBUG, "%s", msg); +#endif + return; + } + if(hug_syslog_sock < 0) return; const time_t rawtime = time(NULL); -- cgit v1.2.3