src/SDL_log.c
changeset 8337 4a67a3cca43d
parent 8325 33cbbdd796ec
parent 6616 4f272256d172
child 8377 3a7e8110201e
--- a/src/SDL_log.c	Sun Nov 04 09:02:58 2012 -0500
+++ b/src/SDL_log.c	Sun Nov 04 09:46:59 2012 -0500
@@ -35,6 +35,7 @@
 #endif
 
 #define DEFAULT_PRIORITY                SDL_LOG_PRIORITY_CRITICAL
+#define DEFAULT_ASSERT_PRIORITY         SDL_LOG_PRIORITY_WARN
 #define DEFAULT_APPLICATION_PRIORITY    SDL_LOG_PRIORITY_INFO
 
 typedef struct SDL_LogLevel
@@ -50,8 +51,9 @@
                           const char *message);
 
 static SDL_LogLevel *SDL_loglevels;
+static SDL_LogPriority SDL_default_priority = DEFAULT_PRIORITY;
+static SDL_LogPriority SDL_assert_priority = DEFAULT_ASSERT_PRIORITY;
 static SDL_LogPriority SDL_application_priority = DEFAULT_APPLICATION_PRIORITY;
-static SDL_LogPriority SDL_default_priority = DEFAULT_PRIORITY;
 static SDL_LogOutputFunction SDL_log_function = SDL_LogOutput;
 static void *SDL_log_userdata = NULL;
 
@@ -95,7 +97,9 @@
     for (entry = SDL_loglevels; entry; entry = entry->next) {
         entry->priority = priority;
     }
-    SDL_application_priority = SDL_default_priority = priority;
+    SDL_default_priority = priority;
+    SDL_assert_priority = priority;
+    SDL_application_priority = priority;
 }
 
 void
@@ -133,6 +137,8 @@
 
     if (category == SDL_LOG_CATEGORY_APPLICATION) {
         return SDL_application_priority;
+    } else if (category == SDL_LOG_CATEGORY_ASSERT) {
+        return SDL_assert_priority;
     } else {
         return SDL_default_priority;
     }
@@ -149,8 +155,9 @@
         SDL_free(entry);
     }
 
+    SDL_default_priority = DEFAULT_PRIORITY;
+    SDL_assert_priority = DEFAULT_ASSERT_PRIORITY;
     SDL_application_priority = DEFAULT_APPLICATION_PRIORITY;
-    SDL_default_priority = DEFAULT_PRIORITY;
 }
 
 void
@@ -302,6 +309,19 @@
         SDL_snprintf(tag, SDL_arraysize(tag), "SDL/%s", GetCategoryPrefix(category));
         __android_log_write(SDL_android_priority[priority], tag, message);
     }
+#elif defined(__APPLE__)
+    extern void SDL_NSLog(const char *text);
+    {
+        char *text;
+
+        text = SDL_stack_alloc(char, SDL_MAX_LOG_MESSAGE);
+        if (text) {
+            SDL_snprintf(text, SDL_MAX_LOG_MESSAGE, "%s: %s", SDL_priority_prefixes[priority], message);
+            SDL_NSLog(text);
+            SDL_stack_free(text);
+            return;
+        }
+    }
 #endif
 #if HAVE_STDIO_H
     fprintf(stderr, "%s: %s\n", SDL_priority_prefixes[priority], message);