upgrade SDL to version 2.0.8
[platform/upstream/SDL.git] / src / SDL_log.c
index b1bf27d..4339663 100755 (executable)
 #include <android/log.h>
 #endif
 
+#ifndef __TIZEN__
+#define __TIZEN__
+#endif
+
+#if defined(__TIZEN__)
+#include <dlog/dlog.h>
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "SDL_LOG"
+#define _SECURE_LOG
+#endif
+
+
+
 #define DEFAULT_PRIORITY                SDL_LOG_PRIORITY_CRITICAL
 #define DEFAULT_ASSERT_PRIORITY         SDL_LOG_PRIORITY_WARN
 #define DEFAULT_APPLICATION_PRIORITY    SDL_LOG_PRIORITY_INFO
@@ -70,6 +85,18 @@ static const char *SDL_priority_prefixes[SDL_NUM_LOG_PRIORITIES] = {
     "CRITICAL"
 };
 
+#if defined(__TIZEN__)
+static const int SDL_dlog_debug_priority[SDL_NUM_LOG_PRIORITIES] = {
+    DLOG_UNKNOWN,
+    DLOG_VERBOSE,
+    DLOG_DEBUG,
+    DLOG_INFO,
+    DLOG_WARN,
+    DLOG_ERROR,
+    DLOG_FATAL
+};
+#endif
+
 #ifdef __ANDROID__
 static const char *SDL_category_prefixes[SDL_LOG_CATEGORY_RESERVED1] = {
     "APP",
@@ -310,6 +337,22 @@ static int consoleAttached = 0;
 static HANDLE stderrHandle = NULL;
 #endif
 
+
+#if defined(__TIZEN__)
+static void
+SDL_PrintDlog(int priority, char *format, ...)
+{
+    va_list ap;
+
+    if (priority >= SDL_NUM_LOG_PRIORITIES)
+        return;
+
+    va_start(ap, format);
+    dlog_vprint(SDL_dlog_debug_priority[priority], LOG_TAG, format, ap);
+    va_end(ap);
+}
+#endif
+
 static void SDLCALL
 SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
               const char *message)
@@ -420,13 +463,17 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
         fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
         fclose (pFile);
     }
+#elif defined(__TIZEN__)
+    {
+        SDL_PrintDlog(priority, "%s: %s", SDL_priority_prefixes[priority], message);
+    }
 #endif
 #if HAVE_STDIO_H
     fprintf(stderr, "%s: %s\n", SDL_priority_prefixes[priority], message);
+#endif
 #if __NACL__
     fflush(stderr);
 #endif
-#endif
 }
 
 void