$NetBSD: patch-src_zm_logger_cpp,v 1.5 2018/07/14 15:03:57 gdt Exp $

Use libgen.h for basename.

Kludge around const for basename.

If the system has syscall() but not SYS_gettid [E.g. NetBSD], don't attempt
to use SYS_gettid.

Fix time types (sizes).

--- src/zm_logger.cpp.orig	2018-12-08 14:22:36.000000000 +0000
+++ src/zm_logger.cpp
@@ -464,12 +464,12 @@ void Logger::logPrint( bool hex, const c
 
     subtractTime( &timeVal, &logStart );
 
-    snprintf( timeString, sizeof(timeString), "%ld.%03ld", timeVal.tv_sec, timeVal.tv_usec/1000 );
+    snprintf( timeString, sizeof(timeString), "%jd.%03ld", (intmax_t) timeVal.tv_sec, timeVal.tv_usec/1000 );
   } else {
 #endif
     char *timePtr = timeString;
     timePtr += strftime(timePtr, sizeof(timeString), "%x %H:%M:%S", localtime(&timeVal.tv_sec));
-    snprintf(timePtr, sizeof(timeString)-(timePtr-timeString), ".%06ld", timeVal.tv_usec);
+    snprintf(timePtr, sizeof(timeString)-(timePtr-timeString), ".%06jd", (intmax_t) timeVal.tv_usec);
 #if 0
   }
 #endif
@@ -548,8 +548,8 @@ void Logger::logPrint( bool hex, const c
           "INSERT INTO Logs "
           "( TimeKey, Component, ServerId, Pid, Level, Code, Message, File, Line )"
          " VALUES "
-         "( %ld.%06ld, '%s', %d, %d, %d, '%s', '%s', '%s', %d )",
-         timeVal.tv_sec, timeVal.tv_usec, mId.c_str(), staticConfig.SERVER_ID, tid, level, classString, escapedString, file, line
+         "( %jd.%06jd, '%s', %d, %d, %d, '%s', '%s', '%s', %d )",
+         (intmax_t) timeVal.tv_sec, (intmax_t) timeVal.tv_usec, mId.c_str(), staticConfig.SERVER_ID, tid, level, classString, escapedString, file, line
          );
       if ( mysql_query(&dbconn, sql) ) {
         Level tempDatabaseLevel = mDatabaseLevel;
