summaryrefslogtreecommitdiff
path: root/hugin_syslog.c
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2013-02-22 14:37:29 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2013-02-22 14:37:29 +0100
commit17765f69c51a9bec4681c129b8cbc76e7374cce4 (patch)
tree43b4ba111b91eabf263dd6866a2b888a9b3ed42f /hugin_syslog.c
parent7804c0a659ee8cac40bfcce68656a9faf0cabd93 (diff)
Use local syslog (linux only) if no host is supplied.
Diffstat (limited to 'hugin_syslog.c')
-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);