Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
authorAndreas Schiffler <aschiffler@ferzkopp.net>
Wed, 14 Aug 2013 23:30:10 -0700
changeset 7639 9406b7dd2f2d
parent 7638 783d1cff9b20
child 7640 38284657fc79
Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
VisualC/tests/loopwave/loopwave_VS2010.vcxproj
VisualC/tests/loopwave/loopwave_VS2012.vcxproj
test/checkkeys.c
test/loopwave.c
test/testatomic.c
test/testaudioinfo.c
test/testautomation.c
test/testautomation_surface.c
test/testdraw2.c
test/testdrawchessboard.c
test/testerror.c
test/testfile.c
test/testgamecontroller.c
test/testgesture.c
test/testgl2.c
test/testgles.c
test/testhaptic.c
test/testiconv.c
test/testime.c
test/testintersections.c
test/testjoystick.c
test/testkeys.c
test/testloadso.c
test/testlock.c
test/testmessage.c
test/testmultiaudio.c
test/testnative.c
test/testoverlay2.c
test/testplatform.c
test/testpower.c
test/testrelative.c
test/testrendercopyex.c
test/testrendertarget.c
test/testresample.c
test/testrumble.c
test/testscale.c
test/testsem.c
test/testshader.c
test/testshape.c
test/testsprite2.c
test/testspriteminimal.c
test/teststreaming.c
test/testthread.c
test/testtimer.c
test/testver.c
test/testwm2.c
test/torturethread.c
--- a/VisualC/tests/loopwave/loopwave_VS2010.vcxproj	Mon Aug 12 22:00:21 2013 -0700
+++ b/VisualC/tests/loopwave/loopwave_VS2010.vcxproj	Wed Aug 14 23:30:10 2013 -0700
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup Label="ProjectConfigurations">
     <ProjectConfiguration Include="Debug|Win32">
@@ -105,7 +105,8 @@
       <SubSystem>Windows</SubSystem>
     </Link>
     <PostBuildEvent>
-      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
+      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
+copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
     </PostBuildEvent>
     <PostBuildEvent>
       <Message>Copy SDL</Message>
@@ -139,7 +140,8 @@
       <SubSystem>Windows</SubSystem>
     </Link>
     <PostBuildEvent>
-      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
+      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
+copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
     </PostBuildEvent>
     <PostBuildEvent>
       <Message>Copy SDL</Message>
@@ -174,7 +176,8 @@
       <SubSystem>Windows</SubSystem>
     </Link>
     <PostBuildEvent>
-      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
+      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
+copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
     </PostBuildEvent>
     <PostBuildEvent>
       <Message>Copy SDL</Message>
@@ -208,7 +211,8 @@
       <SubSystem>Windows</SubSystem>
     </Link>
     <PostBuildEvent>
-      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
+      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
+copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
     </PostBuildEvent>
     <PostBuildEvent>
       <Message>Copy SDL</Message>
--- a/VisualC/tests/loopwave/loopwave_VS2012.vcxproj	Mon Aug 12 22:00:21 2013 -0700
+++ b/VisualC/tests/loopwave/loopwave_VS2012.vcxproj	Wed Aug 14 23:30:10 2013 -0700
@@ -109,7 +109,8 @@
       <SubSystem>Windows</SubSystem>
     </Link>
     <PostBuildEvent>
-      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
+      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
+copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
     </PostBuildEvent>
     <PostBuildEvent>
       <Message>Copy SDL</Message>
@@ -143,7 +144,8 @@
       <SubSystem>Windows</SubSystem>
     </Link>
     <PostBuildEvent>
-      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
+      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
+copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
     </PostBuildEvent>
     <PostBuildEvent>
       <Message>Copy SDL</Message>
@@ -178,7 +180,8 @@
       <SubSystem>Windows</SubSystem>
     </Link>
     <PostBuildEvent>
-      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
+      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
+copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
     </PostBuildEvent>
     <PostBuildEvent>
       <Message>Copy SDL</Message>
@@ -212,7 +215,8 @@
       <SubSystem>Windows</SubSystem>
     </Link>
     <PostBuildEvent>
-      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
+      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
+copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
     </PostBuildEvent>
     <PostBuildEvent>
       <Message>Copy SDL</Message>
--- a/test/checkkeys.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/checkkeys.c	Wed Aug 14 23:30:10 2013 -0700
@@ -117,13 +117,13 @@
 static void
 PrintText(char *text)
 {
-    unsigned char *spot, expanded[1024];
+    char *spot, expanded[1024];
 
     expanded[0] = '\0';
     for ( spot = text; *spot; ++spot )
     {
         size_t length = SDL_strlen(expanded);
-        SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", *spot);
+        SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", (unsigned char)*spot);
     }
     SDL_Log("Text (%s): \"%s%s\"\n", expanded, *text == '"' ? "\\" : "", text);
 }
@@ -134,10 +134,13 @@
     SDL_Window *window;
     SDL_Event event;
     int done;
+	
+	/* Enable standard application logging */
+	SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 
     /* Initialize SDL */
     if (SDL_Init(SDL_INIT_VIDEO) < 0) {
-        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+		SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return (1);
     }
 
@@ -146,7 +149,7 @@
                               SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
                               640, 480, 0);
     if (!window) {
-        fprintf(stderr, "Couldn't create 640x480 window: %s\n",
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n",
                 SDL_GetError());
         quit(2);
     }
@@ -166,7 +169,7 @@
         switch (event.type) {
         case SDL_KEYDOWN:
         case SDL_KEYUP:
-            PrintKey(&event.key.keysym, event.key.state, event.key.repeat);
+			PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED) ? SDL_TRUE : SDL_FALSE, (event.key.repeat) ? SDL_TRUE : SDL_FALSE);
             break;
         case SDL_TEXTINPUT:
             PrintText(event.text.text);
--- a/test/loopwave.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/loopwave.c	Wed Aug 14 23:30:10 2013 -0700
@@ -80,9 +80,12 @@
 {
     int i;
 
+	/* Enable standard application logging */
+	SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     /* Load the SDL library */
     if (SDL_Init(SDL_INIT_AUDIO) < 0) {
-        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return (1);
     }
 
@@ -91,7 +94,7 @@
     }
     /* Load the wave file into memory */
     if (SDL_LoadWAV(argv[1], &wave.spec, &wave.sound, &wave.soundlen) == NULL) {
-        fprintf(stderr, "Couldn't load %s: %s\n", argv[1], SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", argv[1], SDL_GetError());
         quit(1);
     }
 
@@ -109,24 +112,19 @@
 #endif /* HAVE_SIGNAL_H */
 
     /* Show the list of available drivers */
-    printf("Available audio drivers: ");
+    SDL_Log("Available audio drivers:");
     for (i = 0; i < SDL_GetNumAudioDrivers(); ++i) {
-        if (i == 0) {
-            printf("%s", SDL_GetAudioDriver(i));
-        } else {
-            printf(", %s", SDL_GetAudioDriver(i));
-        }
+		SDL_Log("%i: %s", i, SDL_GetAudioDriver(i));
     }
-    printf("\n");
 
     /* Initialize fillerup() variables */
     if (SDL_OpenAudio(&wave.spec, NULL) < 0) {
-        fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError());
         SDL_FreeWAV(wave.sound);
         quit(2);
     }
 
-    printf("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
+    SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
 
     /* Let the audio run */
     SDL_PauseAudio(0);
--- a/test/testatomic.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testatomic.c	Wed Aug 14 23:30:10 2013 -0700
@@ -45,39 +45,39 @@
     SDL_atomic_t v;
     SDL_bool tfret = SDL_FALSE;
 
-    printf("\nspin lock---------------------------------------\n\n");
+    SDL_Log("\nspin lock---------------------------------------\n\n");
 
     SDL_AtomicLock(&lock);
-    printf("AtomicLock                   lock=%d\n", lock);
+    SDL_Log("AtomicLock                   lock=%d\n", lock);
     SDL_AtomicUnlock(&lock);
-    printf("AtomicUnlock                 lock=%d\n", lock);
+    SDL_Log("AtomicUnlock                 lock=%d\n", lock);
 
-    printf("\natomic -----------------------------------------\n\n");
+    SDL_Log("\natomic -----------------------------------------\n\n");
 
     SDL_AtomicSet(&v, 0);
-    tfret = SDL_AtomicSet(&v, 10) == 0;
-    printf("AtomicSet(10)        tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
-    tfret = SDL_AtomicAdd(&v, 10) == 10;
-    printf("AtomicAdd(10)        tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+    tfret = SDL_AtomicSet(&v, 10) == 0 ? SDL_TRUE : SDL_FALSE;
+    SDL_Log("AtomicSet(10)        tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+    tfret = SDL_AtomicAdd(&v, 10) == 10 ? SDL_TRUE : SDL_FALSE;
+    SDL_Log("AtomicAdd(10)        tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
 
     SDL_AtomicSet(&v, 0);
     SDL_AtomicIncRef(&v);
-    tfret = (SDL_AtomicGet(&v) == 1);
-    printf("AtomicIncRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+    tfret = (SDL_AtomicGet(&v) == 1) ? SDL_TRUE : SDL_FALSE;
+    SDL_Log("AtomicIncRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
     SDL_AtomicIncRef(&v);
-    tfret = (SDL_AtomicGet(&v) == 2);
-    printf("AtomicIncRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
-    tfret = (SDL_AtomicDecRef(&v) == SDL_FALSE);
-    printf("AtomicDecRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
-    tfret = (SDL_AtomicDecRef(&v) == SDL_TRUE);
-    printf("AtomicDecRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+    tfret = (SDL_AtomicGet(&v) == 2) ? SDL_TRUE : SDL_FALSE;
+    SDL_Log("AtomicIncRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+    tfret = (SDL_AtomicDecRef(&v) == SDL_FALSE) ? SDL_TRUE : SDL_FALSE;
+    SDL_Log("AtomicDecRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+    tfret = (SDL_AtomicDecRef(&v) == SDL_TRUE) ? SDL_TRUE : SDL_FALSE;
+    SDL_Log("AtomicDecRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
 
     SDL_AtomicSet(&v, 10);
-    tfret = (SDL_AtomicCAS(&v, 0, 20) == SDL_FALSE);
-    printf("AtomicCAS()          tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+    tfret = (SDL_AtomicCAS(&v, 0, 20) == SDL_FALSE) ? SDL_TRUE : SDL_FALSE;
+    SDL_Log("AtomicCAS()          tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
     value = SDL_AtomicGet(&v);
-    tfret = (SDL_AtomicCAS(&v, value, 20) == SDL_TRUE);
-    printf("AtomicCAS()          tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+    tfret = (SDL_AtomicCAS(&v, value, 20) == SDL_TRUE) ? SDL_TRUE : SDL_FALSE;
+    SDL_Log("AtomicCAS()          tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
 }
 
 /**************************************************************************/
@@ -120,7 +120,7 @@
 int adder(void* junk)
 {
     unsigned long N=NInter;
-    printf("Thread subtracting %d %lu times\n",CountInc,N);
+    SDL_Log("Thread subtracting %d %lu times\n",CountInc,N);
     while (N--) {
         SDL_AtomicAdd(&good, -CountInc);
         bad-=CountInc;
@@ -152,7 +152,7 @@
 
     end = SDL_GetTicks();
 
-    printf("Finished in %f sec\n", (end - start) / 1000.f);
+    SDL_Log("Finished in %f sec\n", (end - start) / 1000.f);
 }
 
 static
@@ -161,28 +161,28 @@
     int b;
     atomicValue v;
 
-    printf("\nepic test---------------------------------------\n\n");
+    SDL_Log("\nepic test---------------------------------------\n\n");
 
-    printf("Size asserted to be >= 32-bit\n");
+    SDL_Log("Size asserted to be >= 32-bit\n");
     SDL_assert(sizeof(atomicValue)>=4);
 
-    printf("Check static initializer\n");
+    SDL_Log("Check static initializer\n");
     v=SDL_AtomicGet(&good);
     SDL_assert(v==42);
 
     SDL_assert(bad==42);
 
-    printf("Test negative values\n");
+    SDL_Log("Test negative values\n");
     SDL_AtomicSet(&good, -5);
     v=SDL_AtomicGet(&good);
     SDL_assert(v==-5);
 
-    printf("Verify maximum value\n");
+    SDL_Log("Verify maximum value\n");
     SDL_AtomicSet(&good, CountTo);
     v=SDL_AtomicGet(&good);
     SDL_assert(v==CountTo);
 
-    printf("Test compare and exchange\n");
+    SDL_Log("Test compare and exchange\n");
 
     b=SDL_AtomicCAS(&good, 500, 43);
     SDL_assert(!b); /* no swap since CountTo!=500 */
@@ -194,7 +194,7 @@
     v=SDL_AtomicGet(&good);
     SDL_assert(v==44);
 
-    printf("Test Add\n");
+    SDL_Log("Test Add\n");
 
     v=SDL_AtomicAdd(&good, 1);
     SDL_assert(v==44);
@@ -206,7 +206,7 @@
     v=SDL_AtomicGet(&good);
     SDL_assert(v==55);
 
-    printf("Test Add (Negative values)\n");
+    SDL_Log("Test Add (Negative values)\n");
 
     v=SDL_AtomicAdd(&good, -20);
     SDL_assert(v==55);
@@ -223,7 +223,7 @@
     v=SDL_AtomicGet(&good);
     SDL_assert(v==15);
 
-    printf("Reset before count down test\n");
+    SDL_Log("Reset before count down test\n");
     SDL_AtomicSet(&good, CountTo);
     v=SDL_AtomicGet(&good);
     SDL_assert(v==CountTo);
@@ -231,11 +231,11 @@
     bad=CountTo;
     SDL_assert(bad==CountTo);
 
-    printf("Counting down from %d, Expect %d remaining\n",CountTo,Expect);
+    SDL_Log("Counting down from %d, Expect %d remaining\n",CountTo,Expect);
     runAdder();
 
     v=SDL_AtomicGet(&good);
-    printf("Atomic %d Non-Atomic %d\n",v,bad);
+    SDL_Log("Atomic %d Non-Atomic %d\n",v,bad);
     SDL_assert(v==Expect);
     SDL_assert(bad!=Expect);
 }
@@ -429,7 +429,7 @@
     } else if (delta < 0) {
         /* We ran into an old queue entry, which means it still needs to be dequeued */
     } else {
-        printf("ERROR: mutex failed!\n");
+        SDL_Log("ERROR: mutex failed!\n");
     }
 
     SDL_UnlockMutex(queue->mutex);
@@ -462,7 +462,7 @@
     } else if (delta < 0) {
         /* We ran into an old queue entry, which means we've hit empty */
     } else {
-        printf("ERROR: mutex failed!\n");
+        SDL_Log("ERROR: mutex failed!\n");
     }
 
     SDL_UnlockMutex(queue->mutex);
@@ -598,9 +598,11 @@
     Uint32 start, end;
     int i, j;
     int grand_total;
+	char textBuffer[1024];
+	int len;
 
-    printf("\nFIFO test---------------------------------------\n\n");
-    printf("Mode: %s\n", lock_free ? "LockFree" : "Mutex");
+    SDL_Log("\nFIFO test---------------------------------------\n\n");
+    SDL_Log("Mode: %s\n", lock_free ? "LockFree" : "Mutex");
 
     readersDone = SDL_CreateSemaphore(0);
     writersDone = SDL_CreateSemaphore(0);
@@ -622,7 +624,7 @@
 #endif
 
     /* Start the readers first */
-    printf("Starting %d readers\n", NUM_READERS);
+    SDL_Log("Starting %d readers\n", NUM_READERS);
     SDL_zero(readerData);
     SDL_AtomicSet(&readersRunning, NUM_READERS);
     for (i = 0; i < NUM_READERS; ++i) {
@@ -634,7 +636,7 @@
     }
 
     /* Start up the writers */
-    printf("Starting %d writers\n", NUM_WRITERS);
+    SDL_Log("Starting %d writers\n", NUM_WRITERS);
     SDL_zero(writerData);
     SDL_AtomicSet(&writersRunning, NUM_WRITERS);
     for (i = 0; i < NUM_WRITERS; ++i) {
@@ -668,16 +670,16 @@
         SDL_DestroyMutex(queue.mutex);
     }
 
-    printf("Finished in %f sec\n", (end - start) / 1000.f);
+    SDL_Log("Finished in %f sec\n", (end - start) / 1000.f);
 
-    printf("\n");
+    SDL_Log("\n");
     for (i = 0; i < NUM_WRITERS; ++i) {
-        printf("Writer %d wrote %d events, had %d waits\n", i, EVENTS_PER_WRITER, writerData[i].waits);
+        SDL_Log("Writer %d wrote %d events, had %d waits\n", i, EVENTS_PER_WRITER, writerData[i].waits);
     }
-    printf("Writers wrote %d total events\n", NUM_WRITERS*EVENTS_PER_WRITER);
+    SDL_Log("Writers wrote %d total events\n", NUM_WRITERS*EVENTS_PER_WRITER);
 
     /* Print a breakdown of which readers read messages from which writer */
-    printf("\n");
+    SDL_Log("\n");
     grand_total = 0;
     for (i = 0; i < NUM_READERS; ++i) {
         int total = 0;
@@ -685,17 +687,21 @@
             total += readerData[i].counters[j];
         }
         grand_total += total;
-        printf("Reader %d read %d events, had %d waits\n", i, total, readerData[i].waits);
-        printf("  { ");
+        SDL_Log("Reader %d read %d events, had %d waits\n", i, total, readerData[i].waits);
+		SDL_snprintf(textBuffer, sizeof(textBuffer), "  { ");
         for (j = 0; j < NUM_WRITERS; ++j) {
             if (j > 0) {
-                printf(", ");
+				len = SDL_strlen(textBuffer);
+                SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, ", ");
             }
-            printf("%d", readerData[i].counters[j]);
+            len = SDL_strlen(textBuffer);
+            SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, "%d", readerData[i].counters[j]);
         }
-        printf(" }\n");
+        len = SDL_strlen(textBuffer);
+        SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, " }\n");
+		SDL_Log(textBuffer);
     }
-    printf("Readers read %d total events\n", grand_total);
+    SDL_Log("Readers read %d total events\n", grand_total);
 }
 
 /* End FIFO test */
@@ -704,6 +710,9 @@
 int
 main(int argc, char *argv[])
 {
+	/* Enable standard application logging */
+	SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     RunBasicTest();
     RunEpicTest();
 /* This test is really slow, so don't run it by default */
--- a/test/testaudioinfo.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testaudioinfo.c	Wed Aug 14 23:30:10 2013 -0700
@@ -18,18 +18,18 @@
     const char *typestr = ((iscapture) ? "capture" : "output");
     int n = SDL_GetNumAudioDevices(iscapture);
 
-    printf("%s devices:\n", typestr);
+    SDL_Log("%s devices:\n", typestr);
 
     if (n == -1)
-        printf("  Driver can't detect specific %s devices.\n\n", typestr);
+        SDL_Log("  Driver can't detect specific %s devices.\n\n", typestr);
     else if (n == 0)
-        printf("  No %s devices found.\n\n", typestr);
+        SDL_Log("  No %s devices found.\n\n", typestr);
     else {
         int i;
         for (i = 0; i < n; i++) {
-            printf("  %s\n", SDL_GetAudioDeviceName(i, iscapture));
+            SDL_Log("  %s\n", SDL_GetAudioDeviceName(i, iscapture));
         }
-        printf("\n");
+        SDL_Log("\n");
     }
 }
 
@@ -38,26 +38,29 @@
 {
     int n;
 
+    /* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     /* Load the SDL library */
     if (SDL_Init(SDL_INIT_AUDIO) < 0) {
-        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return (1);
     }
 
     /* Print available audio drivers */
     n = SDL_GetNumAudioDrivers();
     if (n == 0) {
-        printf("No built-in audio drivers\n\n");
+        SDL_Log("No built-in audio drivers\n\n");
     } else {
         int i;
-        printf("Built-in audio drivers:\n");
+        SDL_Log("Built-in audio drivers:\n");
         for (i = 0; i < n; ++i) {
-            printf("  %s\n", SDL_GetAudioDriver(i));
+            SDL_Log("  %s\n", SDL_GetAudioDriver(i));
         }
-        printf("\n");
+        SDL_Log("\n");
     }
 
-    printf("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
+    SDL_Log("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
 
     print_devices(0);
     print_devices(1);
--- a/test/testautomation.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testautomation.c	Wed Aug 14 23:30:10 2013 -0700
@@ -80,8 +80,7 @@
             }
         }
         if (consumed < 0) {
-            fprintf(stderr,
-                    "Usage: %s %s [--iterations #] [--execKey #] [--seed string] [--filter suite_name|test_name]\n",
+            SDL_Log("Usage: %s %s [--iterations #] [--execKey #] [--seed string] [--filter suite_name|test_name]\n",
                     argv[0], SDLTest_CommonUsage(state));
             quit(1);
         }
--- a/test/testautomation_surface.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testautomation_surface.c	Wed Aug 14 23:30:10 2013 -0700
@@ -360,8 +360,6 @@
 
     for ( i = 0; i < SDL_arraysize(pixel_formats); ++i ) {
         for ( j = 0; j < SDL_arraysize(pixel_formats); ++j ) {
-            /*printf("Converting %s -> %s\n", SDL_GetPixelFormatName(pixel_formats[i]), SDL_GetPixelFormatName(pixel_formats[j]));*/
-
             fmt1 = SDL_AllocFormat(pixel_formats[i]);
             SDL_assert(fmt1 != NULL);
             cvt1 = SDL_ConvertSurface(face, fmt1, 0);
--- a/test/testdraw2.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testdraw2.c	Wed Aug 14 23:30:10 2013 -0700
@@ -176,6 +176,9 @@
     SDL_Event event;
     Uint32 then, now, frames;
 
+	/* Enable standard application logging */
+	SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     /* Initialize parameters */
     num_objects = NUM_OBJECTS;
 
@@ -218,8 +221,7 @@
             }
         }
         if (consumed < 0) {
-            fprintf(stderr,
-                    "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
+            SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
                     argv[0], SDLTest_CommonUsage(state));
             return 1;
         }
@@ -268,7 +270,7 @@
     now = SDL_GetTicks();
     if (now > then) {
         double fps = ((double) frames * 1000) / (now - then);
-        printf("%2.2f frames per second\n", fps);
+        SDL_Log("%2.2f frames per second\n", fps);
     }
     return 0;
 }
--- a/test/testdrawchessboard.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testdrawchessboard.c	Wed Aug 14 23:30:10 2013 -0700
@@ -54,10 +54,13 @@
 	SDL_Surface *surface;
 	SDL_Renderer *renderer;
 
+    /* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
 	/* Initialize SDL */
 	if(SDL_Init(SDL_INIT_VIDEO) != 0)
 	{
-		fprintf(stderr,"SDL_Init fail : %s\n", SDL_GetError());
+		SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init fail : %s\n", SDL_GetError());
 		return 1;
 	}
 
@@ -66,14 +69,14 @@
 	window = SDL_CreateWindow("Chess Board", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN);
 	if(!window)
 	{
-		fprintf(stderr,"Window creation fail : %s\n",SDL_GetError());
+		SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window creation fail : %s\n",SDL_GetError());
 		return 1;
 	}	
 	surface = SDL_GetWindowSurface(window);
 	renderer = SDL_CreateSoftwareRenderer(surface);
 	if(!renderer)
 	{
-		fprintf(stderr,"Render creation for surface fail : %s\n",SDL_GetError());
+		SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Render creation for surface fail : %s\n",SDL_GetError());
 		return 1;
 	}
 
--- a/test/testerror.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testerror.c	Wed Aug 14 23:30:10 2013 -0700
@@ -36,10 +36,10 @@
     SDL_SetError("Thread %s (%lu) had a problem: %s",
                  (char *) data, SDL_ThreadID(), "nevermind");
     while (alive) {
-        printf("Thread '%s' is alive!\n", (char *) data);
+        SDL_Log("Thread '%s' is alive!\n", (char *) data);
         SDL_Delay(1 * 1000);
     }
-    printf("Child thread error string: %s\n", SDL_GetError());
+    SDL_Log("Child thread error string: %s\n", SDL_GetError());
     return (0);
 }
 
@@ -48,9 +48,12 @@
 {
     SDL_Thread *thread;
 
+    /* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     /* Load the SDL library */
     if (SDL_Init(0) < 0) {
-        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return (1);
     }
 
@@ -60,15 +63,15 @@
     alive = 1;
     thread = SDL_CreateThread(ThreadFunc, NULL, "#1");
     if (thread == NULL) {
-        fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
         quit(1);
     }
     SDL_Delay(5 * 1000);
-    printf("Waiting for thread #1\n");
+    SDL_Log("Waiting for thread #1\n");
     alive = 0;
     SDL_WaitThread(thread, NULL);
 
-    printf("Main thread error string: %s\n", SDL_GetError());
+    SDL_Log("Main thread error string: %s\n", SDL_GetError());
 
     SDL_Quit();
     return (0);
--- a/test/testfile.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testfile.c	Wed Aug 14 23:30:10 2013 -0700
@@ -44,7 +44,6 @@
 static void
 cleanup(void)
 {
-
     unlink(FBASENAME1);
     unlink(FBASENAME2);
 }
@@ -52,8 +51,7 @@
 static void
 rwops_error_quit(unsigned line, SDL_RWops * rwops)
 {
-
-    printf("testfile.c(%d): failed\n", line);
+    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "testfile.c(%d): failed\n", line);
     if (rwops) {
         rwops->close(rwops);    /* This calls SDL_FreeRW(rwops); */
     }
@@ -71,6 +69,9 @@
     SDL_RWops *rwops = NULL;
     char test_buf[30];
 
+    /* Enable standard application logging */
+	SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     cleanup();
 
 /* test 1 : basic argument test: all those calls to SDL_RWFromFile should fail */
@@ -90,7 +91,7 @@
     rwops = SDL_RWFromFile("something", NULL);
     if (rwops)
         RWOP_ERR_QUIT(rwops);
-    printf("test1 OK\n");
+    SDL_Log("test1 OK\n");
 
 /* test 2 : check that inexistent file is not successfully opened/created when required */
 /* modes : r, r+ imply that file MUST exist
@@ -123,7 +124,7 @@
         RWOP_ERR_QUIT(rwops);
     rwops->close(rwops);
     unlink(FBASENAME2);
-    printf("test2 OK\n");
+    SDL_Log("test2 OK\n");
 
 /* test 3 : creation, writing , reading, seeking,
             test : w mode, r mode, w+ mode
@@ -201,7 +202,7 @@
     if (SDL_memcmp(test_buf, "12345678901234567890", 20))
         RWOP_ERR_QUIT(rwops);
     rwops->close(rwops);
-    printf("test3 OK\n");
+    SDL_Log("test3 OK\n");
 
 /* test 4: same in r+ mode */
     rwops = SDL_RWFromFile(FBASENAME1, "rb+");  /* write + read + file must exists, no truncation */
@@ -236,7 +237,7 @@
     if (SDL_memcmp(test_buf, "12345678901234567890", 20))
         RWOP_ERR_QUIT(rwops);
     rwops->close(rwops);
-    printf("test4 OK\n");
+    SDL_Log("test4 OK\n");
 
 /* test5 : append mode */
     rwops = SDL_RWFromFile(FBASENAME1, "ab+");  /* write + read + append */
@@ -277,7 +278,7 @@
     if (SDL_memcmp(test_buf, "123456789012345678901234567123", 30))
         RWOP_ERR_QUIT(rwops);
     rwops->close(rwops);
-    printf("test5 OK\n");
+    SDL_Log("test5 OK\n");
     cleanup();
     return 0;                   /* all ok */
 }
--- a/test/testgamecontroller.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testgamecontroller.c	Wed Aug 14 23:30:10 2013 -0700
@@ -91,7 +91,7 @@
     const char *name = SDL_GameControllerName(gamecontroller);
     const char *basetitle = "Game Controller Test: ";
     const size_t titlelen = SDL_strlen(basetitle) + SDL_strlen(name) + 1;
-    char *title = SDL_malloc(titlelen);
+    char *title = (char *)SDL_malloc(titlelen);
     SDL_Window *window = NULL;
     SDL_Renderer *screen = NULL;
     int done = 0;
@@ -107,13 +107,13 @@
                               SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH,
                               SCREEN_HEIGHT, 0);
     if (window == NULL) {
-        fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
         return;
     }
 
     screen = SDL_CreateRenderer(window, -1, 0);
     if (screen == NULL) {
-        fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
         SDL_DestroyWindow(window);
         return;
     }
@@ -124,7 +124,7 @@
     SDL_RaiseWindow(window);
 
     /* Print info about the controller we are watching */
-    printf("Watching controller %s\n",  name ? name : "Unknown Controller");
+    SDL_Log("Watching controller %s\n",  name ? name : "Unknown Controller");
 
     /* Loop, getting controller events! */
     while (!done) {
@@ -135,21 +135,21 @@
         while (SDL_PollEvent(&event)) {
             switch (event.type) {
             case SDL_CONTROLLERAXISMOTION:
-                printf("Controller %d axis %d ('%s') value: %d\n",
+                SDL_Log("Controller %d axis %d ('%s') value: %d\n",
                        event.caxis.which,
                        event.caxis.axis,
-                       ControllerAxisName(event.caxis.axis),
+                       ControllerAxisName((SDL_GameControllerAxis)event.caxis.axis),
                        event.caxis.value);
                 break;
             case SDL_CONTROLLERBUTTONDOWN:
-                printf("Controller %d button %d ('%s') down\n",
+                SDL_Log("Controller %d button %d ('%s') down\n",
                        event.cbutton.which, event.cbutton.button,
-                       ControllerButtonName(event.cbutton.button));
+                       ControllerButtonName((SDL_GameControllerButton)event.cbutton.button));
                 break;
             case SDL_CONTROLLERBUTTONUP:
-                printf("Controller %d button %d ('%s') up\n",
+                SDL_Log("Controller %d button %d ('%s') up\n",
                        event.cbutton.which, event.cbutton.button,
-                       ControllerButtonName(event.cbutton.button));
+                       ControllerButtonName((SDL_GameControllerButton)event.cbutton.button));
                 break;
             case SDL_KEYDOWN:
                 if (event.key.keysym.sym != SDLK_ESCAPE) {
@@ -167,7 +167,7 @@
         /* Update visual controller state */
         SDL_SetRenderDrawColor(screen, 0x00, 0xFF, 0x00, SDL_ALPHA_OPAQUE);
         for (i = 0; i <SDL_CONTROLLER_BUTTON_MAX; ++i) {
-            if (SDL_GameControllerGetButton(gamecontroller, i) == SDL_PRESSED) {
+            if (SDL_GameControllerGetButton(gamecontroller, (SDL_GameControllerButton)i) == SDL_PRESSED) {
                 DrawRect(screen, i * 34, SCREEN_HEIGHT - 34, 32, 32);
             }
         }
@@ -176,7 +176,7 @@
         for (i = 0; i < SDL_CONTROLLER_AXIS_MAX / 2; ++i) {
             /* Draw the X/Y axis */
             int x, y;
-            x = (((int) SDL_GameControllerGetAxis(gamecontroller, i * 2 + 0)) + 32768);
+            x = (((int) SDL_GameControllerGetAxis(gamecontroller, (SDL_GameControllerAxis)(i * 2 + 0))) + 32768);
             x *= SCREEN_WIDTH;
             x /= 65535;
             if (x < 0) {
@@ -184,7 +184,7 @@
             } else if (x > (SCREEN_WIDTH - 16)) {
                 x = SCREEN_WIDTH - 16;
             }
-            y = (((int) SDL_GameControllerGetAxis(gamecontroller, i * 2 + 1)) + 32768);
+            y = (((int) SDL_GameControllerGetAxis(gamecontroller, (SDL_GameControllerAxis)(i * 2 + 1))) + 32768);
             y *= SCREEN_HEIGHT;
             y /= 65535;
             if (y < 0) {
@@ -217,9 +217,12 @@
     char guid[64];
     SDL_GameController *gamecontroller;
 
+    /* Enable standard application logging */
+	SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     /* Initialize SDL (Note: video is required to start event loop) */
     if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER ) < 0) {
-        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return 1;
     }
 
@@ -238,22 +241,22 @@
         } else {
             name = SDL_JoystickNameForIndex(i);
         }
-        printf("%s %d: %s (guid %s)\n", description, i, name ? name : "Unknown", guid);
+        SDL_Log("%s %d: %s (guid %s)\n", description, i, name ? name : "Unknown", guid);
     }
-    printf("There are %d game controller(s) attached (%d joystick(s))\n", nController, SDL_NumJoysticks());
+    SDL_Log("There are %d game controller(s) attached (%d joystick(s))\n", nController, SDL_NumJoysticks());
 
     if (argv[1]) {
         int device = atoi(argv[1]);
         if (device >= SDL_NumJoysticks()) {
-            printf("%i is an invalid joystick index.\n", device);
+			SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%i is an invalid joystick index.\n", device);
             retcode = 1;
         } else {
             SDL_JoystickGetGUIDString(SDL_JoystickGetDeviceGUID(device),
                                       guid, sizeof (guid));
-            printf("Attempting to open device %i, guid %s\n", device, guid);
+            SDL_Log("Attempting to open device %i, guid %s\n", device, guid);
             gamecontroller = SDL_GameControllerOpen(device);
             if (gamecontroller == NULL) {
-                printf("Couldn't open joystick %d: %s\n", device, SDL_GetError());
+                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open joystick %d: %s\n", device, SDL_GetError());
                 retcode = 1;
             } else {
                 WatchGameController(gamecontroller);
@@ -272,7 +275,7 @@
 int
 main(int argc, char *argv[])
 {
-    fprintf(stderr, "SDL compiled without Joystick support.\n");
+    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Joystick support.\n");
     exit(1);
 }
 
--- a/test/testgesture.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testgesture.c	Wed Aug 14 23:30:10 2013 -0700
@@ -207,6 +207,9 @@
   SDL_bool quitting = SDL_FALSE;
   SDL_RWops *src;
 
+  /* Enable standard application logging */
+  SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
   //gesture variables
   knob.r = .1f;
   knob.ang = 0;
--- a/test/testgl2.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testgl2.c	Wed Aug 14 23:30:10 2013 -0700
@@ -181,6 +181,9 @@
     Uint32 then, now, frames;
     int status;
 
+    /* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     /* Initialize parameters */
     fsaa = 0;
     accel = -1;
@@ -206,7 +209,7 @@
             }
         }
         if (consumed < 0) {
-            fprintf(stderr, "Usage: %s %s [--fsaa n] [--accel n]\n", argv[0],
+            SDL_Log("Usage: %s %s [--fsaa n] [--accel n]\n", argv[0],
                     SDLTest_CommonUsage(state));
             quit(1);
         }
@@ -235,7 +238,7 @@
     /* Create OpenGL context */
     context = SDL_GL_CreateContext(state->windows[0]);
     if (!context) {
-        fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
         quit(2);
     }
 
@@ -249,63 +252,63 @@
     }
 
     SDL_GetCurrentDisplayMode(0, &mode);
-    printf("Screen BPP    : %d\n", SDL_BITSPERPIXEL(mode.format));
-    printf("Swap Interval : %d\n", SDL_GL_GetSwapInterval());
-    printf("\n");
-    printf("Vendor        : %s\n", glGetString(GL_VENDOR));
-    printf("Renderer      : %s\n", glGetString(GL_RENDERER));
-    printf("Version       : %s\n", glGetString(GL_VERSION));
-    printf("Extensions    : %s\n", glGetString(GL_EXTENSIONS));
-    printf("\n");
+    SDL_Log("Screen BPP    : %d\n", SDL_BITSPERPIXEL(mode.format));
+    SDL_Log("Swap Interval : %d\n", SDL_GL_GetSwapInterval());
+    SDL_Log("\n");
+    SDL_Log("Vendor        : %s\n", glGetString(GL_VENDOR));
+    SDL_Log("Renderer      : %s\n", glGetString(GL_RENDERER));
+    SDL_Log("Version       : %s\n", glGetString(GL_VERSION));
+    SDL_Log("Extensions    : %s\n", glGetString(GL_EXTENSIONS));
+    SDL_Log("\n");
 
     status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
     if (!status) {
-        printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
+        SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
     } else {
-        printf("Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError());
     }
     status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
     if (!status) {
-        printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
+        SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
     } else {
-        printf("Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError());
     }
     status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
     if (!status) {
-        printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
+        SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
     } else {
-        printf("Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError());
     }
     status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
     if (!status) {
-        printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value);
+        SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value);
     } else {
-        printf("Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError());
     }
     if (fsaa) {
         status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
         if (!status) {
-            printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
+            SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
         } else {
-            printf("Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
                    SDL_GetError());
         }
         status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
         if (!status) {
-            printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
+            SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
                    value);
         } else {
-            printf("Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
                    SDL_GetError());
         }
     }
     if (accel >= 0) {
         status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
         if (!status) {
-            printf("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel,
+            SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel,
                    value);
         } else {
-            printf("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
+			SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
                    SDL_GetError());
         }
     }
@@ -343,7 +346,7 @@
     /* Print out some timing information */
     now = SDL_GetTicks();
     if (now > then) {
-        printf("%2.2f frames per second\n",
+        SDL_Log("%2.2f frames per second\n",
                ((double) frames * 1000) / (now - then));
     }
     quit(0);
@@ -355,7 +358,7 @@
 int
 main(int argc, char *argv[])
 {
-    printf("No OpenGL support on this system\n");
+    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system\n");
     return 1;
 }
 
--- a/test/testgles.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testgles.c	Wed Aug 14 23:30:10 2013 -0700
@@ -110,6 +110,9 @@
     Uint32 then, now, frames;
     int status;
 
+    /* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     /* Initialize parameters */
     fsaa = 0;
     accel = 0;
@@ -143,7 +146,7 @@
             }
         }
         if (consumed < 0) {
-            fprintf(stderr, "Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0],
+            SDL_Log("Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0],
                     SDLTest_CommonUsage(state));
             quit(1);
         }
@@ -169,7 +172,7 @@
 
     context = SDL_calloc(state->num_windows, sizeof(context));
     if (context == NULL) {
-        fprintf(stderr, "Out of memory!\n");
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
         quit(2);
     }
 
@@ -177,7 +180,7 @@
     for (i = 0; i < state->num_windows; i++) {
         context[i] = SDL_GL_CreateContext(state->windows[i]);
         if (!context[i]) {
-            fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
             quit(2);
         }
     }
@@ -189,65 +192,65 @@
     }
 
     SDL_GetCurrentDisplayMode(0, &mode);
-    printf("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
-    printf("\n");
-    printf("Vendor     : %s\n", glGetString(GL_VENDOR));
-    printf("Renderer   : %s\n", glGetString(GL_RENDERER));
-    printf("Version    : %s\n", glGetString(GL_VERSION));
-    printf("Extensions : %s\n", glGetString(GL_EXTENSIONS));
-    printf("\n");
+    SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
+    SDL_Log("\n");
+    SDL_Log("Vendor     : %s\n", glGetString(GL_VENDOR));
+    SDL_Log("Renderer   : %s\n", glGetString(GL_RENDERER));
+    SDL_Log("Version    : %s\n", glGetString(GL_VERSION));
+    SDL_Log("Extensions : %s\n", glGetString(GL_EXTENSIONS));
+    SDL_Log("\n");
 
     status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
     if (!status) {
-        printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
+        SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
     } else {
-        fprintf(stderr, "Failed to get SDL_GL_RED_SIZE: %s\n",
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n",
                 SDL_GetError());
     }
     status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
     if (!status) {
-        printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
+        SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
     } else {
-        fprintf(stderr, "Failed to get SDL_GL_GREEN_SIZE: %s\n",
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n",
                 SDL_GetError());
     }
     status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
     if (!status) {
-        printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
+        SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
     } else {
-        fprintf(stderr, "Failed to get SDL_GL_BLUE_SIZE: %s\n",
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n",
                 SDL_GetError());
     }
     status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
     if (!status) {
-        printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
+        SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
     } else {
-        fprintf(stderr, "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
                 SDL_GetError());
     }
     if (fsaa) {
         status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
         if (!status) {
-            printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
+            SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
         } else {
-            fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
                     SDL_GetError());
         }
         status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
         if (!status) {
-            printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
+            SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
                    value);
         } else {
-            fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
                     SDL_GetError());
         }
     }
     if (accel) {
         status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
         if (!status) {
-            printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
+            SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
         } else {
-            fprintf(stderr, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
                     SDL_GetError());
         }
     }
@@ -258,7 +261,7 @@
 
         status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
         if (status) {
-            printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
+            SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
 
             /* Continue for next window */
             continue;
@@ -292,7 +295,7 @@
                             if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
                                 status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
                                 if (status) {
-                                    printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
+                                    SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
                                     break;
                                 }
                                 /* Change view port to the new window dimensions */
@@ -311,7 +314,7 @@
         for (i = 0; i < state->num_windows; ++i) {
             status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
             if (status) {
-                printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
+                SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
 
                 /* Continue for next window */
                 continue;
@@ -324,7 +327,7 @@
     /* Print out some timing information */
     now = SDL_GetTicks();
     if (now > then) {
-        printf("%2.2f frames per second\n",
+        SDL_Log("%2.2f frames per second\n",
                ((double) frames * 1000) / (now - then));
     }
     quit(0);
@@ -336,7 +339,7 @@
 int
 main(int argc, char *argv[])
 {
-    printf("No OpenGL ES support on this system\n");
+    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL ES support on this system\n");
     return 1;
 }
 
--- a/test/testhaptic.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testhaptic.c	Wed Aug 14 23:30:10 2013 -0700
@@ -26,7 +26,6 @@
  * includes
  */
 #include <stdlib.h>
-#include <stdio.h>              /* printf */
 #include <string.h>             /* strstr */
 #include <ctype.h>              /* isdigit */
 
@@ -62,12 +61,15 @@
     int nefx;
     unsigned int supported;
 
+    /* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     name = NULL;
     index = -1;
     if (argc > 1) {
         name = argv[1];
         if ((strcmp(name, "--help") == 0) || (strcmp(name, "-h") == 0)) {
-            printf("USAGE: %s [device]\n"
+            SDL_Log("USAGE: %s [device]\n"
                    "If device is a two-digit number it'll use it as an index, otherwise\n"
                    "it'll use it as if it were part of the device's name.\n",
                    argv[0]);
@@ -84,7 +86,7 @@
     /* Initialize the force feedbackness */
     SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK |
              SDL_INIT_HAPTIC);
-    printf("%d Haptic devices detected.\n", SDL_NumHaptics());
+    SDL_Log("%d Haptic devices detected.\n", SDL_NumHaptics());
     if (SDL_NumHaptics() > 0) {
         /* We'll just use index or the first force feedback device found */
         if (name == NULL) {
@@ -98,7 +100,7 @@
             }
 
             if (i >= SDL_NumHaptics()) {
-                printf("Unable to find device matching '%s', aborting.\n",
+                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find device matching '%s', aborting.\n",
                        name);
                 return 1;
             }
@@ -106,14 +108,14 @@
 
         haptic = SDL_HapticOpen(i);
         if (haptic == NULL) {
-            printf("Unable to create the haptic device: %s\n",
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n",
                    SDL_GetError());
             return 1;
         }
-        printf("Device: %s\n", SDL_HapticName(i));
+        SDL_Log("Device: %s\n", SDL_HapticName(i));
         HapticPrintSupported(haptic);
     } else {
-        printf("No Haptic devices found!\n");
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No Haptic devices found!\n");
         return 1;
     }
 
@@ -125,10 +127,10 @@
     nefx = 0;
     supported = SDL_HapticQuery(haptic);
 
-    printf("\nUploading effects\n");
+    SDL_Log("\nUploading effects\n");
     /* First we'll try a SINE effect. */
     if (supported & SDL_HAPTIC_SINE) {
-        printf("   effect %d: Sine Wave\n", nefx);
+        SDL_Log("   effect %d: Sine Wave\n", nefx);
         efx[nefx].type = SDL_HAPTIC_SINE;
         efx[nefx].periodic.period = 1000;
         efx[nefx].periodic.magnitude = 0x4000;
@@ -137,14 +139,14 @@
         efx[nefx].periodic.fade_length = 1000;
         id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
         if (id[nefx] < 0) {
-            printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
             abort_execution();
         }
         nefx++;
     }
     /* Now we'll try a SAWTOOTHUP */
     if (supported & SDL_HAPTIC_SAWTOOTHUP) {
-        printf("   effect %d: Sawtooth Up\n", nefx);
+        SDL_Log("   effect %d: Sawtooth Up\n", nefx);
         efx[nefx].type = SDL_HAPTIC_SAWTOOTHUP;
         efx[nefx].periodic.period = 500;
         efx[nefx].periodic.magnitude = 0x5000;
@@ -153,14 +155,14 @@
         efx[nefx].periodic.fade_length = 1000;
         id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
         if (id[nefx] < 0) {
-            printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
             abort_execution();
         }
         nefx++;
     }
     /* Now the classical constant effect. */
     if (supported & SDL_HAPTIC_CONSTANT) {
-        printf("   effect %d: Constant Force\n", nefx);
+        SDL_Log("   effect %d: Constant Force\n", nefx);
         efx[nefx].type = SDL_HAPTIC_CONSTANT;
         efx[nefx].constant.direction.type = SDL_HAPTIC_POLAR;
         efx[nefx].constant.direction.dir[0] = 20000;    /* Force comes from the south-west. */
@@ -170,14 +172,14 @@
         efx[nefx].constant.fade_length = 1000;
         id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
         if (id[nefx] < 0) {
-            printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
             abort_execution();
         }
         nefx++;
     }
     /* The cute spring effect. */
     if (supported & SDL_HAPTIC_SPRING) {
-        printf("   effect %d: Condition Spring\n", nefx);
+        SDL_Log("   effect %d: Condition Spring\n", nefx);
         efx[nefx].type = SDL_HAPTIC_SPRING;
         efx[nefx].condition.length = 5000;
         for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
@@ -189,14 +191,14 @@
         }
         id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
         if (id[nefx] < 0) {
-            printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
             abort_execution();
         }
         nefx++;
     }
     /* The pretty awesome inertia effect. */
     if (supported & SDL_HAPTIC_INERTIA) {
-        printf("   effect %d: Condition Inertia\n", nefx);
+        SDL_Log("   effect %d: Condition Inertia\n", nefx);
         efx[nefx].type = SDL_HAPTIC_SPRING;
         efx[nefx].condition.length = 5000;
         for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
@@ -207,7 +209,7 @@
         }
         id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
         if (id[nefx] < 0) {
-            printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
             abort_execution();
         }
         nefx++;
@@ -215,24 +217,24 @@
 
     /* Finally we'll try a left/right effect. */
     if (supported & SDL_HAPTIC_LEFTRIGHT) {
-        printf("   effect %d: Left/Right\n", nefx);
+        SDL_Log("   effect %d: Left/Right\n", nefx);
         efx[nefx].type = SDL_HAPTIC_LEFTRIGHT;
         efx[nefx].leftright.length = 5000;
         efx[nefx].leftright.large_magnitude = 0x3000;
         efx[nefx].leftright.small_magnitude = 0xFFFF;
         id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
         if (id[nefx] < 0) {
-            printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
             abort_execution();
         }
         nefx++;
     }
 
 
-    printf
+    SDL_Log
         ("\nNow playing effects for 5 seconds each with 1 second delay between\n");
     for (i = 0; i < nefx; i++) {
-        printf("   Playing effect %d\n", i);
+        SDL_Log("   Playing effect %d\n", i);
         SDL_HapticRunEffect(haptic, id[i], 1);
         SDL_Delay(6000);        /* Effects only have length 5000 */
     }
@@ -252,7 +254,7 @@
 static void
 abort_execution(void)
 {
-    printf("\nAborting program execution.\n");
+    SDL_Log("\nAborting program execution.\n");
 
     SDL_HapticClose(haptic);
     SDL_Quit();
@@ -270,42 +272,42 @@
     unsigned int supported;
 
     supported = SDL_HapticQuery(haptic);
-    printf("   Supported effects [%d effects, %d playing]:\n",
+    SDL_Log("   Supported effects [%d effects, %d playing]:\n",
            SDL_HapticNumEffects(haptic), SDL_HapticNumEffectsPlaying(haptic));
     if (supported & SDL_HAPTIC_CONSTANT)
-        printf("      constant\n");
+        SDL_Log("      constant\n");
     if (supported & SDL_HAPTIC_SINE)
-        printf("      sine\n");
+        SDL_Log("      sine\n");
     /* !!! FIXME: put this back when we have more bits in 2.1 */
     /*if (supported & SDL_HAPTIC_SQUARE)
-        printf("      square\n");*/
+        SDL_Log("      square\n");*/
     if (supported & SDL_HAPTIC_TRIANGLE)
-        printf("      triangle\n");
+        SDL_Log("      triangle\n");
     if (supported & SDL_HAPTIC_SAWTOOTHUP)
-        printf("      sawtoothup\n");
+        SDL_Log("      sawtoothup\n");
     if (supported & SDL_HAPTIC_SAWTOOTHDOWN)
-        printf("      sawtoothdown\n");
+        SDL_Log("      sawtoothdown\n");
     if (supported & SDL_HAPTIC_RAMP)
-        printf("      ramp\n");
+        SDL_Log("      ramp\n");
     if (supported & SDL_HAPTIC_FRICTION)
-        printf("      friction\n");
+        SDL_Log("      friction\n");
     if (supported & SDL_HAPTIC_SPRING)
-        printf("      spring\n");
+        SDL_Log("      spring\n");
     if (supported & SDL_HAPTIC_DAMPER)
-        printf("      damper\n");
+        SDL_Log("      damper\n");
     if (supported & SDL_HAPTIC_INERTIA)
-        printf("      intertia\n");
+        SDL_Log("      inertia\n");
     if (supported & SDL_HAPTIC_CUSTOM)
-        printf("      custom\n");
+        SDL_Log("      custom\n");
     if (supported & SDL_HAPTIC_LEFTRIGHT)
-        printf("      left/right\n");
-    printf("   Supported capabilities:\n");
+        SDL_Log("      left/right\n");
+    SDL_Log("   Supported capabilities:\n");
     if (supported & SDL_HAPTIC_GAIN)
-        printf("      gain\n");
+        SDL_Log("      gain\n");
     if (supported & SDL_HAPTIC_AUTOCENTER)
-        printf("      autocenter\n");
+        SDL_Log("      autocenter\n");
     if (supported & SDL_HAPTIC_STATUS)
-        printf("      status\n");
+        SDL_Log("      status\n");
 }
 
 #else
@@ -313,7 +315,7 @@
 int
 main(int argc, char *argv[])
 {
-    fprintf(stderr, "SDL compiled without Haptic support.\n");
+    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Haptic support.\n");
     exit(1);
 }
 
--- a/test/testiconv.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testiconv.c	Wed Aug 14 23:30:10 2013 -0700
@@ -49,12 +49,15 @@
     FILE *file;
     int errors = 0;
 
+    /* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     if (!argv[1]) {
         argv[1] = "utf8.txt";
     }
     file = fopen(argv[1], "rb");
     if (!file) {
-        fprintf(stderr, "Unable to open %s\n", argv[1]);
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to open %s\n", argv[1]);
         return (1);
     }
 
@@ -69,7 +72,7 @@
             test[0] = SDL_iconv_string(formats[i], "UCS-4", ucs4, len);
             test[1] = SDL_iconv_string("UCS-4", formats[i], test[0], len);
             if (!test[1] || SDL_memcmp(test[1], ucs4, len) != 0) {
-                fprintf(stderr, "FAIL: %s\n", formats[i]);
+                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "FAIL: %s\n", formats[i]);
                 ++errors;
             }
             if (test[0]) {
--- a/test/testime.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testime.c	Wed Aug 14 23:30:10 2013 -0700
@@ -80,7 +80,7 @@
 
 void usage()
 {
-    printf("usage: testime [--font fontfile]\n");
+    SDL_Log("usage: testime [--font fontfile]\n");
     exit(0);
 }
 
@@ -210,6 +210,9 @@
     SDL_Event event;
     const char *fontname = DEFAULT_FONT;
 
+    /* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     /* Initialize test framework */
     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
     if (!state) {
@@ -251,12 +254,12 @@
     font = TTF_OpenFont(fontname, DEFAULT_PTSIZE);
     if (! font)
     {
-        fprintf(stderr, "Failed to find font: %s\n", TTF_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to find font: %s\n", TTF_GetError());
         exit(-1);
     }
 #endif
 
-    printf("Using font: %s\n", fontname);
+    SDL_Log("Using font: %s\n", fontname);
     atexit(SDL_Quit);
 
     InitInput();
@@ -321,8 +324,7 @@
                         break;
                     }
 
-                    fprintf(stderr,
-                            "Keyboard: scancode 0x%08X = %s, keycode 0x%08X = %s\n",
+                    SDL_Log("Keyboard: scancode 0x%08X = %s, keycode 0x%08X = %s\n",
                             event.key.keysym.scancode,
                             SDL_GetScancodeName(event.key.keysym.scancode),
                             event.key.keysym.sym, SDL_GetKeyName(event.key.keysym.sym));
@@ -333,12 +335,12 @@
                         markedRect.w < 0)
                         break;
 
-                    fprintf(stderr, "Keyboard: text input \"%s\"\n", event.text.text);
+                    SDL_Log("Keyboard: text input \"%s\"\n", event.text.text);
 
                     if (SDL_strlen(text) + SDL_strlen(event.text.text) < sizeof(text))
                         SDL_strlcat(text, event.text.text, sizeof(text));
 
-                    fprintf(stderr, "text inputed: %s\n", text);
+                    SDL_Log("text inputed: %s\n", text);
 
                     // After text inputed, we can clear up markedText because it
                     // is committed
@@ -347,7 +349,7 @@
                     break;
 
                 case SDL_TEXTEDITING:
-                    fprintf(stderr, "text editing \"%s\", selected range (%d, %d)\n",
+                    SDL_Log("text editing \"%s\", selected range (%d, %d)\n",
                             event.edit.text, event.edit.start, event.edit.length);
 
                     strcpy(markedText, event.edit.text);
--- a/test/testintersections.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testintersections.c	Wed Aug 14 23:30:10 2013 -0700
@@ -84,7 +84,7 @@
     if ((x1 == x2) && (y1 == y2))
         return 0;
 
-    printf("adding line (%d, %d), (%d, %d)\n", x1, y1, x2, y2);
+    SDL_Log("adding line (%d, %d), (%d, %d)\n", x1, y1, x2, y2);
     lines[num_lines].x = x1;
     lines[num_lines].y = y1;
     lines[num_lines].w = x2;
@@ -133,7 +133,7 @@
     if (y1 > y2)
         SWAP(int, y1, y2);
 
-    printf("adding rect (%d, %d), (%d, %d) [%dx%d]\n", x1, y1, x2, y2,
+    SDL_Log("adding rect (%d, %d), (%d, %d) [%dx%d]\n", x1, y1, x2, y2,
            x2 - x1, y2 - y1);
 
     rects[num_rects].x = x1;
@@ -199,6 +199,9 @@
     SDL_Event event;
     Uint32 then, now, frames;
 
+    /* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     /* Initialize parameters */
     num_objects = NUM_OBJECTS;
 
@@ -241,8 +244,7 @@
             }
         }
         if (consumed < 0) {
-            fprintf(stderr,
-                    "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
+            SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
                     argv[0], SDLTest_CommonUsage(state));
             return 1;
         }
@@ -327,7 +329,7 @@
     now = SDL_GetTicks();
     if (now > then) {
         double fps = ((double) frames * 1000) / (now - then);
-        printf("%2.2f frames per second\n", fps);
+        SDL_Log("%2.2f frames per second\n", fps);
     }
     return 0;
 }
--- a/test/testjoystick.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testjoystick.c	Wed Aug 14 23:30:10 2013 -0700
@@ -52,13 +52,13 @@
                               SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH,
                               SCREEN_HEIGHT, 0);
     if (window == NULL) {
-        fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
         return SDL_FALSE;
     }
 
     screen = SDL_CreateRenderer(window, -1, 0);
     if (screen == NULL) {
-        fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
         SDL_DestroyWindow(window);
         return SDL_FALSE;
     }
@@ -70,9 +70,9 @@
 
     /* Print info about the joystick we are watching */
     name = SDL_JoystickName(joystick);
-    printf("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick),
+    SDL_Log("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick),
            name ? name : "Unknown Joystick");
-    printf("Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
+    SDL_Log("Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
            SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick),
            SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick));
 
@@ -85,36 +85,36 @@
         while (SDL_PollEvent(&event)) {
             switch (event.type) {
             case SDL_JOYAXISMOTION:
-                printf("Joystick %d axis %d value: %d\n",
+                SDL_Log("Joystick %d axis %d value: %d\n",
                        event.jaxis.which,
                        event.jaxis.axis, event.jaxis.value);
                 break;
             case SDL_JOYHATMOTION:
-                printf("Joystick %d hat %d value:",
+                SDL_Log("Joystick %d hat %d value:",
                        event.jhat.which, event.jhat.hat);
                 if (event.jhat.value == SDL_HAT_CENTERED)
-                    printf(" centered");
+                    SDL_Log(" centered");
                 if (event.jhat.value & SDL_HAT_UP)
-                    printf(" up");
+                    SDL_Log(" up");
                 if (event.jhat.value & SDL_HAT_RIGHT)
-                    printf(" right");
+                    SDL_Log(" right");
                 if (event.jhat.value & SDL_HAT_DOWN)
-                    printf(" down");
+                    SDL_Log(" down");
                 if (event.jhat.value & SDL_HAT_LEFT)
-                    printf(" left");
-                printf("\n");
+                    SDL_Log(" left");
+                SDL_Log("\n");
                 break;
             case SDL_JOYBALLMOTION:
-                printf("Joystick %d ball %d delta: (%d,%d)\n",
+                SDL_Log("Joystick %d ball %d delta: (%d,%d)\n",
                        event.jball.which,
                        event.jball.ball, event.jball.xrel, event.jball.yrel);
                 break;
             case SDL_JOYBUTTONDOWN:
-                printf("Joystick %d button %d down\n",
+                SDL_Log("Joystick %d button %d down\n",
                        event.jbutton.which, event.jbutton.button);
                 break;
             case SDL_JOYBUTTONUP:
-                printf("Joystick %d button %d up\n",
+                SDL_Log("Joystick %d button %d up\n",
                        event.jbutton.which, event.jbutton.button);
                 break;
             case SDL_KEYDOWN:
@@ -211,31 +211,34 @@
     int i;
     SDL_Joystick *joystick;
 
+    /* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);	
+
     /* Initialize SDL (Note: video is required to start event loop) */
     if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) {
-        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         exit(1);
     }
 
     /* Print information about the joysticks */
-    printf("There are %d joysticks attached\n", SDL_NumJoysticks());
+    SDL_Log("There are %d joysticks attached\n", SDL_NumJoysticks());
     for (i = 0; i < SDL_NumJoysticks(); ++i) {
         name = SDL_JoystickNameForIndex(i);
-        printf("Joystick %d: %s\n", i, name ? name : "Unknown Joystick");
+        SDL_Log("Joystick %d: %s\n", i, name ? name : "Unknown Joystick");
         joystick = SDL_JoystickOpen(i);
         if (joystick == NULL) {
-            fprintf(stderr, "SDL_JoystickOpen(%d) failed: %s\n", i,
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_JoystickOpen(%d) failed: %s\n", i,
                     SDL_GetError());
         } else {
             char guid[64];
             SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick),
                                       guid, sizeof (guid));
-            printf("       axes: %d\n", SDL_JoystickNumAxes(joystick));
-            printf("      balls: %d\n", SDL_JoystickNumBalls(joystick));
-            printf("       hats: %d\n", SDL_JoystickNumHats(joystick));
-            printf("    buttons: %d\n", SDL_JoystickNumButtons(joystick));
-            printf("instance id: %d\n", SDL_JoystickInstanceID(joystick));
-            printf("       guid: %s\n", guid);
+            SDL_Log("       axes: %d\n", SDL_JoystickNumAxes(joystick));
+            SDL_Log("      balls: %d\n", SDL_JoystickNumBalls(joystick));
+            SDL_Log("       hats: %d\n", SDL_JoystickNumHats(joystick));
+            SDL_Log("    buttons: %d\n", SDL_JoystickNumButtons(joystick));
+            SDL_Log("instance id: %d\n", SDL_JoystickInstanceID(joystick));
+            SDL_Log("       guid: %s\n", guid);
             SDL_JoystickClose(joystick);
         }
     }
@@ -256,7 +259,7 @@
         while ( keepGoing ) {
             if (joystick == NULL) {
                 if ( !reportederror ) {
-                    printf("Couldn't open joystick %d: %s\n", atoi(argv[1]), SDL_GetError());
+                    SDL_Log("Couldn't open joystick %d: %s\n", atoi(argv[1]), SDL_GetError());
                     keepGoing = SDL_FALSE;
                     reportederror = SDL_TRUE;
                 }
@@ -268,7 +271,7 @@
 
             joystick = NULL;
             if (keepGoing) {
-                printf("Waiting for attach\n");
+                SDL_Log("Waiting for attach\n");
             }
             while (keepGoing) {
                 SDL_WaitEvent(&event);
@@ -296,7 +299,7 @@
 int
 main(int argc, char *argv[])
 {
-    fprintf(stderr, "SDL compiled without Joystick support.\n");
+    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Joystick support.\n");
     exit(1);
 }
 
--- a/test/testkeys.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testkeys.c	Wed Aug 14 23:30:10 2013 -0700
@@ -24,12 +24,15 @@
 {
     SDL_Scancode scancode;
 
+    /* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     if (SDL_Init(SDL_INIT_VIDEO) < 0) {
-        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         exit(1);
     }
     for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) {
-        printf("Scancode #%d, \"%s\"\n", scancode,
+        SDL_Log("Scancode #%d, \"%s\"\n", scancode,
                SDL_GetScancodeName(scancode));
     }
     SDL_Quit();
--- a/test/testloadso.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testloadso.c	Wed Aug 14 23:30:10 2013 -0700
@@ -33,14 +33,14 @@
 
     if (argc != 3) {
         const char *app = argv[0];
-        fprintf(stderr, "USAGE: %s <library> <functionname>\n", app);
-        fprintf(stderr, "       %s --hello <lib with puts()>\n", app);
+        SDL_Log("USAGE: %s <library> <functionname>\n", app);
+        SDL_Log("       %s --hello <lib with puts()>\n", app);
         return 1;
     }
 
     /* Initialize SDL */
     if (SDL_Init(0) < 0) {
-        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return 2;
     }
 
@@ -55,23 +55,23 @@
 
     lib = SDL_LoadObject(libname);
     if (lib == NULL) {
-        fprintf(stderr, "SDL_LoadObject('%s') failed: %s\n",
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadObject('%s') failed: %s\n",
                 libname, SDL_GetError());
         retval = 3;
     } else {
         fn = (fntype) SDL_LoadFunction(lib, symname);
         if (fn == NULL) {
-            fprintf(stderr, "SDL_LoadFunction('%s') failed: %s\n",
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadFunction('%s') failed: %s\n",
                     symname, SDL_GetError());
             retval = 4;
         } else {
-            printf("Found %s in %s at %p\n", symname, libname, fn);
+            SDL_Log("Found %s in %s at %p\n", symname, libname, fn);
             if (hello) {
-                printf("Calling function...\n");
+                SDL_Log("Calling function...\n");
                 fflush(stdout);
                 fn("     HELLO, WORLD!\n");
-                printf("...apparently, we survived.  :)\n");
-                printf("Unloading library...\n");
+                SDL_Log("...apparently, we survived.  :)\n");
+                SDL_Log("Unloading library...\n");
                 fflush(stdout);
             }
         }
--- a/test/testlock.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testlock.c	Wed Aug 14 23:30:10 2013 -0700
@@ -40,7 +40,7 @@
 void
 printid(void)
 {
-    printf("Process %lu:  exiting\n", SDL_ThreadID());
+    SDL_Log("Process %lu:  exiting\n", SDL_ThreadID());
 }
 
 void
@@ -55,7 +55,7 @@
 {
     SDL_threadID id = SDL_ThreadID();
     int i;
-    printf("Process %lu:  Cleaning up...\n", id == mainthread ? 0 : id);
+    SDL_Log("Process %lu:  Cleaning up...\n", id == mainthread ? 0 : id);
     doterminate = 1;
     for (i = 0; i < 6; ++i)
         SDL_WaitThread(threads[i], NULL);
@@ -69,23 +69,23 @@
     if (SDL_ThreadID() == mainthread)
         signal(SIGTERM, closemutex);
     while (!doterminate) {
-        printf("Process %lu ready to work\n", SDL_ThreadID());
+        SDL_Log("Process %lu ready to work\n", SDL_ThreadID());
         if (SDL_LockMutex(mutex) < 0) {
-            fprintf(stderr, "Couldn't lock mutex: %s", SDL_GetError());
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock mutex: %s", SDL_GetError());
             exit(1);
         }
-        printf("Process %lu, working!\n", SDL_ThreadID());
+        SDL_Log("Process %lu, working!\n", SDL_ThreadID());
         SDL_Delay(1 * 1000);
-        printf("Process %lu, done!\n", SDL_ThreadID());
+        SDL_Log("Process %lu, done!\n", SDL_ThreadID());
         if (SDL_UnlockMutex(mutex) < 0) {
-            fprintf(stderr, "Couldn't unlock mutex: %s", SDL_GetError());
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't unlock mutex: %s", SDL_GetError());
             exit(1);
         }
         /* If this sleep isn't done, then threads may starve */
         SDL_Delay(10);
     }
     if (SDL_ThreadID() == mainthread && doterminate) {
-        printf("Process %lu:  raising SIGTERM\n", SDL_ThreadID());
+        SDL_Log("Process %lu:  raising SIGTERM\n", SDL_ThreadID());
         raise(SIGTERM);
     }
     return (0);
@@ -97,26 +97,29 @@
     int i;
     int maxproc = 6;
 
+	/* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     /* Load the SDL library */
     if (SDL_Init(0) < 0) {
-        fprintf(stderr, "%s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
         exit(1);
     }
     atexit(SDL_Quit_Wrapper);
 
     if ((mutex = SDL_CreateMutex()) == NULL) {
-        fprintf(stderr, "Couldn't create mutex: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create mutex: %s\n", SDL_GetError());
         exit(1);
     }
 
     mainthread = SDL_ThreadID();
-    printf("Main thread: %lu\n", mainthread);
+    SDL_Log("Main thread: %lu\n", mainthread);
     atexit(printid);
     for (i = 0; i < maxproc; ++i) {
         char name[64];
         SDL_snprintf(name, sizeof (name), "Worker%d", i);
         if ((threads[i] = SDL_CreateThread(Run, name, NULL)) == NULL)
-            fprintf(stderr, "Couldn't create thread!\n");
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread!\n");
     }
     signal(SIGINT, terminate);
     Run(NULL);
--- a/test/testmessage.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testmessage.c	Wed Aug 14 23:30:10 2013 -0700
@@ -62,7 +62,7 @@
 
     success = SDL_ShowMessageBox(&data, &button);
     if (success == -1) {
-        printf("Error Presenting MessageBox: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
         if (eventNumber) {
             SDL_UserEvent event;
             event.type = (intptr_t)eventNumber;
@@ -72,7 +72,7 @@
             quit(2);
         }
     }
-    printf("Pressed button: %d, %s\n", button, button == 1 ? "Cancel" : "OK");
+    SDL_Log("Pressed button: %d, %s\n", button, button == 1 ? "Cancel" : "OK");
 
     if (eventNumber) {
         SDL_UserEvent event;
@@ -88,12 +88,15 @@
 {
     int success;
 
+	/* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
                 "Simple MessageBox",
                 "This is a simple error MessageBox",
                 NULL);
     if (success == -1) {
-        printf("Error Presenting MessageBox: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
         quit(1);
     }
 
@@ -102,7 +105,7 @@
                 "This is a simple MessageBox with a newline:\r\nHello world!",
                 NULL);
     if (success == -1) {
-        printf("Error Presenting MessageBox: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
         quit(1);
     }
 
@@ -112,7 +115,7 @@
                 "Unicode text: '牛肉西蘭花' ...",
                 NULL);
     if (success == -1) {
-        printf("Error Presenting MessageBox: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
         quit(1);
     }
 
@@ -122,7 +125,7 @@
                 "Unicode text and newline:\r\n'牛肉西蘭花'\n'牛肉西蘭花'",
                 NULL);
     if (success == -1) {
-        printf("Error Presenting MessageBox: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
         quit(1);
     }
 
@@ -135,7 +138,7 @@
        subsystem on the main thread.
      */
     if (SDL_Init(SDL_INIT_VIDEO) < 0) {
-        fprintf(stderr, "Couldn't initialize SDL video subsystem: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video subsystem: %s\n", SDL_GetError());
         return (1);
     }
     {
@@ -153,7 +156,7 @@
 
         SDL_WaitThread(thread, &status);
 
-        printf("Message box thread return %i\n", status);
+        SDL_Log("Message box thread return %i\n", status);
     }
 
     /* Test showing a message box with a parent window */
@@ -166,7 +169,7 @@
                     "This is a simple error MessageBox with a parent window",
                     window);
         if (success == -1) {
-            printf("Error Presenting MessageBox: %s\n", SDL_GetError());
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
             quit(1);
         }
 
--- a/test/testmultiaudio.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testmultiaudio.c	Wed Aug 14 23:30:10 2013 -0700
@@ -10,7 +10,6 @@
   freely.
 */
 #include "SDL.h"
-#include <stdio.h>
 
 static SDL_AudioSpec spec;
 static Uint8 *sound = NULL;     /* Pointer to wave data */
@@ -51,7 +50,7 @@
     int i;
 
     if (devcount > 64) {
-        fprintf(stderr, "Too many devices (%d), clamping to 64...\n",
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Too many devices (%d), clamping to 64...\n",
                 devcount);
         devcount = 64;
     }
@@ -60,33 +59,33 @@
 
     for (i = 0; i < devcount; i++) {
         const char *devname = SDL_GetAudioDeviceName(i, 0);
-        printf("playing on device #%d: ('%s')...", i, devname);
+        SDL_Log("playing on device #%d: ('%s')...", i, devname);
         fflush(stdout);
 
         SDL_memset(&cbd[0], '\0', sizeof(callback_data));
         spec.userdata = &cbd[0];
         cbd[0].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL, 0);
         if (cbd[0].dev == 0) {
-            printf("\nOpen device failed: %s\n", SDL_GetError());
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device failed: %s\n", SDL_GetError());
         } else {
             SDL_PauseAudioDevice(cbd[0].dev, 0);
             while (!cbd[0].done)
                 SDL_Delay(100);
             SDL_PauseAudioDevice(cbd[0].dev, 1);
-            printf("done.\n");
+            SDL_Log("done.\n");
             SDL_CloseAudioDevice(cbd[0].dev);
         }
     }
 
     SDL_memset(cbd, '\0', sizeof(cbd));
 
-    printf("playing on all devices...\n");
+    SDL_Log("playing on all devices...\n");
     for (i = 0; i < devcount; i++) {
         const char *devname = SDL_GetAudioDeviceName(i, 0);
         spec.userdata = &cbd[i];
         cbd[i].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL, 0);
         if (cbd[i].dev == 0) {
-            printf("Open device %d failed: %s\n", i, SDL_GetError());
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device %d failed: %s\n", i, SDL_GetError());
         }
     }
 
@@ -113,7 +112,7 @@
         }
     }
 
-    printf("All done!\n");
+    SDL_Log("All done!\n");
 }
 
 
@@ -122,17 +121,20 @@
 {
     int devcount = 0;
 
+	/* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     /* Load the SDL library */
     if (SDL_Init(SDL_INIT_AUDIO) < 0) {
-        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return (1);
     }
 
-    printf("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
+    SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
 
     devcount = SDL_GetNumAudioDevices(0);
     if (devcount < 1) {
-        fprintf(stderr, "Don't see any specific audio devices!\n");
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Don't see any specific audio devices!\n");
     } else {
         if (argv[1] == NULL) {
             argv[1] = "sample.wav";
@@ -140,7 +142,7 @@
 
         /* Load the wave file into memory */
         if (SDL_LoadWAV(argv[1], &spec, &sound, &soundlen) == NULL) {
-            fprintf(stderr, "Couldn't load %s: %s\n", argv[1],
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", argv[1],
                     SDL_GetError());
         } else {
             test_multi_audio(devcount);
--- a/test/testnative.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testnative.c	Wed Aug 14 23:30:10 2013 -0700
@@ -58,7 +58,7 @@
     /* Load the sprite image */
     temp = SDL_LoadBMP(file);
     if (temp == NULL) {
-        fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
         return 0;
     }
 
@@ -70,7 +70,7 @@
     /* Create textures from the image */
     sprite = SDL_CreateTextureFromSurface(renderer, temp);
     if (!sprite) {
-        fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
         SDL_FreeSurface(temp);
         return 0;
     }
@@ -131,8 +131,11 @@
     int sprite_w, sprite_h;
     SDL_Event event;
 
+	/* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     if (SDL_VideoInit(NULL) < 0) {
-        fprintf(stderr, "Couldn't initialize SDL video: %s\n",
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video: %s\n",
                 SDL_GetError());
         exit(1);
     }
@@ -146,19 +149,19 @@
         }
     }
     if (!factory) {
-        fprintf(stderr, "Couldn't find native window code for %s driver\n",
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find native window code for %s driver\n",
                 driver);
         quit(2);
     }
-    printf("Creating native window for %s driver\n", driver);
+    SDL_Log("Creating native window for %s driver\n", driver);
     native_window = factory->CreateNativeWindow(WINDOW_W, WINDOW_H);
     if (!native_window) {
-        fprintf(stderr, "Couldn't create native window\n");
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create native window\n");
         quit(3);
     }
     window = SDL_CreateWindowFrom(native_window);
     if (!window) {
-        fprintf(stderr, "Couldn't create SDL window: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create SDL window: %s\n", SDL_GetError());
         quit(4);
     }
     SDL_SetWindowTitle(window, "SDL Native Window Test");
@@ -166,7 +169,7 @@
     /* Create the renderer */
     renderer = SDL_CreateRenderer(window, -1, 0);
     if (!renderer) {
-        fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
         quit(5);
     }
 
@@ -185,7 +188,7 @@
     positions = (SDL_Rect *) SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect));
     velocities = (SDL_Rect *) SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect));
     if (!positions || !velocities) {
-        fprintf(stderr, "Out of memory!\n");
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
         quit(2);
     }
     srand(time(NULL));
--- a/test/testoverlay2.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testoverlay2.c	Wed Aug 14 23:30:10 2013 -0700
@@ -209,19 +209,18 @@
 static void
 PrintUsage(char *argv0)
 {
-    fprintf(stderr, "Usage: %s [arg] [arg] [arg] ...\n", argv0);
-    fprintf(stderr, "\n");
-    fprintf(stderr, "Where 'arg' is any of the following options:\n");
-    fprintf(stderr, "\n");
-    fprintf(stderr, "    -fps <frames per second>\n");
-    fprintf(stderr, "    -nodelay\n");
-    fprintf(stderr, "    -format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n");
-    fprintf(stderr, "    -scale <scale factor> (initial scale of the overlay)\n");
-    fprintf(stderr, "    -help (shows this help)\n");
-    fprintf(stderr, "\n");
-    fprintf(stderr,
-            "Press ESC to exit, or SPACE to freeze the movie while application running.\n");
-    fprintf(stderr, "\n");
+    SDL_Log("Usage: %s [arg] [arg] [arg] ...\n", argv0);
+    SDL_Log("\n");
+    SDL_Log("Where 'arg' is any of the following options:\n");
+    SDL_Log("\n");
+    SDL_Log("    -fps <frames per second>\n");
+    SDL_Log("    -nodelay\n");
+    SDL_Log("    -format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n");
+    SDL_Log("    -scale <scale factor> (initial scale of the overlay)\n");
+    SDL_Log("    -help (shows this help)\n");
+    SDL_Log("\n");
+    SDL_Log("Press ESC to exit, or SPACE to freeze the movie while application running.\n");
+    SDL_Log("\n");
 }
 
 int
@@ -246,8 +245,11 @@
     int scale = 5;
     SDL_bool done = SDL_FALSE;
 
+    /* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     if (SDL_Init(SDL_INIT_VIDEO) < 0) {
-        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return 3;
     }
 
@@ -256,19 +258,19 @@
             if (argv[2]) {
                 fps = atoi(argv[2]);
                 if (fps == 0) {
-                    fprintf(stderr,
+                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                             "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
                     quit(10);
                 }
                 if ((fps < 0) || (fps > 1000)) {
-                    fprintf(stderr,
+                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                             "The -fps option must be in range from 1 to 1000, default is 12.\n");
                     quit(10);
                 }
                 argv += 2;
                 argc -= 2;
             } else {
-                fprintf(stderr,
+                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                         "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
                 quit(10);
             }
@@ -280,19 +282,19 @@
             if (argv[2]) {
                 scale = atoi(argv[2]);
                 if (scale == 0) {
-                    fprintf(stderr,
+                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                             "The -scale option requires an argument [from 1 to 50], default is 5.\n");
                     quit(10);
                 }
                 if ((scale < 0) || (scale > 50)) {
-                    fprintf(stderr,
+                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                             "The -scale option must be in range from 1 to 50, default is 5.\n");
                     quit(10);
                 }
                 argv += 2;
                 argc -= 2;
             } else {
-                fprintf(stderr,
+                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
                         "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
                 quit(10);
             }
@@ -301,7 +303,7 @@
             PrintUsage(argv[0]);
             quit(0);
         } else {
-            fprintf(stderr, "Unrecognized option: %s.\n", argv[1]);
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unrecognized option: %s.\n", argv[1]);
             quit(10);
         }
         break;
@@ -309,7 +311,7 @@
 
     RawMooseData = (Uint8 *) malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT);
     if (RawMooseData == NULL) {
-        fprintf(stderr, "Can't allocate memory for movie !\n");
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't allocate memory for movie !\n");
         free(RawMooseData);
         quit(1);
     }
@@ -317,7 +319,7 @@
     /* load the trojan moose images */
     handle = SDL_RWFromFile("moose.dat", "rb");
     if (handle == NULL) {
-        fprintf(stderr, "Can't find the file moose.dat !\n");
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
         free(RawMooseData);
         quit(2);
     }
@@ -335,21 +337,21 @@
                               window_w, window_h,
                               SDL_WINDOW_RESIZABLE);
     if (!window) {
-        fprintf(stderr, "Couldn't set create window: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError());
         free(RawMooseData);
         quit(4);
     }
 
     renderer = SDL_CreateRenderer(window, -1, 0);
     if (!renderer) {
-        fprintf(stderr, "Couldn't set create renderer: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError());
         free(RawMooseData);
         quit(4);
     }
 
     MooseTexture = SDL_CreateTexture(renderer, pixel_format, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H);
     if (!MooseTexture) {
-        fprintf(stderr, "Couldn't set create texture: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());
         free(RawMooseData);
         quit(5);
     }
--- a/test/testplatform.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testplatform.c	Wed Aug 14 23:30:10 2013 -0700
@@ -35,30 +35,30 @@
 
     if (badsize(sizeof(Uint8), 1)) {
         if (verbose)
-            printf("sizeof(Uint8) != 1, instead = %u\n",
+            SDL_Log("sizeof(Uint8) != 1, instead = %u\n",
                    (unsigned int)sizeof(Uint8));
         ++error;
     }
     if (badsize(sizeof(Uint16), 2)) {
         if (verbose)
-            printf("sizeof(Uint16) != 2, instead = %u\n",
+            SDL_Log("sizeof(Uint16) != 2, instead = %u\n",
                    (unsigned int)sizeof(Uint16));
         ++error;
     }
     if (badsize(sizeof(Uint32), 4)) {
         if (verbose)
-            printf("sizeof(Uint32) != 4, instead = %u\n",
+            SDL_Log("sizeof(Uint32) != 4, instead = %u\n",
                    (unsigned int)sizeof(Uint32));
         ++error;
     }
     if (badsize(sizeof(Uint64), 8)) {
         if (verbose)
-            printf("sizeof(Uint64) != 8, instead = %u\n",
+            SDL_Log("sizeof(Uint64) != 8, instead = %u\n",
                    (unsigned int)sizeof(Uint64));
         ++error;
     }
     if (verbose && !error)
-        printf("All data types are the expected size.\n");
+        SDL_Log("All data types are the expected size.\n");
 
     return (error ? 1 : 0);
 }
@@ -83,7 +83,7 @@
     swapped64 |= 0xDEADBEEF;
 
     if (verbose) {
-        printf("Detected a %s endian machine.\n",
+        SDL_Log("Detected a %s endian machine.\n",
                (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big");
     }
     if ((*((char *) &value) >> 4) == 0x1) {
@@ -93,44 +93,44 @@
     }
     if (real_byteorder != SDL_BYTEORDER) {
         if (verbose) {
-            printf("Actually a %s endian machine!\n",
+            SDL_Log("Actually a %s endian machine!\n",
                    (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big");
         }
         ++error;
     }
     if (verbose) {
-        printf("Value 16 = 0x%X, swapped = 0x%X\n", value16,
+        SDL_Log("Value 16 = 0x%X, swapped = 0x%X\n", value16,
                SDL_Swap16(value16));
     }
     if (SDL_Swap16(value16) != swapped16) {
         if (verbose) {
-            printf("16 bit value swapped incorrectly!\n");
+            SDL_Log("16 bit value swapped incorrectly!\n");
         }
         ++error;
     }
     if (verbose) {
-        printf("Value 32 = 0x%X, swapped = 0x%X\n", value32,
+        SDL_Log("Value 32 = 0x%X, swapped = 0x%X\n", value32,
                SDL_Swap32(value32));
     }
     if (SDL_Swap32(value32) != swapped32) {
         if (verbose) {
-            printf("32 bit value swapped incorrectly!\n");
+            SDL_Log("32 bit value swapped incorrectly!\n");
         }
         ++error;
     }
     if (verbose) {
 #ifdef _MSC_VER
-        printf("Value 64 = 0x%I64X, swapped = 0x%I64X\n", value64,
+        SDL_Log("Value 64 = 0x%I64X, swapped = 0x%I64X\n", value64,
                SDL_Swap64(value64));
 #else
-        printf("Value 64 = 0x%llX, swapped = 0x%llX\n",
+        SDL_Log("Value 64 = 0x%llX, swapped = 0x%llX\n",
                (unsigned long long) value64,
                (unsigned long long) SDL_Swap64(value64));
 #endif
     }
     if (SDL_Swap64(value64) != swapped64) {
         if (verbose) {
-            printf("64 bit value swapped incorrectly!\n");
+            SDL_Log("64 bit value swapped incorrectly!\n");
         }
         ++error;
     }
@@ -142,17 +142,17 @@
 TestCPUInfo(SDL_bool verbose)
 {
     if (verbose) {
-        printf("CPU count: %d\n", SDL_GetCPUCount());
-        printf("CPU cache line size: %d\n", SDL_GetCPUCacheLineSize());
-        printf("RDTSC %s\n", SDL_HasRDTSC()? "detected" : "not detected");
-        printf("AltiVec %s\n", SDL_HasAltiVec()? "detected" : "not detected");
-        printf("MMX %s\n", SDL_HasMMX()? "detected" : "not detected");
-        printf("3DNow! %s\n", SDL_Has3DNow()? "detected" : "not detected");
-        printf("SSE %s\n", SDL_HasSSE()? "detected" : "not detected");
-        printf("SSE2 %s\n", SDL_HasSSE2()? "detected" : "not detected");
-        printf("SSE3 %s\n", SDL_HasSSE3()? "detected" : "not detected");
-        printf("SSE4.1 %s\n", SDL_HasSSE41()? "detected" : "not detected");
-        printf("SSE4.2 %s\n", SDL_HasSSE42()? "detected" : "not detected");
+        SDL_Log("CPU count: %d\n", SDL_GetCPUCount());
+        SDL_Log("CPU cache line size: %d\n", SDL_GetCPUCacheLineSize());
+        SDL_Log("RDTSC %s\n", SDL_HasRDTSC()? "detected" : "not detected");
+        SDL_Log("AltiVec %s\n", SDL_HasAltiVec()? "detected" : "not detected");
+        SDL_Log("MMX %s\n", SDL_HasMMX()? "detected" : "not detected");
+        SDL_Log("3DNow! %s\n", SDL_Has3DNow()? "detected" : "not detected");
+        SDL_Log("SSE %s\n", SDL_HasSSE()? "detected" : "not detected");
+        SDL_Log("SSE2 %s\n", SDL_HasSSE2()? "detected" : "not detected");
+        SDL_Log("SSE3 %s\n", SDL_HasSSE3()? "detected" : "not detected");
+        SDL_Log("SSE4.1 %s\n", SDL_HasSSE41()? "detected" : "not detected");
+        SDL_Log("SSE4.2 %s\n", SDL_HasSSE42()? "detected" : "not detected");
     }
     return (0);
 }
@@ -176,7 +176,7 @@
     {
         const SDL_assert_data *item = SDL_GetAssertionReport();
         while (item) {
-            printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n",
+            SDL_Log("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n",
                 item->condition, item->function, item->filename,
                 item->linenum, item->trigger_count,
                 item->always_ignore ? "yes" : "no");
@@ -192,11 +192,14 @@
     SDL_bool verbose = SDL_TRUE;
     int status = 0;
 
+    /* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     if (argv[1] && (SDL_strcmp(argv[1], "-q") == 0)) {
         verbose = SDL_FALSE;
     }
     if (verbose) {
-        printf("This system is running %s\n", SDL_GetPlatform());
+        SDL_Log("This system is running %s\n", SDL_GetPlatform());
     }
 
     status += TestTypes(verbose);
--- a/test/testpower.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testpower.c	Wed Aug 14 23:30:10 2013 -0700
@@ -21,7 +21,7 @@
     const SDL_PowerState state = SDL_GetPowerInfo(&seconds, &percent);
     char *statestr = NULL;
 
-    printf("SDL-reported power info...\n");
+    SDL_Log("SDL-reported power info...\n");
     switch (state) {
     case SDL_POWERSTATE_UNKNOWN:
         statestr = "Unknown";
@@ -43,18 +43,18 @@
         break;
     }
 
-    printf("State: %s\n", statestr);
+    SDL_Log("State: %s\n", statestr);
 
     if (percent == -1) {
-        printf("Percent left: unknown\n");
+        SDL_Log("Percent left: unknown\n");
     } else {
-        printf("Percent left: %d%%\n", percent);
+        SDL_Log("Percent left: %d%%\n", percent);
     }
 
     if (seconds == -1) {
-        printf("Time left: unknown\n");
+        SDL_Log("Time left: unknown\n");
     } else {
-        printf("Time left: %d minutes, %d seconds\n", (int) (seconds / 60),
+        SDL_Log("Time left: %d minutes, %d seconds\n", (int) (seconds / 60),
                (int) (seconds % 60));
     }
 }
@@ -63,8 +63,11 @@
 int
 main(int argc, char *argv[])
 {
+    /* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     if (SDL_Init(0) == -1) {
-        fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
         return 1;
     }
 
--- a/test/testrelative.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testrelative.c	Wed Aug 14 23:30:10 2013 -0700
@@ -35,6 +35,8 @@
     int i, done;
     SDL_Event event;
 
+	/* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 
     /* Initialize test framework */
     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
@@ -74,10 +76,8 @@
             switch(event.type) {
                 case SDL_MOUSEMOTION:
                 {
-                    /*printf("mouse motion ABS x %d y %d REL x %d y %d\n",event.motion.x,event.motion.y,event.motion.xrel,event.motion.yrel);*/
                     rect.x += event.motion.xrel;
                     rect.y += event.motion.yrel;
-
                 }
                 break;
             }
--- a/test/testrendercopyex.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testrendercopyex.c	Wed Aug 14 23:30:10 2013 -0700
@@ -46,7 +46,7 @@
     /* Load the sprite image */
     temp = SDL_LoadBMP(file);
     if (temp == NULL) {
-        fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
         return NULL;
     }
 
@@ -77,7 +77,7 @@
     /* Create textures from the image */
     texture = SDL_CreateTextureFromSurface(renderer, temp);
     if (!texture) {
-        fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
         SDL_FreeSurface(temp);
         return NULL;
     }
@@ -139,6 +139,9 @@
     int frames;
     Uint32 then, now;
 
+	/* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     /* Initialize test framework */
     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
     if (!state) {
@@ -149,7 +152,7 @@
 
         consumed = SDLTest_CommonArg(state, i);
         if (consumed == 0) {
-            fprintf(stderr, "Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
+            SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
             return 1;
         }
         i += consumed;
@@ -193,7 +196,7 @@
     now = SDL_GetTicks();
     if (now > then) {
         double fps = ((double) frames * 1000) / (now - then);
-        printf("%2.2f frames per second\n", fps);
+        SDL_Log("%2.2f frames per second\n", fps);
     }
 
     SDL_stack_free(drawstates);
--- a/test/testrendertarget.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testrendertarget.c	Wed Aug 14 23:30:10 2013 -0700
@@ -46,7 +46,7 @@
     /* Load the sprite image */
     temp = SDL_LoadBMP(file);
     if (temp == NULL) {
-        fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
         return NULL;
     }
 
@@ -77,7 +77,7 @@
     /* Create textures from the image */
     texture = SDL_CreateTextureFromSurface(renderer, temp);
     if (!texture) {
-        fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
         SDL_FreeSurface(temp);
         return NULL;
     }
@@ -114,7 +114,7 @@
         SDL_RenderCopy(s->renderer, A, NULL, NULL);
         SDL_RenderReadPixels(s->renderer, NULL, SDL_PIXELFORMAT_ARGB8888, &P, sizeof(P));
 
-        printf("Blended pixel: 0x%8.8X\n", P);
+        SDL_Log("Blended pixel: 0x%8.8X\n", P);
 
         SDL_DestroyTexture(A);
         SDL_DestroyTexture(B);
@@ -218,6 +218,9 @@
     Uint32 then, now;
     SDL_bool test_composite = SDL_FALSE;
 
+    /* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     /* Initialize test framework */
     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
     if (!state) {
@@ -235,8 +238,7 @@
             }
         }
         if (consumed < 0) {
-            fprintf(stderr,
-                    "Usage: %s %s [--composite]\n",
+            SDL_Log("Usage: %s %s [--composite]\n",
                     argv[0], SDLTest_CommonUsage(state));
             quit(1);
         }
@@ -289,7 +291,7 @@
     now = SDL_GetTicks();
     if (now > then) {
         double fps = ((double) frames * 1000) / (now - then);
-        printf("%2.2f frames per second\n", fps);
+        SDL_Log("%2.2f frames per second\n", fps);
     }
 
     SDL_stack_free(drawstates);
--- a/test/testresample.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testresample.c	Wed Aug 14 23:30:10 2013 -0700
@@ -9,7 +9,7 @@
   including commercial applications, and to alter it and redistribute it
   freely.
 */
-#include <stdio.h>
+
 #include "SDL.h"
 
 int
@@ -25,27 +25,30 @@
     int avgbytes = 0;
     SDL_RWops *io = NULL;
 
+	/* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     if (argc != 4) {
-        fprintf(stderr, "USAGE: %s in.wav out.wav newfreq\n", argv[0]);
+        SDL_Log("USAGE: %s in.wav out.wav newfreq\n", argv[0]);
         return 1;
     }
 
     cvtfreq = SDL_atoi(argv[3]);
 
     if (SDL_Init(SDL_INIT_AUDIO) == -1) {
-        fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
         return 2;
     }
 
     if (SDL_LoadWAV(argv[1], &spec, &data, &len) == NULL) {
-        fprintf(stderr, "failed to load %s: %s\n", argv[1], SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to load %s: %s\n", argv[1], SDL_GetError());
         SDL_Quit();
         return 3;
     }
 
     if (SDL_BuildAudioCVT(&cvt, spec.format, spec.channels, spec.freq,
                           spec.format, spec.channels, cvtfreq) == -1) {
-        fprintf(stderr, "failed to build CVT: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to build CVT: %s\n", SDL_GetError());
         SDL_FreeWAV(data);
         SDL_Quit();
         return 4;
@@ -54,7 +57,7 @@
     cvt.len = len;
     cvt.buf = (Uint8 *) SDL_malloc(len * cvt.len_mult);
     if (cvt.buf == NULL) {
-        fprintf(stderr, "Out of memory.\n");
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory.\n");
         SDL_FreeWAV(data);
         SDL_Quit();
         return 5;
@@ -62,7 +65,7 @@
     SDL_memcpy(cvt.buf, data, len);
 
     if (SDL_ConvertAudio(&cvt) == -1) {
-        fprintf(stderr, "Conversion failed: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Conversion failed: %s\n", SDL_GetError());
         SDL_free(cvt.buf);
         SDL_FreeWAV(data);
         SDL_Quit();
@@ -72,7 +75,7 @@
     /* write out a WAV header... */
     io = SDL_RWFromFile(argv[2], "wb");
     if (io == NULL) {
-        fprintf(stderr, "fopen('%s') failed: %s\n", argv[2], SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fopen('%s') failed: %s\n", argv[2], SDL_GetError());
         SDL_free(cvt.buf);
         SDL_FreeWAV(data);
         SDL_Quit();
@@ -99,7 +102,7 @@
     SDL_RWwrite(io, cvt.buf, cvt.len_cvt, 1);
 
     if (SDL_RWclose(io) == -1) {
-        fprintf(stderr, "fclose('%s') failed: %s\n", argv[2], SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fclose('%s') failed: %s\n", argv[2], SDL_GetError());
         SDL_free(cvt.buf);
         SDL_FreeWAV(data);
         SDL_Quit();
--- a/test/testrumble.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testrumble.c	Wed Aug 14 23:30:10 2013 -0700
@@ -26,7 +26,6 @@
  * includes
  */
 #include <stdlib.h>
-#include <stdio.h>              /* printf */
 #include <string.h>             /* strstr */
 #include <ctype.h>              /* isdigit */
 
@@ -51,12 +50,15 @@
     char *name;
     int index;
 
+	/* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     name = NULL;
     index = -1;
     if (argc > 1) {
         name = argv[1];
         if ((strcmp(name, "--help") == 0) || (strcmp(name, "-h") == 0)) {
-            printf("USAGE: %s [device]\n"
+            SDL_Log("USAGE: %s [device]\n"
                    "If device is a two-digit number it'll use it as an index, otherwise\n"
                    "it'll use it as if it were part of the device's name.\n",
                    argv[0]);
@@ -73,7 +75,7 @@
     /* Initialize the force feedbackness */
     SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK |
              SDL_INIT_HAPTIC);
-    printf("%d Haptic devices detected.\n", SDL_NumHaptics());
+    SDL_Log("%d Haptic devices detected.\n", SDL_NumHaptics());
     if (SDL_NumHaptics() > 0) {
         /* We'll just use index or the first force feedback device found */
         if (name == NULL) {
@@ -87,7 +89,7 @@
             }
 
             if (i >= SDL_NumHaptics()) {
-                printf("Unable to find device matching '%s', aborting.\n",
+                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find device matching '%s', aborting.\n",
                        name);
                 return 1;
             }
@@ -95,13 +97,13 @@
 
         haptic = SDL_HapticOpen(i);
         if (haptic == NULL) {
-            printf("Unable to create the haptic device: %s\n",
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n",
                    SDL_GetError());
             return 1;
         }
-        printf("Device: %s\n", SDL_HapticName(i));
+        SDL_Log("Device: %s\n", SDL_HapticName(i));
     } else {
-        printf("No Haptic devices found!\n");
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No Haptic devices found!\n");
         return 1;
     }
 
@@ -109,25 +111,25 @@
     SDL_ClearError();
 
     if (SDL_HapticRumbleSupported(haptic) == SDL_FALSE) {
-        printf("\nRumble not supported!\n");
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Rumble not supported!\n");
         return 1;
     }
     if (SDL_HapticRumbleInit(haptic) != 0) {
-        printf("\nFailed to initialize rumble: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to initialize rumble: %s\n", SDL_GetError());
         return 1;
     }
-    printf("Playing 2 second rumble at 0.5 magnitude.\n");
+    SDL_Log("Playing 2 second rumble at 0.5 magnitude.\n");
     if (SDL_HapticRumblePlay(haptic, 0.5, 5000) != 0) {
-       printf("\nFailed to play rumble: %s\n", SDL_GetError() );
+       SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError() );
        return 1;
     }
     SDL_Delay(2000);
-    printf("Stopping rumble.\n");
+    SDL_Log("Stopping rumble.\n");
     SDL_HapticRumbleStop(haptic);
     SDL_Delay(2000);
-    printf("Playing 2 second rumble at 0.3 magnitude.\n");
+    SDL_Log("Playing 2 second rumble at 0.3 magnitude.\n");
     if (SDL_HapticRumblePlay(haptic, 0.3f, 5000) != 0) {
-       printf("\nFailed to play rumble: %s\n", SDL_GetError() );
+       SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError() );
        return 1;
     }
     SDL_Delay(2000);
@@ -145,7 +147,7 @@
 int
 main(int argc, char *argv[])
 {
-    fprintf(stderr, "SDL compiled without Haptic support.\n");
+    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Haptic support.\n");
     exit(1);
 }
 
--- a/test/testscale.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testscale.c	Wed Aug 14 23:30:10 2013 -0700
@@ -48,7 +48,7 @@
     /* Load the sprite image */
     temp = SDL_LoadBMP(file);
     if (temp == NULL) {
-        fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
         return NULL;
     }
 
@@ -79,7 +79,7 @@
     /* Create textures from the image */
     texture = SDL_CreateTextureFromSurface(renderer, temp);
     if (!texture) {
-        fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
         SDL_FreeSurface(temp);
         return NULL;
     }
@@ -129,6 +129,9 @@
     int frames;
     Uint32 then, now;
 
+    /* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     /* Initialize test framework */
     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
     if (!state) {
@@ -139,7 +142,7 @@
 
         consumed = SDLTest_CommonArg(state, i);
         if (consumed == 0) {
-            fprintf(stderr, "Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
+            SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
             return 1;
         }
         i += consumed;
@@ -183,7 +186,7 @@
     now = SDL_GetTicks();
     if (now > then) {
         double fps = ((double) frames * 1000) / (now - then);
-        printf("%2.2f frames per second\n", fps);
+        SDL_Log("%2.2f frames per second\n", fps);
     }
 
     SDL_stack_free(drawstates);
--- a/test/testsem.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testsem.c	Wed Aug 14 23:30:10 2013 -0700
@@ -30,17 +30,15 @@
     int threadnum = (int) (uintptr_t) data;
     while (alive) {
         SDL_SemWait(sem);
-        fprintf(stderr,
-                "Thread number %d has got the semaphore (value = %d)!\n",
+        SDL_Log("Thread number %d has got the semaphore (value = %d)!\n",
                 threadnum, SDL_SemValue(sem));
         SDL_Delay(200);
         SDL_SemPost(sem);
-        fprintf(stderr,
-                "Thread number %d has released the semaphore (value = %d)!\n",
+        SDL_Log("Thread number %d has released the semaphore (value = %d)!\n",
                 threadnum, SDL_SemValue(sem));
         SDL_Delay(1);           /* For the scheduler */
     }
-    printf("Thread number %d exiting.\n", threadnum);
+    SDL_Log("Thread number %d exiting.\n", threadnum);
     return 0;
 }
 
@@ -59,7 +57,7 @@
     int retval;
 
     sem = SDL_CreateSemaphore(0);
-    printf("Waiting 2 seconds on semaphore\n");
+    SDL_Log("Waiting 2 seconds on semaphore\n");
 
     start_ticks = SDL_GetTicks();
     retval = SDL_SemWaitTimeout(sem, 2000);
@@ -69,13 +67,13 @@
 
     /* Accept a little offset in the effective wait */
     if (duration > 1900 && duration < 2050)
-        printf("Wait done.\n");
+        SDL_Log("Wait done.\n");
     else
-        fprintf(stderr, "Wait took %d milliseconds\n", duration);
+        SDL_Log("Wait took %d milliseconds\n", duration);
 
     /* Check to make sure the return value indicates timed out */
     if (retval != SDL_MUTEX_TIMEDOUT)
-        fprintf(stderr, "SDL_SemWaitTimeout returned: %d; expected: %d\n", retval, SDL_MUTEX_TIMEDOUT);
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_SemWaitTimeout returned: %d; expected: %d\n", retval, SDL_MUTEX_TIMEDOUT);
 }
 
 int
@@ -85,14 +83,17 @@
     uintptr_t i;
     int init_sem;
 
+	/* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     if (argc < 2) {
-        fprintf(stderr, "Usage: %s init_value\n", argv[0]);
+        SDL_Log("Usage: %s init_value\n", argv[0]);
         return (1);
     }
 
     /* Load the SDL library */
     if (SDL_Init(0) < 0) {
-        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return (1);
     }
     signal(SIGTERM, killed);
@@ -101,7 +102,7 @@
     init_sem = atoi(argv[1]);
     sem = SDL_CreateSemaphore(init_sem);
 
-    printf("Running %d threads, semaphore value = %d\n", NUM_THREADS,
+    SDL_Log("Running %d threads, semaphore value = %d\n", NUM_THREADS,
            init_sem);
     /* Create all the threads */
     for (i = 0; i < NUM_THREADS; ++i) {
@@ -114,12 +115,12 @@
     SDL_Delay(10 * 1000);
 
     /* Wait for all threads to finish */
-    printf("Waiting for threads to finish\n");
+    SDL_Log("Waiting for threads to finish\n");
     alive = 0;
     for (i = 0; i < NUM_THREADS; ++i) {
         SDL_WaitThread(threads[i], NULL);
     }
-    printf("Finished waiting for threads\n");
+    SDL_Log("Finished waiting for threads\n");
 
     SDL_DestroySemaphore(sem);
 
--- a/test/testshader.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testshader.c	Wed Aug 14 23:30:10 2013 -0700
@@ -11,7 +11,6 @@
 */
 /* This is a simple example of using GLSL shaders with SDL */
 
-#include <stdio.h> /* for printf() */
 #include "SDL.h"
 
 #ifdef HAVE_OPENGL
@@ -139,7 +138,7 @@
         glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
         info = SDL_stack_alloc(char, length+1);
         glGetInfoLogARB(shader, length, NULL, info);
-        fprintf(stderr, "Failed to compile shader:\n%s\n%s", source, info);
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to compile shader:\n%s\n%s", source, info);
         SDL_stack_free(info);
 
         return SDL_FALSE;
@@ -245,7 +244,7 @@
     /* Compile all the shaders */
     for (i = 0; i < NUM_SHADERS; ++i) {
         if (!CompileShaderProgram(&shaders[i])) {
-            fprintf(stderr, "Unable to compile shader!\n");
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to compile shader!\n");
             return SDL_FALSE;
         }
     }
@@ -422,29 +421,32 @@
     GLuint texture;
     GLfloat texcoords[4];
 
+	/* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     /* Initialize SDL for video output */
     if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
-        fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to initialize SDL: %s\n", SDL_GetError());
         exit(1);
     }
 
     /* Create a 640x480 OpenGL screen */
     window = SDL_CreateWindow( "Shader Demo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_OPENGL );
     if ( !window ) {
-        fprintf(stderr, "Unable to create OpenGL window: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL window: %s\n", SDL_GetError());
         SDL_Quit();
         exit(2);
     }
 
     if ( !SDL_GL_CreateContext(window)) {
-        fprintf(stderr, "Unable to create OpenGL context: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL context: %s\n", SDL_GetError());
         SDL_Quit();
         exit(2);
     }
 
     surface = SDL_LoadBMP("icon.bmp");
     if ( ! surface ) {
-        fprintf(stderr, "Unable to load icon.bmp: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to load icon.bmp: %s\n", SDL_GetError());
         SDL_Quit();
         exit(3);
     }
@@ -454,9 +456,9 @@
     /* Loop, drawing and checking events */
     InitGL(640, 480);
     if (InitShaders()) {
-        printf("Shaders supported, press SPACE to cycle them.\n");
+        SDL_Log("Shaders supported, press SPACE to cycle them.\n");
     } else {
-        printf("Shaders not supported!\n");
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Shaders not supported!\n");
     }
     done = 0;
     while ( ! done ) {
@@ -489,7 +491,7 @@
 int
 main(int argc, char *argv[])
 {
-    printf("No OpenGL support on this system\n");
+    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system\n");
     return 1;
 }
 
--- a/test/testshape.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testshape.c	Wed Aug 14 23:30:10 2013 -0700
@@ -68,13 +68,16 @@
     int access = 0;
     SDL_Rect texture_dimensions;;
 
+    /* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     if(argc < 2) {
-        printf("SDL_Shape requires at least one bitmap file as argument.\n");
+		SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Shape requires at least one bitmap file as argument.");
         exit(-1);
     }
 
     if(SDL_VideoInit(NULL) == -1) {
-        printf("Could not initialize SDL video.\n");
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not initialize SDL video.");
         exit(-2);
     }
 
@@ -91,7 +94,7 @@
                     SDL_FreeSurface(pictures[j].surface);
             SDL_free(pictures);
             SDL_VideoQuit();
-            printf("Could not load surface from named bitmap file.\n");
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not load surface from named bitmap file.");
             exit(-3);
         }
 
@@ -112,7 +115,7 @@
             SDL_FreeSurface(pictures[i].surface);
         SDL_free(pictures);
         SDL_VideoQuit();
-        printf("Could not create shaped window for SDL_Shape.\n");
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create shaped window for SDL_Shape.");
         exit(-4);
     }
     renderer = SDL_CreateRenderer(window,-1,0);
@@ -122,7 +125,7 @@
             SDL_FreeSurface(pictures[i].surface);
         SDL_free(pictures);
         SDL_VideoQuit();
-        printf("Could not create rendering context for SDL_Shape window.\n");
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create rendering context for SDL_Shape window.");
         exit(-5);
     }
 
@@ -141,7 +144,7 @@
             SDL_DestroyRenderer(renderer);
             SDL_DestroyWindow(window);
             SDL_VideoQuit();
-            printf("Could not create texture for SDL_shape.\n");
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create texture for SDL_shape.");
             exit(-6);
         }
     }
--- a/test/testsprite2.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testsprite2.c	Wed Aug 14 23:30:10 2013 -0700
@@ -64,7 +64,7 @@
     /* Load the sprite image */
     temp = SDL_LoadBMP(file);
     if (temp == NULL) {
-        fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
         return (-1);
     }
     sprite_w = temp->w;
@@ -95,7 +95,7 @@
         SDL_Renderer *renderer = state->renderers[i];
         sprites[i] = SDL_CreateTextureFromSurface(renderer, temp);
         if (!sprites[i]) {
-            fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
             SDL_FreeSurface(temp);
             return (-1);
         }
@@ -299,8 +299,7 @@
             }
         }
         if (consumed < 0) {
-            fprintf(stderr,
-                    "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha] [--iterations N] [num_sprites] [icon.bmp]\n",
+            SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha] [--iterations N] [num_sprites] [icon.bmp]\n",
                     argv[0], SDLTest_CommonUsage(state));
             quit(1);
         }
@@ -314,7 +313,7 @@
     sprites =
         (SDL_Texture **) SDL_malloc(state->num_windows * sizeof(*sprites));
     if (!sprites) {
-        fprintf(stderr, "Out of memory!\n");
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
         quit(2);
     }
     for (i = 0; i < state->num_windows; ++i) {
@@ -330,7 +329,7 @@
     positions = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect));
     velocities = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect));
     if (!positions || !velocities) {
-        fprintf(stderr, "Out of memory!\n");
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
         quit(2);
     }
 
@@ -375,7 +374,7 @@
     now = SDL_GetTicks();
     if (now > then) {
         double fps = ((double) frames * 1000) / (now - then);
-        printf("%2.2f frames per second\n", fps);
+        SDL_Log("%2.2f frames per second\n", fps);
     }
     quit(0);
     return 0;
--- a/test/testspriteminimal.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testspriteminimal.c	Wed Aug 14 23:30:10 2013 -0700
@@ -42,7 +42,7 @@
     /* Load the sprite image */
     temp = SDL_LoadBMP(file);
     if (temp == NULL) {
-        fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", file, SDL_GetError());
         return (-1);
     }
     sprite_w = temp->w;
@@ -73,7 +73,7 @@
     /* Create textures from the image */
     sprite = SDL_CreateTextureFromSurface(renderer, temp);
     if (!sprite) {
-        fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
         SDL_FreeSurface(temp);
         return (-1);
     }
@@ -126,6 +126,9 @@
     int i, done;
     SDL_Event event;
 
+	/* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     if (SDL_CreateWindowAndRenderer(WINDOW_WIDTH, WINDOW_HEIGHT, 0, &window, &renderer) < 0) {
         quit(2);
     }
--- a/test/teststreaming.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/teststreaming.c	Wed Aug 14 23:30:10 2013 -0700
@@ -68,7 +68,7 @@
     int pitch;
 
     if (SDL_LockTexture(texture, NULL, &pixels, &pitch) < 0) {
-        fprintf(stderr, "Couldn't lock texture: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock texture: %s\n", SDL_GetError());
         quit(5);
     }
     src = MooseFrames[frame];
@@ -93,15 +93,18 @@
     SDL_bool done = SDL_FALSE;
     int frame;
 
+	/* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     if (SDL_Init(SDL_INIT_VIDEO) < 0) {
-        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return 1;
     }
 
     /* load the moose images */
     handle = SDL_RWFromFile("moose.dat", "rb");
     if (handle == NULL) {
-        fprintf(stderr, "Can't find the file moose.dat !\n");
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
         quit(2);
     }
     SDL_RWread(handle, MooseFrames, MOOSEFRAME_SIZE, MOOSEFRAMES_COUNT);
@@ -115,19 +118,19 @@
                               MOOSEPIC_W*4, MOOSEPIC_H*4,
                               SDL_WINDOW_RESIZABLE);
     if (!window) {
-        fprintf(stderr, "Couldn't set create window: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError());
         quit(3);
     }
 
     renderer = SDL_CreateRenderer(window, -1, 0);
     if (!renderer) {
-        fprintf(stderr, "Couldn't set create renderer: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError());
         quit(4);
     }
 
     MooseTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H);
     if (!MooseTexture) {
-        fprintf(stderr, "Couldn't set create texture: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());
         quit(5);
     }
 
--- a/test/testthread.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testthread.c	Wed Aug 14 23:30:10 2013 -0700
@@ -34,20 +34,20 @@
 ThreadFunc(void *data)
 {
     SDL_TLSSet(tls, "baby thread", NULL);
-    printf("Started thread %s: My thread id is %lu, thread data = %s\n",
+    SDL_Log("Started thread %s: My thread id is %lu, thread data = %s\n",
            (char *) data, SDL_ThreadID(), (const char *)SDL_TLSGet(tls));
     while (alive) {
-        printf("Thread '%s' is alive!\n", (char *) data);
+        SDL_Log("Thread '%s' is alive!\n", (char *) data);
         SDL_Delay(1 * 1000);
     }
-    printf("Thread '%s' exiting!\n", (char *) data);
+    SDL_Log("Thread '%s' exiting!\n", (char *) data);
     return (0);
 }
 
 static void
 killed(int sig)
 {
-    printf("Killed with SIGTERM, waiting 5 seconds to exit\n");
+    SDL_Log("Killed with SIGTERM, waiting 5 seconds to exit\n");
     SDL_Delay(5 * 1000);
     alive = 0;
     quit(0);
@@ -58,35 +58,38 @@
 {
     SDL_Thread *thread;
 
+	/* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     /* Load the SDL library */
     if (SDL_Init(0) < 0) {
-        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return (1);
     }
 
     tls = SDL_TLSCreate();
     SDL_assert(tls);
     SDL_TLSSet(tls, "main thread", NULL);
-    printf("Main thread data initially: %s\n", (const char *)SDL_TLSGet(tls));
+    SDL_Log("Main thread data initially: %s\n", (const char *)SDL_TLSGet(tls));
 
     alive = 1;
     thread = SDL_CreateThread(ThreadFunc, "One", "#1");
     if (thread == NULL) {
-        fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
         quit(1);
     }
     SDL_Delay(5 * 1000);
-    printf("Waiting for thread #1\n");
+    SDL_Log("Waiting for thread #1\n");
     alive = 0;
     SDL_WaitThread(thread, NULL);
 
-    printf("Main thread data finally: %s\n", (const char *)SDL_TLSGet(tls));
+    SDL_Log("Main thread data finally: %s\n", (const char *)SDL_TLSGet(tls));
 
     alive = 1;
     signal(SIGTERM, killed);
     thread = SDL_CreateThread(ThreadFunc, "Two", "#2");
     if (thread == NULL) {
-        fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
         quit(1);
     }
     raise(SIGTERM);
--- a/test/testtimer.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testtimer.c	Wed Aug 14 23:30:10 2013 -0700
@@ -33,7 +33,7 @@
 static Uint32 SDLCALL
 callback(Uint32 interval, void *param)
 {
-    printf("Timer %d : param = %d\n", interval, (int) (uintptr_t) param);
+    SDL_Log("Timer %d : param = %d\n", interval, (int) (uintptr_t) param);
     return interval;
 }
 
@@ -45,8 +45,11 @@
     Uint32 start32, now32;
     Uint64 start, now;
 
+	/* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     if (SDL_Init(SDL_INIT_TIMER) < 0) {
-        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return (1);
     }
 
@@ -61,7 +64,7 @@
     t1 = SDL_AddTimer(desired, ticktock, NULL);
 
     /* Wait 10 seconds */
-    printf("Waiting 10 seconds\n");
+    SDL_Log("Waiting 10 seconds\n");
     SDL_Delay(10 * 1000);
 
     /* Stop the timer */
@@ -69,28 +72,27 @@
 
     /* Print the results */
     if (ticks) {
-        fprintf(stderr,
-                "Timer resolution: desired = %d ms, actual = %f ms\n",
+        SDL_Log("Timer resolution: desired = %d ms, actual = %f ms\n",
                 desired, (double) (10 * 1000) / ticks);
     }
 
     /* Test multiple timers */
-    printf("Testing multiple timers...\n");
+    SDL_Log("Testing multiple timers...\n");
     t1 = SDL_AddTimer(100, callback, (void *) 1);
     if (!t1)
-        fprintf(stderr, "Could not create timer 1: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 1: %s\n", SDL_GetError());
     t2 = SDL_AddTimer(50, callback, (void *) 2);
     if (!t2)
-        fprintf(stderr, "Could not create timer 2: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 2: %s\n", SDL_GetError());
     t3 = SDL_AddTimer(233, callback, (void *) 3);
     if (!t3)
-        fprintf(stderr, "Could not create timer 3: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 3: %s\n", SDL_GetError());
 
     /* Wait 10 seconds */
-    printf("Waiting 10 seconds\n");
+    SDL_Log("Waiting 10 seconds\n");
     SDL_Delay(10 * 1000);
 
-    printf("Removing timer 1 and waiting 5 more seconds\n");
+    SDL_Log("Removing timer 1 and waiting 5 more seconds\n");
     SDL_RemoveTimer(t1);
 
     SDL_Delay(5 * 1000);
@@ -103,15 +105,15 @@
         ticktock(0, NULL);
     }
     now = SDL_GetPerformanceCounter();
-    printf("1 million iterations of ticktock took %f ms\n", (double)((now - start)*1000) / SDL_GetPerformanceFrequency());
+    SDL_Log("1 million iterations of ticktock took %f ms\n", (double)((now - start)*1000) / SDL_GetPerformanceFrequency());
 
-    printf("Performance counter frequency: %llu\n", (unsigned long long) SDL_GetPerformanceFrequency());
+    SDL_Log("Performance counter frequency: %llu\n", (unsigned long long) SDL_GetPerformanceFrequency());
     start32 = SDL_GetTicks();
     start = SDL_GetPerformanceCounter();
     SDL_Delay(1000);
     now = SDL_GetPerformanceCounter();
     now32 = SDL_GetTicks();
-    printf("Delay 1 second = %d ms in ticks, %f ms according to performance counter\n", (now32-start32), (double)((now - start)*1000) / SDL_GetPerformanceFrequency());
+    SDL_Log("Delay 1 second = %d ms in ticks, %f ms according to performance counter\n", (now32-start32), (double)((now - start)*1000) / SDL_GetPerformanceFrequency());
 
     SDL_Quit();
     return (0);
--- a/test/testver.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testver.c	Wed Aug 14 23:30:10 2013 -0700
@@ -26,17 +26,20 @@
     SDL_version compiled;
     SDL_version linked;
 
+	/* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
 #if SDL_VERSION_ATLEAST(2, 0, 0)
-    printf("Compiled with SDL 2.0 or newer\n");
+    SDL_Log("Compiled with SDL 2.0 or newer\n");
 #else
-    printf("Compiled with SDL older than 2.0\n");
+    SDL_Log("Compiled with SDL older than 2.0\n");
 #endif
     SDL_VERSION(&compiled);
-    printf("Compiled version: %d.%d.%d.%d (%s)\n",
+    SDL_Log("Compiled version: %d.%d.%d.%d (%s)\n",
            compiled.major, compiled.minor, compiled.patch,
            SDL_REVISION_NUMBER, SDL_REVISION);
     SDL_GetVersion(&linked);
-    printf("Linked version: %d.%d.%d.%d (%s)\n",
+    SDL_Log("Linked version: %d.%d.%d.%d (%s)\n",
            linked.major, linked.minor, linked.patch,
            SDL_GetRevisionNumber(), SDL_GetRevision());
     SDL_Quit();
--- a/test/testwm2.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/testwm2.c	Wed Aug 14 23:30:10 2013 -0700
@@ -48,6 +48,9 @@
     int system_cursor = -1;
     SDL_Cursor *cursor = NULL;
 
+	/* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     SDL_assert(SDL_arraysize(cursorNames) == SDL_NUM_SYSTEM_CURSORS);
 
     /* Initialize test framework */
@@ -64,7 +67,7 @@
             consumed = -1;
         }
         if (consumed < 0) {
-            fprintf(stderr, "Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
+            SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
             quit(1);
         }
         i += consumed;
@@ -84,7 +87,7 @@
                 if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
                     SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
                     if (window) {
-                        printf("Window %d resized to %dx%d\n",
+                        SDL_Log("Window %d resized to %dx%d\n",
                             event.window.windowID,
                             event.window.data1,
                             event.window.data2);
@@ -93,7 +96,7 @@
                 if (event.window.event == SDL_WINDOWEVENT_MOVED) {
                     SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
                     if (window) {
-                        printf("Window %d moved to %d,%d (display %s)\n",
+                        SDL_Log("Window %d moved to %d,%d (display %s)\n",
                             event.window.windowID,
                             event.window.data1,
                             event.window.data2,
--- a/test/torturethread.c	Mon Aug 12 22:00:21 2013 -0700
+++ b/test/torturethread.c	Wed Aug 14 23:30:10 2013 -0700
@@ -49,7 +49,7 @@
     int i;
     int tid = (int) (uintptr_t) data;
 
-    fprintf(stderr, "Creating Thread %d\n", tid);
+    SDL_Log("Creating Thread %d\n", tid);
 
     for (i = 0; i < NUMTHREADS; i++) {
         char name[64];
@@ -58,18 +58,18 @@
         sub_threads[i] = SDL_CreateThread(SubThreadFunc, name, &flags[i]);
     }
 
-    printf("Thread '%d' waiting for signal\n", tid);
+    SDL_Log("Thread '%d' waiting for signal\n", tid);
     while (time_for_threads_to_die[tid] != 1) {
         ;                       /* do nothing */
     }
 
-    printf("Thread '%d' sending signals to subthreads\n", tid);
+    SDL_Log("Thread '%d' sending signals to subthreads\n", tid);
     for (i = 0; i < NUMTHREADS; i++) {
         flags[i] = 1;
         SDL_WaitThread(sub_threads[i], NULL);
     }
 
-    printf("Thread '%d' exiting!\n", tid);
+    SDL_Log("Thread '%d' exiting!\n", tid);
 
     return 0;
 }
@@ -80,9 +80,12 @@
     SDL_Thread *threads[NUMTHREADS];
     int i;
 
+	/* Enable standard application logging */
+    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
     /* Load the SDL library */
     if (SDL_Init(0) < 0) {
-        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return (1);
     }
 
@@ -94,7 +97,7 @@
         threads[i] = SDL_CreateThread(ThreadFunc, name, (void*) (uintptr_t) i);
 
         if (threads[i] == NULL) {
-            fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
+            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
             quit(1);
         }
     }