Browse Source

better attempt at refactoring the logger.

Matt Coburn 5 years ago
parent
commit
192cbafd66
2 changed files with 8 additions and 3 deletions
  1. 1 1
      Build-iOS/Build-iOS.command
  2. 7 2
      Source/Native/custom/enet_logging.h

+ 1 - 1
Build-iOS/Build-iOS.command

@@ -46,7 +46,7 @@ then
 		DEBUG_STATUS=1
 	fi
 	
-	cmake $CODE_ROOT -B$CODE_ROOT/build -G Xcode -DCMAKE_TOOLCHAIN_FILE=$UPPER_ROOT/MobileToolchains/ios.toolchain.cmake -DPLATFORM=OS -DENABLE_ARC=0 -DENABLE_VISIBILITY=0 -DENET_ON_APPLE_IOS=1 -DENET_DEBUG=$DEBUG_STATUS -DENET_STATIC=1 -DENET_SHARED=0 -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=NO	
+	cmake $CODE_ROOT -B$CODE_ROOT/build -G Xcode -DCMAKE_TOOLCHAIN_FILE=$UPPER_ROOT/MobileToolchains/ios.toolchain.cmake -DPLATFORM=OS -DENABLE_ARC=0 -DENABLE_VISIBILITY=0 -DENET_DEBUG=$DEBUG_STATUS -DENET_STATIC=1 -DENET_SHARED=0 -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=NO	
 	
 	if [ $? -eq 0 ] 
 	then

+ 7 - 2
Source/Native/custom/enet_logging.h

@@ -4,6 +4,10 @@
 #include <stdarg.h>
 #include <stdio.h>
 
+#if __APPLE__
+	#include <TargetConditionals.h>
+#endif
+
 // TODO: Make better filenames; ie. enet_log.pid.txt
 #define ENET_LOG_FILE "enet_log.txt"
 
@@ -37,7 +41,7 @@ static inline void enet_log(enum enet_log_type type, const char *func, int line,
 
 	time_buf[strftime(time_buf, sizeof(time_buf), "%Y-%m-%d %H:%M:%S", local_time)] = '\0';
 
-#if ENET_ON_APPLE_IOS
+#if __APPLE__ && TARGET_OS_IPHONE
 	// https://github.com/SoftwareGuy/ENet-CSharp/issues/15
 	// iOS Debugging - File Access Permission (#blameApple)
 	// Can't write to files without the file permission... so don't do that if we're on Apple.
@@ -55,11 +59,12 @@ static inline void enet_log(enum enet_log_type type, const char *func, int line,
 	if (!enet_log_fp) enet_log_fp = fopen(ENET_LOG_FILE, "a");
 	if (!enet_log_fp) return;
 
-	fprintf(enet_log_fp, "%s [%s] [%s:%d] \n", time_buf, enet_log_type_names[type], func, line);
+	fprintf(enet_log_fp, "%s [%s] [%s:%d] ", time_buf, enet_log_type_names[type], func, line);
 	va_start(args, fmt);
 	vfprintf(enet_log_fp, fmt, args);
 	va_end(args);
 
+	fprintf(enet_log_fp, "\n");
 	fflush(enet_log_fp);
 #endif