src/SDL_log.c
changeset 8820 0e935d5b193a
parent 8583 fb2933ca805f
child 8833 ae720d61d14d
equal deleted inserted replaced
8819:728adb496260 8820:0e935d5b193a
    24 #include "core/windows/SDL_windows.h"
    24 #include "core/windows/SDL_windows.h"
    25 #endif
    25 #endif
    26 
    26 
    27 /* Simple log messages in SDL */
    27 /* Simple log messages in SDL */
    28 
    28 
       
    29 #include "SDL_error.h"
    29 #include "SDL_log.h"
    30 #include "SDL_log.h"
    30 
    31 
    31 #if HAVE_STDIO_H
    32 #if HAVE_STDIO_H
    32 #include <stdio.h>
    33 #include <stdio.h>
    33 #endif
    34 #endif
    38 
    39 
    39 #define DEFAULT_PRIORITY                SDL_LOG_PRIORITY_CRITICAL
    40 #define DEFAULT_PRIORITY                SDL_LOG_PRIORITY_CRITICAL
    40 #define DEFAULT_ASSERT_PRIORITY         SDL_LOG_PRIORITY_WARN
    41 #define DEFAULT_ASSERT_PRIORITY         SDL_LOG_PRIORITY_WARN
    41 #define DEFAULT_APPLICATION_PRIORITY    SDL_LOG_PRIORITY_INFO
    42 #define DEFAULT_APPLICATION_PRIORITY    SDL_LOG_PRIORITY_INFO
    42 #define DEFAULT_TEST_PRIORITY           SDL_LOG_PRIORITY_VERBOSE
    43 #define DEFAULT_TEST_PRIORITY           SDL_LOG_PRIORITY_VERBOSE
    43 
       
    44 /* Forward definition of error function */
       
    45 extern int SDL_SetError(const char *fmt, ...);
       
    46 
    44 
    47 typedef struct SDL_LogLevel
    45 typedef struct SDL_LogLevel
    48 {
    46 {
    49     int category;
    47     int category;
    50     SDL_LogPriority priority;
    48     SDL_LogPriority priority;
   170     SDL_application_priority = DEFAULT_APPLICATION_PRIORITY;
   168     SDL_application_priority = DEFAULT_APPLICATION_PRIORITY;
   171     SDL_test_priority = DEFAULT_TEST_PRIORITY;
   169     SDL_test_priority = DEFAULT_TEST_PRIORITY;
   172 }
   170 }
   173 
   171 
   174 void
   172 void
   175 SDL_Log(const char *fmt, ...)
   173 SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
   176 {
   174 {
   177     va_list ap;
   175     va_list ap;
   178 
   176 
   179     va_start(ap, fmt);
   177     va_start(ap, fmt);
   180     SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, fmt, ap);
   178     SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, fmt, ap);
   181     va_end(ap);
   179     va_end(ap);
   182 }
   180 }
   183 
   181 
   184 void
   182 void
   185 SDL_LogVerbose(int category, const char *fmt, ...)
   183 SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
   186 {
   184 {
   187     va_list ap;
   185     va_list ap;
   188 
   186 
   189     va_start(ap, fmt);
   187     va_start(ap, fmt);
   190     SDL_LogMessageV(category, SDL_LOG_PRIORITY_VERBOSE, fmt, ap);
   188     SDL_LogMessageV(category, SDL_LOG_PRIORITY_VERBOSE, fmt, ap);
   191     va_end(ap);
   189     va_end(ap);
   192 }
   190 }
   193 
   191 
   194 void
   192 void
   195 SDL_LogDebug(int category, const char *fmt, ...)
   193 SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
   196 {
   194 {
   197     va_list ap;
   195     va_list ap;
   198 
   196 
   199     va_start(ap, fmt);
   197     va_start(ap, fmt);
   200     SDL_LogMessageV(category, SDL_LOG_PRIORITY_DEBUG, fmt, ap);
   198     SDL_LogMessageV(category, SDL_LOG_PRIORITY_DEBUG, fmt, ap);
   201     va_end(ap);
   199     va_end(ap);
   202 }
   200 }
   203 
   201 
   204 void
   202 void
   205 SDL_LogInfo(int category, const char *fmt, ...)
   203 SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
   206 {
   204 {
   207     va_list ap;
   205     va_list ap;
   208 
   206 
   209     va_start(ap, fmt);
   207     va_start(ap, fmt);
   210     SDL_LogMessageV(category, SDL_LOG_PRIORITY_INFO, fmt, ap);
   208     SDL_LogMessageV(category, SDL_LOG_PRIORITY_INFO, fmt, ap);
   211     va_end(ap);
   209     va_end(ap);
   212 }
   210 }
   213 
   211 
   214 void
   212 void
   215 SDL_LogWarn(int category, const char *fmt, ...)
   213 SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
   216 {
   214 {
   217     va_list ap;
   215     va_list ap;
   218 
   216 
   219     va_start(ap, fmt);
   217     va_start(ap, fmt);
   220     SDL_LogMessageV(category, SDL_LOG_PRIORITY_WARN, fmt, ap);
   218     SDL_LogMessageV(category, SDL_LOG_PRIORITY_WARN, fmt, ap);
   221     va_end(ap);
   219     va_end(ap);
   222 }
   220 }
   223 
   221 
   224 void
   222 void
   225 SDL_LogError(int category, const char *fmt, ...)
   223 SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
   226 {
   224 {
   227     va_list ap;
   225     va_list ap;
   228 
   226 
   229     va_start(ap, fmt);
   227     va_start(ap, fmt);
   230     SDL_LogMessageV(category, SDL_LOG_PRIORITY_ERROR, fmt, ap);
   228     SDL_LogMessageV(category, SDL_LOG_PRIORITY_ERROR, fmt, ap);
   231     va_end(ap);
   229     va_end(ap);
   232 }
   230 }
   233 
   231 
   234 void
   232 void
   235 SDL_LogCritical(int category, const char *fmt, ...)
   233 SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
   236 {
   234 {
   237     va_list ap;
   235     va_list ap;
   238 
   236 
   239     va_start(ap, fmt);
   237     va_start(ap, fmt);
   240     SDL_LogMessageV(category, SDL_LOG_PRIORITY_CRITICAL, fmt, ap);
   238     SDL_LogMessageV(category, SDL_LOG_PRIORITY_CRITICAL, fmt, ap);
   241     va_end(ap);
   239     va_end(ap);
   242 }
   240 }
   243 
   241 
   244 void
   242 void
   245 SDL_LogMessage(int category, SDL_LogPriority priority, const char *fmt, ...)
   243 SDL_LogMessage(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
   246 {
   244 {
   247     va_list ap;
   245     va_list ap;
   248 
   246 
   249     va_start(ap, fmt);
   247     va_start(ap, fmt);
   250     SDL_LogMessageV(category, priority, fmt, ap);
   248     SDL_LogMessageV(category, priority, fmt, ap);