src/SDL_log.c
changeset 8337 4a67a3cca43d
parent 8325 33cbbdd796ec
parent 6616 4f272256d172
child 8377 3a7e8110201e
     1.1 --- a/src/SDL_log.c	Sun Nov 04 09:02:58 2012 -0500
     1.2 +++ b/src/SDL_log.c	Sun Nov 04 09:46:59 2012 -0500
     1.3 @@ -35,6 +35,7 @@
     1.4  #endif
     1.5  
     1.6  #define DEFAULT_PRIORITY                SDL_LOG_PRIORITY_CRITICAL
     1.7 +#define DEFAULT_ASSERT_PRIORITY         SDL_LOG_PRIORITY_WARN
     1.8  #define DEFAULT_APPLICATION_PRIORITY    SDL_LOG_PRIORITY_INFO
     1.9  
    1.10  typedef struct SDL_LogLevel
    1.11 @@ -50,8 +51,9 @@
    1.12                            const char *message);
    1.13  
    1.14  static SDL_LogLevel *SDL_loglevels;
    1.15 +static SDL_LogPriority SDL_default_priority = DEFAULT_PRIORITY;
    1.16 +static SDL_LogPriority SDL_assert_priority = DEFAULT_ASSERT_PRIORITY;
    1.17  static SDL_LogPriority SDL_application_priority = DEFAULT_APPLICATION_PRIORITY;
    1.18 -static SDL_LogPriority SDL_default_priority = DEFAULT_PRIORITY;
    1.19  static SDL_LogOutputFunction SDL_log_function = SDL_LogOutput;
    1.20  static void *SDL_log_userdata = NULL;
    1.21  
    1.22 @@ -95,7 +97,9 @@
    1.23      for (entry = SDL_loglevels; entry; entry = entry->next) {
    1.24          entry->priority = priority;
    1.25      }
    1.26 -    SDL_application_priority = SDL_default_priority = priority;
    1.27 +    SDL_default_priority = priority;
    1.28 +    SDL_assert_priority = priority;
    1.29 +    SDL_application_priority = priority;
    1.30  }
    1.31  
    1.32  void
    1.33 @@ -133,6 +137,8 @@
    1.34  
    1.35      if (category == SDL_LOG_CATEGORY_APPLICATION) {
    1.36          return SDL_application_priority;
    1.37 +    } else if (category == SDL_LOG_CATEGORY_ASSERT) {
    1.38 +        return SDL_assert_priority;
    1.39      } else {
    1.40          return SDL_default_priority;
    1.41      }
    1.42 @@ -149,8 +155,9 @@
    1.43          SDL_free(entry);
    1.44      }
    1.45  
    1.46 +    SDL_default_priority = DEFAULT_PRIORITY;
    1.47 +    SDL_assert_priority = DEFAULT_ASSERT_PRIORITY;
    1.48      SDL_application_priority = DEFAULT_APPLICATION_PRIORITY;
    1.49 -    SDL_default_priority = DEFAULT_PRIORITY;
    1.50  }
    1.51  
    1.52  void
    1.53 @@ -302,6 +309,19 @@
    1.54          SDL_snprintf(tag, SDL_arraysize(tag), "SDL/%s", GetCategoryPrefix(category));
    1.55          __android_log_write(SDL_android_priority[priority], tag, message);
    1.56      }
    1.57 +#elif defined(__APPLE__)
    1.58 +    extern void SDL_NSLog(const char *text);
    1.59 +    {
    1.60 +        char *text;
    1.61 +
    1.62 +        text = SDL_stack_alloc(char, SDL_MAX_LOG_MESSAGE);
    1.63 +        if (text) {
    1.64 +            SDL_snprintf(text, SDL_MAX_LOG_MESSAGE, "%s: %s", SDL_priority_prefixes[priority], message);
    1.65 +            SDL_NSLog(text);
    1.66 +            SDL_stack_free(text);
    1.67 +            return;
    1.68 +        }
    1.69 +    }
    1.70  #endif
    1.71  #if HAVE_STDIO_H
    1.72      fprintf(stderr, "%s: %s\n", SDL_priority_prefixes[priority], message);