|
|
@@ -40,30 +40,39 @@ static inline void enet_log_to_file(enum enet_log_type type, const char *func, i
|
|
|
// iOS Debugging - Sandboxed logging can't write file. This might extend even into Android!
|
|
|
// Can't write to files without the file permission... so don't do that if we're on Apple.
|
|
|
// https://github.com/SoftwareGuy/ENet-CSharp/issues/15
|
|
|
+
|
|
|
+ // Write the initial debug text to stdout.
|
|
|
printf("%s [%s] [%s:%d] ", time_buf, enet_log_type_names[type], func, line);
|
|
|
|
|
|
+ // Write our arguments and related stuff to stdout, then newline it.
|
|
|
va_start(args, fmt);
|
|
|
vprintf(fmt, args);
|
|
|
va_end(args);
|
|
|
printf("\n");
|
|
|
+
|
|
|
// -- End logging for Android and Apple iOS -- //
|
|
|
#else
|
|
|
- // Open the log file
|
|
|
+ // Open the log file, and if we can't, then short-circuit.
|
|
|
if (!enet_log_fp) enet_log_fp = fopen(ENET_LOG_FILE, "a");
|
|
|
if (!enet_log_fp) return;
|
|
|
|
|
|
+ // Write the initial debug text to buffer.
|
|
|
fprintf(enet_log_fp, "%s [%s] [%s:%d] ", time_buf, enet_log_type_names[type], func, line);
|
|
|
+
|
|
|
+ // Write our arguments and related stuff to buffer.
|
|
|
va_start(args, fmt);
|
|
|
vfprintf(enet_log_fp, fmt, args);
|
|
|
va_end(args);
|
|
|
|
|
|
+ // Write new line marker, then flush and wrap up.
|
|
|
fprintf(enet_log_fp, "\n");
|
|
|
fflush(enet_log_fp);
|
|
|
+
|
|
|
// -- End logging for other platforms -- //
|
|
|
#endif
|
|
|
}
|
|
|
#else
|
|
|
-// Not Debug
|
|
|
+// We are not building a debug library, stub the functions.
|
|
|
#define ENET_LOG_TRACE(...) ((void)0)
|
|
|
#define ENET_LOG_ERROR(...) ((void)0)
|
|
|
#endif
|