$NetBSD: patch-src_zm_logger_cpp,v 1.8 2024/12/01 13:49:48 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	2023-02-23 21:44:01.000000000 +0000
+++ src/zm_logger.cpp
@@ -439,13 +439,13 @@ void Logger::logPrint(bool hex, const ch
 
     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, (long) timeVal.tv_usec/1000 );
   } else {
 #endif
     char *timePtr = timeString;
     tm now_tm = {};
     timePtr += strftime(timePtr, sizeof(timeString), "%x %H:%M:%S", localtime_r(&timeVal.tv_sec, &now_tm));
-    snprintf(timePtr, sizeof(timeString)-(timePtr-timeString), ".%06ld", timeVal.tv_usec);
+    snprintf(timePtr, sizeof(timeString)-(timePtr-timeString), ".%06ld", (long) timeVal.tv_usec);
 #if 0
   }
 #endif
@@ -534,8 +534,8 @@ void Logger::logPrint(bool hex, const ch
           "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.c_str(), file, line
+          "( %jd.%06ld, '%s', %d, %d, %d, '%s', '%s', '%s', %d )",
+          (intmax_t) timeVal.tv_sec, (long) timeVal.tv_usec, mId.c_str(), staticConfig.SERVER_ID, tid, level, classString, escapedString.c_str(), file, line
           );
       dbQueue.push(std::move(sql_string));
     } else {
