Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Redirect g_print and relatives to the device log in MonoTouch.

	* goutput.c: Redirect output to the device log on iOS devices.
  • Loading branch information...
commit da1644bfbfcb346f7af8f00dd0e3e9ad1bc4bce1 1 parent 8d9fa2b
@rolfbjarne rolfbjarne authored kumpera committed
Showing with 26 additions and 0 deletions.
  1. +26 −0 eglib/src/goutput.c
View
26 eglib/src/goutput.c
@@ -58,6 +58,30 @@ out_vfprintf (FILE *ignore, const gchar *format, va_list args)
/* TODO: provide a proper app name */
__android_log_vprint (ANDROID_LOG_ERROR, "mono", format, args);
}
+#elif MONOTOUCH && defined(__arm__)
+#include <asl.h>
+
+static int
+to_asl_priority (GLogLevelFlags log_level)
+{
+ switch (log_level & G_LOG_LEVEL_MASK)
+ {
+ case G_LOG_LEVEL_ERROR: return ASL_LEVEL_CRIT;
+ case G_LOG_LEVEL_CRITICAL: return ASL_LEVEL_ERR;
+ case G_LOG_LEVEL_WARNING: return ASL_LEVEL_WARNING;
+ case G_LOG_LEVEL_MESSAGE: return ASL_LEVEL_NOTICE;
+ case G_LOG_LEVEL_INFO: return ASL_LEVEL_INFO;
+ case G_LOG_LEVEL_DEBUG: return ASL_LEVEL_DEBUG;
+ }
+ return ASL_LEVEL_ERR;
+}
+
+static void
+out_vfprintf (FILE *ignore, const gchar *format, va_list args)
+{
+ asl_vlog (NULL, NULL, ASL_LEVEL_WARNING, format, args);
+}
+
#else
static void
out_vfprintf (FILE *file, const gchar *format, va_list args)
@@ -116,6 +140,8 @@ g_logv (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format,
{
#if PLATFORM_ANDROID
__android_log_vprint (to_android_priority (log_level), log_domain, format, args);
+#elif MONOTOUCH && defined(__arm__)
+ asl_vlog (NULL, NULL, to_asl_priority (log_level), format, args);
#else
char *msg;
Please sign in to comment.
Something went wrong with that request. Please try again.