$OpenBSD: patch-common_ECLogger_cpp,v 1.10 2011/06/02 12:46:37 ajacoutot Exp $

Needs newlocale(3).

--- common/ECLogger.cpp.orig	Wed Apr 20 19:51:45 2011
+++ common/ECLogger.cpp	Thu Jun  2 11:07:53 2011
@@ -55,6 +55,10 @@
 #include <assert.h>
 #include "stringutil.h"
 
+#ifdef __OpenBSD__
+#include <signal.h>
+#endif
+
 #include "config.h"
 #if HAVE_SYSLOG_H
 #include <syslog.h>
@@ -78,15 +82,19 @@ ECLogger::ECLogger(int max_ll) {
 	max_loglevel = max_ll;
 	msgbuffer = new char[_LOG_BUFSIZE];
 	// get system locale for time, NULL is returned if locale was not found.
+#ifndef __OpenBSD__
 	timelocale = createlocale(LC_TIME, "");
+#endif
 	prefix = LP_NONE;
 	m_ulRef = 1;
 }
 
 ECLogger::~ECLogger() {
 	delete [] msgbuffer;
+#ifndef __OpenBSD__
 	if (timelocale)
 		freelocale(timelocale);
+#endif
 
 	pthread_mutex_destroy(&msgbuflock);
 }
@@ -101,9 +109,11 @@ char* ECLogger::MakeTimestamp() {
 
 	localtime_r(&now, &local);
 
+#ifndef __OpenBSD__
 	if (timelocale)
 		strftime_l(timestring, _LOG_TSSIZE, "%c", &local, timelocale);
 	else
+#endif
 		strftime(timestring, _LOG_TSSIZE, "%c", &local);
 
 	return timestring;
@@ -222,7 +232,7 @@ void ECLogger_File::DoPrefix() {
 	if (timestamp)
 		fnPrintf(log, "%s: ", MakeTimestamp());
 	if (prefix == LP_TID)
-		fnPrintf(log, "[0x%08x] ", (unsigned int)pthread_self());
+		fnPrintf(log, "[0x%08x] ", (uintptr_t)pthread_self());
 	else if (prefix == LP_PID)
 		fnPrintf(log, "[%5d] ", getpid());
 }
@@ -473,7 +483,7 @@ void ECLogger_Pipe::Log(int loglevel, const std::strin
 	off += 1;
 
 	if (prefix == LP_TID)
-		len = snprintf(msgbuffer+off, _LOG_BUFSIZE -off, "[0x%08x] ", (unsigned int)pthread_self());
+		len = snprintf(msgbuffer+off, _LOG_BUFSIZE -off, "[0x%08x] ", (uintptr_t)pthread_self());
 	else if (prefix == LP_PID)
 		len = snprintf(msgbuffer+off, _LOG_BUFSIZE -off, "[%5d] ", getpid());
 	off += len;
@@ -507,7 +517,7 @@ void ECLogger_Pipe::LogVA(int loglevel, const char *fo
 	off += 1;
 
 	if (prefix == LP_TID)
-		len = snprintf(msgbuffer+off, _LOG_BUFSIZE -off, "[0x%08x] ", (unsigned int)pthread_self());
+		len = snprintf(msgbuffer+off, _LOG_BUFSIZE -off, "[0x%08x] ", (uintptr_t)pthread_self());
 	else if (prefix == LP_PID)
 		len = snprintf(msgbuffer+off, _LOG_BUFSIZE -off, "[%5d] ", getpid());
 	off += len;
