summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hugin_syslog.c17
1 files changed, 17 insertions, 0 deletions
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 <WinSock2.h>
typedef SOCKET socket_t;
#else
+#include <syslog.h>
typedef int socket_t;
#include <sys/socket.h>
#include <netinet/in.h>
@@ -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);