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 76399406b7dd2f2d
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
     1.1 --- a/VisualC/tests/loopwave/loopwave_VS2010.vcxproj	Mon Aug 12 22:00:21 2013 -0700
     1.2 +++ b/VisualC/tests/loopwave/loopwave_VS2010.vcxproj	Wed Aug 14 23:30:10 2013 -0700
     1.3 @@ -1,4 +1,4 @@
     1.4 -<?xml version="1.0" encoding="utf-8"?>
     1.5 +<?xml version="1.0" encoding="utf-8"?>
     1.6  <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
     1.7    <ItemGroup Label="ProjectConfigurations">
     1.8      <ProjectConfiguration Include="Debug|Win32">
     1.9 @@ -105,7 +105,8 @@
    1.10        <SubSystem>Windows</SubSystem>
    1.11      </Link>
    1.12      <PostBuildEvent>
    1.13 -      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
    1.14 +      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
    1.15 +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
    1.16      </PostBuildEvent>
    1.17      <PostBuildEvent>
    1.18        <Message>Copy SDL</Message>
    1.19 @@ -139,7 +140,8 @@
    1.20        <SubSystem>Windows</SubSystem>
    1.21      </Link>
    1.22      <PostBuildEvent>
    1.23 -      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
    1.24 +      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
    1.25 +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
    1.26      </PostBuildEvent>
    1.27      <PostBuildEvent>
    1.28        <Message>Copy SDL</Message>
    1.29 @@ -174,7 +176,8 @@
    1.30        <SubSystem>Windows</SubSystem>
    1.31      </Link>
    1.32      <PostBuildEvent>
    1.33 -      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
    1.34 +      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
    1.35 +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
    1.36      </PostBuildEvent>
    1.37      <PostBuildEvent>
    1.38        <Message>Copy SDL</Message>
    1.39 @@ -208,7 +211,8 @@
    1.40        <SubSystem>Windows</SubSystem>
    1.41      </Link>
    1.42      <PostBuildEvent>
    1.43 -      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
    1.44 +      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
    1.45 +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
    1.46      </PostBuildEvent>
    1.47      <PostBuildEvent>
    1.48        <Message>Copy SDL</Message>
     2.1 --- a/VisualC/tests/loopwave/loopwave_VS2012.vcxproj	Mon Aug 12 22:00:21 2013 -0700
     2.2 +++ b/VisualC/tests/loopwave/loopwave_VS2012.vcxproj	Wed Aug 14 23:30:10 2013 -0700
     2.3 @@ -109,7 +109,8 @@
     2.4        <SubSystem>Windows</SubSystem>
     2.5      </Link>
     2.6      <PostBuildEvent>
     2.7 -      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
     2.8 +      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
     2.9 +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
    2.10      </PostBuildEvent>
    2.11      <PostBuildEvent>
    2.12        <Message>Copy SDL</Message>
    2.13 @@ -143,7 +144,8 @@
    2.14        <SubSystem>Windows</SubSystem>
    2.15      </Link>
    2.16      <PostBuildEvent>
    2.17 -      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
    2.18 +      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
    2.19 +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
    2.20      </PostBuildEvent>
    2.21      <PostBuildEvent>
    2.22        <Message>Copy SDL</Message>
    2.23 @@ -178,7 +180,8 @@
    2.24        <SubSystem>Windows</SubSystem>
    2.25      </Link>
    2.26      <PostBuildEvent>
    2.27 -      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
    2.28 +      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
    2.29 +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
    2.30      </PostBuildEvent>
    2.31      <PostBuildEvent>
    2.32        <Message>Copy SDL</Message>
    2.33 @@ -212,7 +215,8 @@
    2.34        <SubSystem>Windows</SubSystem>
    2.35      </Link>
    2.36      <PostBuildEvent>
    2.37 -      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
    2.38 +      <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
    2.39 +copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
    2.40      </PostBuildEvent>
    2.41      <PostBuildEvent>
    2.42        <Message>Copy SDL</Message>
     3.1 --- a/test/checkkeys.c	Mon Aug 12 22:00:21 2013 -0700
     3.2 +++ b/test/checkkeys.c	Wed Aug 14 23:30:10 2013 -0700
     3.3 @@ -117,13 +117,13 @@
     3.4  static void
     3.5  PrintText(char *text)
     3.6  {
     3.7 -    unsigned char *spot, expanded[1024];
     3.8 +    char *spot, expanded[1024];
     3.9  
    3.10      expanded[0] = '\0';
    3.11      for ( spot = text; *spot; ++spot )
    3.12      {
    3.13          size_t length = SDL_strlen(expanded);
    3.14 -        SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", *spot);
    3.15 +        SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", (unsigned char)*spot);
    3.16      }
    3.17      SDL_Log("Text (%s): \"%s%s\"\n", expanded, *text == '"' ? "\\" : "", text);
    3.18  }
    3.19 @@ -134,10 +134,13 @@
    3.20      SDL_Window *window;
    3.21      SDL_Event event;
    3.22      int done;
    3.23 +	
    3.24 +	/* Enable standard application logging */
    3.25 +	SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
    3.26  
    3.27      /* Initialize SDL */
    3.28      if (SDL_Init(SDL_INIT_VIDEO) < 0) {
    3.29 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
    3.30 +		SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
    3.31          return (1);
    3.32      }
    3.33  
    3.34 @@ -146,7 +149,7 @@
    3.35                                SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
    3.36                                640, 480, 0);
    3.37      if (!window) {
    3.38 -        fprintf(stderr, "Couldn't create 640x480 window: %s\n",
    3.39 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n",
    3.40                  SDL_GetError());
    3.41          quit(2);
    3.42      }
    3.43 @@ -166,7 +169,7 @@
    3.44          switch (event.type) {
    3.45          case SDL_KEYDOWN:
    3.46          case SDL_KEYUP:
    3.47 -            PrintKey(&event.key.keysym, event.key.state, event.key.repeat);
    3.48 +			PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED) ? SDL_TRUE : SDL_FALSE, (event.key.repeat) ? SDL_TRUE : SDL_FALSE);
    3.49              break;
    3.50          case SDL_TEXTINPUT:
    3.51              PrintText(event.text.text);
     4.1 --- a/test/loopwave.c	Mon Aug 12 22:00:21 2013 -0700
     4.2 +++ b/test/loopwave.c	Wed Aug 14 23:30:10 2013 -0700
     4.3 @@ -80,9 +80,12 @@
     4.4  {
     4.5      int i;
     4.6  
     4.7 +	/* Enable standard application logging */
     4.8 +	SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
     4.9 +
    4.10      /* Load the SDL library */
    4.11      if (SDL_Init(SDL_INIT_AUDIO) < 0) {
    4.12 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
    4.13 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
    4.14          return (1);
    4.15      }
    4.16  
    4.17 @@ -91,7 +94,7 @@
    4.18      }
    4.19      /* Load the wave file into memory */
    4.20      if (SDL_LoadWAV(argv[1], &wave.spec, &wave.sound, &wave.soundlen) == NULL) {
    4.21 -        fprintf(stderr, "Couldn't load %s: %s\n", argv[1], SDL_GetError());
    4.22 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", argv[1], SDL_GetError());
    4.23          quit(1);
    4.24      }
    4.25  
    4.26 @@ -109,24 +112,19 @@
    4.27  #endif /* HAVE_SIGNAL_H */
    4.28  
    4.29      /* Show the list of available drivers */
    4.30 -    printf("Available audio drivers: ");
    4.31 +    SDL_Log("Available audio drivers:");
    4.32      for (i = 0; i < SDL_GetNumAudioDrivers(); ++i) {
    4.33 -        if (i == 0) {
    4.34 -            printf("%s", SDL_GetAudioDriver(i));
    4.35 -        } else {
    4.36 -            printf(", %s", SDL_GetAudioDriver(i));
    4.37 -        }
    4.38 +		SDL_Log("%i: %s", i, SDL_GetAudioDriver(i));
    4.39      }
    4.40 -    printf("\n");
    4.41  
    4.42      /* Initialize fillerup() variables */
    4.43      if (SDL_OpenAudio(&wave.spec, NULL) < 0) {
    4.44 -        fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
    4.45 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError());
    4.46          SDL_FreeWAV(wave.sound);
    4.47          quit(2);
    4.48      }
    4.49  
    4.50 -    printf("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
    4.51 +    SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
    4.52  
    4.53      /* Let the audio run */
    4.54      SDL_PauseAudio(0);
     5.1 --- a/test/testatomic.c	Mon Aug 12 22:00:21 2013 -0700
     5.2 +++ b/test/testatomic.c	Wed Aug 14 23:30:10 2013 -0700
     5.3 @@ -45,39 +45,39 @@
     5.4      SDL_atomic_t v;
     5.5      SDL_bool tfret = SDL_FALSE;
     5.6  
     5.7 -    printf("\nspin lock---------------------------------------\n\n");
     5.8 +    SDL_Log("\nspin lock---------------------------------------\n\n");
     5.9  
    5.10      SDL_AtomicLock(&lock);
    5.11 -    printf("AtomicLock                   lock=%d\n", lock);
    5.12 +    SDL_Log("AtomicLock                   lock=%d\n", lock);
    5.13      SDL_AtomicUnlock(&lock);
    5.14 -    printf("AtomicUnlock                 lock=%d\n", lock);
    5.15 +    SDL_Log("AtomicUnlock                 lock=%d\n", lock);
    5.16  
    5.17 -    printf("\natomic -----------------------------------------\n\n");
    5.18 +    SDL_Log("\natomic -----------------------------------------\n\n");
    5.19  
    5.20      SDL_AtomicSet(&v, 0);
    5.21 -    tfret = SDL_AtomicSet(&v, 10) == 0;
    5.22 -    printf("AtomicSet(10)        tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
    5.23 -    tfret = SDL_AtomicAdd(&v, 10) == 10;
    5.24 -    printf("AtomicAdd(10)        tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
    5.25 +    tfret = SDL_AtomicSet(&v, 10) == 0 ? SDL_TRUE : SDL_FALSE;
    5.26 +    SDL_Log("AtomicSet(10)        tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
    5.27 +    tfret = SDL_AtomicAdd(&v, 10) == 10 ? SDL_TRUE : SDL_FALSE;
    5.28 +    SDL_Log("AtomicAdd(10)        tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
    5.29  
    5.30      SDL_AtomicSet(&v, 0);
    5.31      SDL_AtomicIncRef(&v);
    5.32 -    tfret = (SDL_AtomicGet(&v) == 1);
    5.33 -    printf("AtomicIncRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
    5.34 +    tfret = (SDL_AtomicGet(&v) == 1) ? SDL_TRUE : SDL_FALSE;
    5.35 +    SDL_Log("AtomicIncRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
    5.36      SDL_AtomicIncRef(&v);
    5.37 -    tfret = (SDL_AtomicGet(&v) == 2);
    5.38 -    printf("AtomicIncRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
    5.39 -    tfret = (SDL_AtomicDecRef(&v) == SDL_FALSE);
    5.40 -    printf("AtomicDecRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
    5.41 -    tfret = (SDL_AtomicDecRef(&v) == SDL_TRUE);
    5.42 -    printf("AtomicDecRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
    5.43 +    tfret = (SDL_AtomicGet(&v) == 2) ? SDL_TRUE : SDL_FALSE;
    5.44 +    SDL_Log("AtomicIncRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
    5.45 +    tfret = (SDL_AtomicDecRef(&v) == SDL_FALSE) ? SDL_TRUE : SDL_FALSE;
    5.46 +    SDL_Log("AtomicDecRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
    5.47 +    tfret = (SDL_AtomicDecRef(&v) == SDL_TRUE) ? SDL_TRUE : SDL_FALSE;
    5.48 +    SDL_Log("AtomicDecRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
    5.49  
    5.50      SDL_AtomicSet(&v, 10);
    5.51 -    tfret = (SDL_AtomicCAS(&v, 0, 20) == SDL_FALSE);
    5.52 -    printf("AtomicCAS()          tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
    5.53 +    tfret = (SDL_AtomicCAS(&v, 0, 20) == SDL_FALSE) ? SDL_TRUE : SDL_FALSE;
    5.54 +    SDL_Log("AtomicCAS()          tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
    5.55      value = SDL_AtomicGet(&v);
    5.56 -    tfret = (SDL_AtomicCAS(&v, value, 20) == SDL_TRUE);
    5.57 -    printf("AtomicCAS()          tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
    5.58 +    tfret = (SDL_AtomicCAS(&v, value, 20) == SDL_TRUE) ? SDL_TRUE : SDL_FALSE;
    5.59 +    SDL_Log("AtomicCAS()          tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
    5.60  }
    5.61  
    5.62  /**************************************************************************/
    5.63 @@ -120,7 +120,7 @@
    5.64  int adder(void* junk)
    5.65  {
    5.66      unsigned long N=NInter;
    5.67 -    printf("Thread subtracting %d %lu times\n",CountInc,N);
    5.68 +    SDL_Log("Thread subtracting %d %lu times\n",CountInc,N);
    5.69      while (N--) {
    5.70          SDL_AtomicAdd(&good, -CountInc);
    5.71          bad-=CountInc;
    5.72 @@ -152,7 +152,7 @@
    5.73  
    5.74      end = SDL_GetTicks();
    5.75  
    5.76 -    printf("Finished in %f sec\n", (end - start) / 1000.f);
    5.77 +    SDL_Log("Finished in %f sec\n", (end - start) / 1000.f);
    5.78  }
    5.79  
    5.80  static
    5.81 @@ -161,28 +161,28 @@
    5.82      int b;
    5.83      atomicValue v;
    5.84  
    5.85 -    printf("\nepic test---------------------------------------\n\n");
    5.86 +    SDL_Log("\nepic test---------------------------------------\n\n");
    5.87  
    5.88 -    printf("Size asserted to be >= 32-bit\n");
    5.89 +    SDL_Log("Size asserted to be >= 32-bit\n");
    5.90      SDL_assert(sizeof(atomicValue)>=4);
    5.91  
    5.92 -    printf("Check static initializer\n");
    5.93 +    SDL_Log("Check static initializer\n");
    5.94      v=SDL_AtomicGet(&good);
    5.95      SDL_assert(v==42);
    5.96  
    5.97      SDL_assert(bad==42);
    5.98  
    5.99 -    printf("Test negative values\n");
   5.100 +    SDL_Log("Test negative values\n");
   5.101      SDL_AtomicSet(&good, -5);
   5.102      v=SDL_AtomicGet(&good);
   5.103      SDL_assert(v==-5);
   5.104  
   5.105 -    printf("Verify maximum value\n");
   5.106 +    SDL_Log("Verify maximum value\n");
   5.107      SDL_AtomicSet(&good, CountTo);
   5.108      v=SDL_AtomicGet(&good);
   5.109      SDL_assert(v==CountTo);
   5.110  
   5.111 -    printf("Test compare and exchange\n");
   5.112 +    SDL_Log("Test compare and exchange\n");
   5.113  
   5.114      b=SDL_AtomicCAS(&good, 500, 43);
   5.115      SDL_assert(!b); /* no swap since CountTo!=500 */
   5.116 @@ -194,7 +194,7 @@
   5.117      v=SDL_AtomicGet(&good);
   5.118      SDL_assert(v==44);
   5.119  
   5.120 -    printf("Test Add\n");
   5.121 +    SDL_Log("Test Add\n");
   5.122  
   5.123      v=SDL_AtomicAdd(&good, 1);
   5.124      SDL_assert(v==44);
   5.125 @@ -206,7 +206,7 @@
   5.126      v=SDL_AtomicGet(&good);
   5.127      SDL_assert(v==55);
   5.128  
   5.129 -    printf("Test Add (Negative values)\n");
   5.130 +    SDL_Log("Test Add (Negative values)\n");
   5.131  
   5.132      v=SDL_AtomicAdd(&good, -20);
   5.133      SDL_assert(v==55);
   5.134 @@ -223,7 +223,7 @@
   5.135      v=SDL_AtomicGet(&good);
   5.136      SDL_assert(v==15);
   5.137  
   5.138 -    printf("Reset before count down test\n");
   5.139 +    SDL_Log("Reset before count down test\n");
   5.140      SDL_AtomicSet(&good, CountTo);
   5.141      v=SDL_AtomicGet(&good);
   5.142      SDL_assert(v==CountTo);
   5.143 @@ -231,11 +231,11 @@
   5.144      bad=CountTo;
   5.145      SDL_assert(bad==CountTo);
   5.146  
   5.147 -    printf("Counting down from %d, Expect %d remaining\n",CountTo,Expect);
   5.148 +    SDL_Log("Counting down from %d, Expect %d remaining\n",CountTo,Expect);
   5.149      runAdder();
   5.150  
   5.151      v=SDL_AtomicGet(&good);
   5.152 -    printf("Atomic %d Non-Atomic %d\n",v,bad);
   5.153 +    SDL_Log("Atomic %d Non-Atomic %d\n",v,bad);
   5.154      SDL_assert(v==Expect);
   5.155      SDL_assert(bad!=Expect);
   5.156  }
   5.157 @@ -429,7 +429,7 @@
   5.158      } else if (delta < 0) {
   5.159          /* We ran into an old queue entry, which means it still needs to be dequeued */
   5.160      } else {
   5.161 -        printf("ERROR: mutex failed!\n");
   5.162 +        SDL_Log("ERROR: mutex failed!\n");
   5.163      }
   5.164  
   5.165      SDL_UnlockMutex(queue->mutex);
   5.166 @@ -462,7 +462,7 @@
   5.167      } else if (delta < 0) {
   5.168          /* We ran into an old queue entry, which means we've hit empty */
   5.169      } else {
   5.170 -        printf("ERROR: mutex failed!\n");
   5.171 +        SDL_Log("ERROR: mutex failed!\n");
   5.172      }
   5.173  
   5.174      SDL_UnlockMutex(queue->mutex);
   5.175 @@ -598,9 +598,11 @@
   5.176      Uint32 start, end;
   5.177      int i, j;
   5.178      int grand_total;
   5.179 +	char textBuffer[1024];
   5.180 +	int len;
   5.181  
   5.182 -    printf("\nFIFO test---------------------------------------\n\n");
   5.183 -    printf("Mode: %s\n", lock_free ? "LockFree" : "Mutex");
   5.184 +    SDL_Log("\nFIFO test---------------------------------------\n\n");
   5.185 +    SDL_Log("Mode: %s\n", lock_free ? "LockFree" : "Mutex");
   5.186  
   5.187      readersDone = SDL_CreateSemaphore(0);
   5.188      writersDone = SDL_CreateSemaphore(0);
   5.189 @@ -622,7 +624,7 @@
   5.190  #endif
   5.191  
   5.192      /* Start the readers first */
   5.193 -    printf("Starting %d readers\n", NUM_READERS);
   5.194 +    SDL_Log("Starting %d readers\n", NUM_READERS);
   5.195      SDL_zero(readerData);
   5.196      SDL_AtomicSet(&readersRunning, NUM_READERS);
   5.197      for (i = 0; i < NUM_READERS; ++i) {
   5.198 @@ -634,7 +636,7 @@
   5.199      }
   5.200  
   5.201      /* Start up the writers */
   5.202 -    printf("Starting %d writers\n", NUM_WRITERS);
   5.203 +    SDL_Log("Starting %d writers\n", NUM_WRITERS);
   5.204      SDL_zero(writerData);
   5.205      SDL_AtomicSet(&writersRunning, NUM_WRITERS);
   5.206      for (i = 0; i < NUM_WRITERS; ++i) {
   5.207 @@ -668,16 +670,16 @@
   5.208          SDL_DestroyMutex(queue.mutex);
   5.209      }
   5.210  
   5.211 -    printf("Finished in %f sec\n", (end - start) / 1000.f);
   5.212 +    SDL_Log("Finished in %f sec\n", (end - start) / 1000.f);
   5.213  
   5.214 -    printf("\n");
   5.215 +    SDL_Log("\n");
   5.216      for (i = 0; i < NUM_WRITERS; ++i) {
   5.217 -        printf("Writer %d wrote %d events, had %d waits\n", i, EVENTS_PER_WRITER, writerData[i].waits);
   5.218 +        SDL_Log("Writer %d wrote %d events, had %d waits\n", i, EVENTS_PER_WRITER, writerData[i].waits);
   5.219      }
   5.220 -    printf("Writers wrote %d total events\n", NUM_WRITERS*EVENTS_PER_WRITER);
   5.221 +    SDL_Log("Writers wrote %d total events\n", NUM_WRITERS*EVENTS_PER_WRITER);
   5.222  
   5.223      /* Print a breakdown of which readers read messages from which writer */
   5.224 -    printf("\n");
   5.225 +    SDL_Log("\n");
   5.226      grand_total = 0;
   5.227      for (i = 0; i < NUM_READERS; ++i) {
   5.228          int total = 0;
   5.229 @@ -685,17 +687,21 @@
   5.230              total += readerData[i].counters[j];
   5.231          }
   5.232          grand_total += total;
   5.233 -        printf("Reader %d read %d events, had %d waits\n", i, total, readerData[i].waits);
   5.234 -        printf("  { ");
   5.235 +        SDL_Log("Reader %d read %d events, had %d waits\n", i, total, readerData[i].waits);
   5.236 +		SDL_snprintf(textBuffer, sizeof(textBuffer), "  { ");
   5.237          for (j = 0; j < NUM_WRITERS; ++j) {
   5.238              if (j > 0) {
   5.239 -                printf(", ");
   5.240 +				len = SDL_strlen(textBuffer);
   5.241 +                SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, ", ");
   5.242              }
   5.243 -            printf("%d", readerData[i].counters[j]);
   5.244 +            len = SDL_strlen(textBuffer);
   5.245 +            SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, "%d", readerData[i].counters[j]);
   5.246          }
   5.247 -        printf(" }\n");
   5.248 +        len = SDL_strlen(textBuffer);
   5.249 +        SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, " }\n");
   5.250 +		SDL_Log(textBuffer);
   5.251      }
   5.252 -    printf("Readers read %d total events\n", grand_total);
   5.253 +    SDL_Log("Readers read %d total events\n", grand_total);
   5.254  }
   5.255  
   5.256  /* End FIFO test */
   5.257 @@ -704,6 +710,9 @@
   5.258  int
   5.259  main(int argc, char *argv[])
   5.260  {
   5.261 +	/* Enable standard application logging */
   5.262 +	SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   5.263 +
   5.264      RunBasicTest();
   5.265      RunEpicTest();
   5.266  /* This test is really slow, so don't run it by default */
     6.1 --- a/test/testaudioinfo.c	Mon Aug 12 22:00:21 2013 -0700
     6.2 +++ b/test/testaudioinfo.c	Wed Aug 14 23:30:10 2013 -0700
     6.3 @@ -18,18 +18,18 @@
     6.4      const char *typestr = ((iscapture) ? "capture" : "output");
     6.5      int n = SDL_GetNumAudioDevices(iscapture);
     6.6  
     6.7 -    printf("%s devices:\n", typestr);
     6.8 +    SDL_Log("%s devices:\n", typestr);
     6.9  
    6.10      if (n == -1)
    6.11 -        printf("  Driver can't detect specific %s devices.\n\n", typestr);
    6.12 +        SDL_Log("  Driver can't detect specific %s devices.\n\n", typestr);
    6.13      else if (n == 0)
    6.14 -        printf("  No %s devices found.\n\n", typestr);
    6.15 +        SDL_Log("  No %s devices found.\n\n", typestr);
    6.16      else {
    6.17          int i;
    6.18          for (i = 0; i < n; i++) {
    6.19 -            printf("  %s\n", SDL_GetAudioDeviceName(i, iscapture));
    6.20 +            SDL_Log("  %s\n", SDL_GetAudioDeviceName(i, iscapture));
    6.21          }
    6.22 -        printf("\n");
    6.23 +        SDL_Log("\n");
    6.24      }
    6.25  }
    6.26  
    6.27 @@ -38,26 +38,29 @@
    6.28  {
    6.29      int n;
    6.30  
    6.31 +    /* Enable standard application logging */
    6.32 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
    6.33 +
    6.34      /* Load the SDL library */
    6.35      if (SDL_Init(SDL_INIT_AUDIO) < 0) {
    6.36 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
    6.37 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
    6.38          return (1);
    6.39      }
    6.40  
    6.41      /* Print available audio drivers */
    6.42      n = SDL_GetNumAudioDrivers();
    6.43      if (n == 0) {
    6.44 -        printf("No built-in audio drivers\n\n");
    6.45 +        SDL_Log("No built-in audio drivers\n\n");
    6.46      } else {
    6.47          int i;
    6.48 -        printf("Built-in audio drivers:\n");
    6.49 +        SDL_Log("Built-in audio drivers:\n");
    6.50          for (i = 0; i < n; ++i) {
    6.51 -            printf("  %s\n", SDL_GetAudioDriver(i));
    6.52 +            SDL_Log("  %s\n", SDL_GetAudioDriver(i));
    6.53          }
    6.54 -        printf("\n");
    6.55 +        SDL_Log("\n");
    6.56      }
    6.57  
    6.58 -    printf("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
    6.59 +    SDL_Log("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
    6.60  
    6.61      print_devices(0);
    6.62      print_devices(1);
     7.1 --- a/test/testautomation.c	Mon Aug 12 22:00:21 2013 -0700
     7.2 +++ b/test/testautomation.c	Wed Aug 14 23:30:10 2013 -0700
     7.3 @@ -80,8 +80,7 @@
     7.4              }
     7.5          }
     7.6          if (consumed < 0) {
     7.7 -            fprintf(stderr,
     7.8 -                    "Usage: %s %s [--iterations #] [--execKey #] [--seed string] [--filter suite_name|test_name]\n",
     7.9 +            SDL_Log("Usage: %s %s [--iterations #] [--execKey #] [--seed string] [--filter suite_name|test_name]\n",
    7.10                      argv[0], SDLTest_CommonUsage(state));
    7.11              quit(1);
    7.12          }
     8.1 --- a/test/testautomation_surface.c	Mon Aug 12 22:00:21 2013 -0700
     8.2 +++ b/test/testautomation_surface.c	Wed Aug 14 23:30:10 2013 -0700
     8.3 @@ -360,8 +360,6 @@
     8.4  
     8.5      for ( i = 0; i < SDL_arraysize(pixel_formats); ++i ) {
     8.6          for ( j = 0; j < SDL_arraysize(pixel_formats); ++j ) {
     8.7 -            /*printf("Converting %s -> %s\n", SDL_GetPixelFormatName(pixel_formats[i]), SDL_GetPixelFormatName(pixel_formats[j]));*/
     8.8 -
     8.9              fmt1 = SDL_AllocFormat(pixel_formats[i]);
    8.10              SDL_assert(fmt1 != NULL);
    8.11              cvt1 = SDL_ConvertSurface(face, fmt1, 0);
     9.1 --- a/test/testdraw2.c	Mon Aug 12 22:00:21 2013 -0700
     9.2 +++ b/test/testdraw2.c	Wed Aug 14 23:30:10 2013 -0700
     9.3 @@ -176,6 +176,9 @@
     9.4      SDL_Event event;
     9.5      Uint32 then, now, frames;
     9.6  
     9.7 +	/* Enable standard application logging */
     9.8 +	SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
     9.9 +
    9.10      /* Initialize parameters */
    9.11      num_objects = NUM_OBJECTS;
    9.12  
    9.13 @@ -218,8 +221,7 @@
    9.14              }
    9.15          }
    9.16          if (consumed < 0) {
    9.17 -            fprintf(stderr,
    9.18 -                    "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
    9.19 +            SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
    9.20                      argv[0], SDLTest_CommonUsage(state));
    9.21              return 1;
    9.22          }
    9.23 @@ -268,7 +270,7 @@
    9.24      now = SDL_GetTicks();
    9.25      if (now > then) {
    9.26          double fps = ((double) frames * 1000) / (now - then);
    9.27 -        printf("%2.2f frames per second\n", fps);
    9.28 +        SDL_Log("%2.2f frames per second\n", fps);
    9.29      }
    9.30      return 0;
    9.31  }
    10.1 --- a/test/testdrawchessboard.c	Mon Aug 12 22:00:21 2013 -0700
    10.2 +++ b/test/testdrawchessboard.c	Wed Aug 14 23:30:10 2013 -0700
    10.3 @@ -54,10 +54,13 @@
    10.4  	SDL_Surface *surface;
    10.5  	SDL_Renderer *renderer;
    10.6  
    10.7 +    /* Enable standard application logging */
    10.8 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
    10.9 +
   10.10  	/* Initialize SDL */
   10.11  	if(SDL_Init(SDL_INIT_VIDEO) != 0)
   10.12  	{
   10.13 -		fprintf(stderr,"SDL_Init fail : %s\n", SDL_GetError());
   10.14 +		SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init fail : %s\n", SDL_GetError());
   10.15  		return 1;
   10.16  	}
   10.17  
   10.18 @@ -66,14 +69,14 @@
   10.19  	window = SDL_CreateWindow("Chess Board", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN);
   10.20  	if(!window)
   10.21  	{
   10.22 -		fprintf(stderr,"Window creation fail : %s\n",SDL_GetError());
   10.23 +		SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window creation fail : %s\n",SDL_GetError());
   10.24  		return 1;
   10.25  	}	
   10.26  	surface = SDL_GetWindowSurface(window);
   10.27  	renderer = SDL_CreateSoftwareRenderer(surface);
   10.28  	if(!renderer)
   10.29  	{
   10.30 -		fprintf(stderr,"Render creation for surface fail : %s\n",SDL_GetError());
   10.31 +		SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Render creation for surface fail : %s\n",SDL_GetError());
   10.32  		return 1;
   10.33  	}
   10.34  
    11.1 --- a/test/testerror.c	Mon Aug 12 22:00:21 2013 -0700
    11.2 +++ b/test/testerror.c	Wed Aug 14 23:30:10 2013 -0700
    11.3 @@ -36,10 +36,10 @@
    11.4      SDL_SetError("Thread %s (%lu) had a problem: %s",
    11.5                   (char *) data, SDL_ThreadID(), "nevermind");
    11.6      while (alive) {
    11.7 -        printf("Thread '%s' is alive!\n", (char *) data);
    11.8 +        SDL_Log("Thread '%s' is alive!\n", (char *) data);
    11.9          SDL_Delay(1 * 1000);
   11.10      }
   11.11 -    printf("Child thread error string: %s\n", SDL_GetError());
   11.12 +    SDL_Log("Child thread error string: %s\n", SDL_GetError());
   11.13      return (0);
   11.14  }
   11.15  
   11.16 @@ -48,9 +48,12 @@
   11.17  {
   11.18      SDL_Thread *thread;
   11.19  
   11.20 +    /* Enable standard application logging */
   11.21 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   11.22 +
   11.23      /* Load the SDL library */
   11.24      if (SDL_Init(0) < 0) {
   11.25 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   11.26 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
   11.27          return (1);
   11.28      }
   11.29  
   11.30 @@ -60,15 +63,15 @@
   11.31      alive = 1;
   11.32      thread = SDL_CreateThread(ThreadFunc, NULL, "#1");
   11.33      if (thread == NULL) {
   11.34 -        fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
   11.35 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
   11.36          quit(1);
   11.37      }
   11.38      SDL_Delay(5 * 1000);
   11.39 -    printf("Waiting for thread #1\n");
   11.40 +    SDL_Log("Waiting for thread #1\n");
   11.41      alive = 0;
   11.42      SDL_WaitThread(thread, NULL);
   11.43  
   11.44 -    printf("Main thread error string: %s\n", SDL_GetError());
   11.45 +    SDL_Log("Main thread error string: %s\n", SDL_GetError());
   11.46  
   11.47      SDL_Quit();
   11.48      return (0);
    12.1 --- a/test/testfile.c	Mon Aug 12 22:00:21 2013 -0700
    12.2 +++ b/test/testfile.c	Wed Aug 14 23:30:10 2013 -0700
    12.3 @@ -44,7 +44,6 @@
    12.4  static void
    12.5  cleanup(void)
    12.6  {
    12.7 -
    12.8      unlink(FBASENAME1);
    12.9      unlink(FBASENAME2);
   12.10  }
   12.11 @@ -52,8 +51,7 @@
   12.12  static void
   12.13  rwops_error_quit(unsigned line, SDL_RWops * rwops)
   12.14  {
   12.15 -
   12.16 -    printf("testfile.c(%d): failed\n", line);
   12.17 +    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "testfile.c(%d): failed\n", line);
   12.18      if (rwops) {
   12.19          rwops->close(rwops);    /* This calls SDL_FreeRW(rwops); */
   12.20      }
   12.21 @@ -71,6 +69,9 @@
   12.22      SDL_RWops *rwops = NULL;
   12.23      char test_buf[30];
   12.24  
   12.25 +    /* Enable standard application logging */
   12.26 +	SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   12.27 +
   12.28      cleanup();
   12.29  
   12.30  /* test 1 : basic argument test: all those calls to SDL_RWFromFile should fail */
   12.31 @@ -90,7 +91,7 @@
   12.32      rwops = SDL_RWFromFile("something", NULL);
   12.33      if (rwops)
   12.34          RWOP_ERR_QUIT(rwops);
   12.35 -    printf("test1 OK\n");
   12.36 +    SDL_Log("test1 OK\n");
   12.37  
   12.38  /* test 2 : check that inexistent file is not successfully opened/created when required */
   12.39  /* modes : r, r+ imply that file MUST exist
   12.40 @@ -123,7 +124,7 @@
   12.41          RWOP_ERR_QUIT(rwops);
   12.42      rwops->close(rwops);
   12.43      unlink(FBASENAME2);
   12.44 -    printf("test2 OK\n");
   12.45 +    SDL_Log("test2 OK\n");
   12.46  
   12.47  /* test 3 : creation, writing , reading, seeking,
   12.48              test : w mode, r mode, w+ mode
   12.49 @@ -201,7 +202,7 @@
   12.50      if (SDL_memcmp(test_buf, "12345678901234567890", 20))
   12.51          RWOP_ERR_QUIT(rwops);
   12.52      rwops->close(rwops);
   12.53 -    printf("test3 OK\n");
   12.54 +    SDL_Log("test3 OK\n");
   12.55  
   12.56  /* test 4: same in r+ mode */
   12.57      rwops = SDL_RWFromFile(FBASENAME1, "rb+");  /* write + read + file must exists, no truncation */
   12.58 @@ -236,7 +237,7 @@
   12.59      if (SDL_memcmp(test_buf, "12345678901234567890", 20))
   12.60          RWOP_ERR_QUIT(rwops);
   12.61      rwops->close(rwops);
   12.62 -    printf("test4 OK\n");
   12.63 +    SDL_Log("test4 OK\n");
   12.64  
   12.65  /* test5 : append mode */
   12.66      rwops = SDL_RWFromFile(FBASENAME1, "ab+");  /* write + read + append */
   12.67 @@ -277,7 +278,7 @@
   12.68      if (SDL_memcmp(test_buf, "123456789012345678901234567123", 30))
   12.69          RWOP_ERR_QUIT(rwops);
   12.70      rwops->close(rwops);
   12.71 -    printf("test5 OK\n");
   12.72 +    SDL_Log("test5 OK\n");
   12.73      cleanup();
   12.74      return 0;                   /* all ok */
   12.75  }
    13.1 --- a/test/testgamecontroller.c	Mon Aug 12 22:00:21 2013 -0700
    13.2 +++ b/test/testgamecontroller.c	Wed Aug 14 23:30:10 2013 -0700
    13.3 @@ -91,7 +91,7 @@
    13.4      const char *name = SDL_GameControllerName(gamecontroller);
    13.5      const char *basetitle = "Game Controller Test: ";
    13.6      const size_t titlelen = SDL_strlen(basetitle) + SDL_strlen(name) + 1;
    13.7 -    char *title = SDL_malloc(titlelen);
    13.8 +    char *title = (char *)SDL_malloc(titlelen);
    13.9      SDL_Window *window = NULL;
   13.10      SDL_Renderer *screen = NULL;
   13.11      int done = 0;
   13.12 @@ -107,13 +107,13 @@
   13.13                                SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH,
   13.14                                SCREEN_HEIGHT, 0);
   13.15      if (window == NULL) {
   13.16 -        fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError());
   13.17 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
   13.18          return;
   13.19      }
   13.20  
   13.21      screen = SDL_CreateRenderer(window, -1, 0);
   13.22      if (screen == NULL) {
   13.23 -        fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError());
   13.24 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
   13.25          SDL_DestroyWindow(window);
   13.26          return;
   13.27      }
   13.28 @@ -124,7 +124,7 @@
   13.29      SDL_RaiseWindow(window);
   13.30  
   13.31      /* Print info about the controller we are watching */
   13.32 -    printf("Watching controller %s\n",  name ? name : "Unknown Controller");
   13.33 +    SDL_Log("Watching controller %s\n",  name ? name : "Unknown Controller");
   13.34  
   13.35      /* Loop, getting controller events! */
   13.36      while (!done) {
   13.37 @@ -135,21 +135,21 @@
   13.38          while (SDL_PollEvent(&event)) {
   13.39              switch (event.type) {
   13.40              case SDL_CONTROLLERAXISMOTION:
   13.41 -                printf("Controller %d axis %d ('%s') value: %d\n",
   13.42 +                SDL_Log("Controller %d axis %d ('%s') value: %d\n",
   13.43                         event.caxis.which,
   13.44                         event.caxis.axis,
   13.45 -                       ControllerAxisName(event.caxis.axis),
   13.46 +                       ControllerAxisName((SDL_GameControllerAxis)event.caxis.axis),
   13.47                         event.caxis.value);
   13.48                  break;
   13.49              case SDL_CONTROLLERBUTTONDOWN:
   13.50 -                printf("Controller %d button %d ('%s') down\n",
   13.51 +                SDL_Log("Controller %d button %d ('%s') down\n",
   13.52                         event.cbutton.which, event.cbutton.button,
   13.53 -                       ControllerButtonName(event.cbutton.button));
   13.54 +                       ControllerButtonName((SDL_GameControllerButton)event.cbutton.button));
   13.55                  break;
   13.56              case SDL_CONTROLLERBUTTONUP:
   13.57 -                printf("Controller %d button %d ('%s') up\n",
   13.58 +                SDL_Log("Controller %d button %d ('%s') up\n",
   13.59                         event.cbutton.which, event.cbutton.button,
   13.60 -                       ControllerButtonName(event.cbutton.button));
   13.61 +                       ControllerButtonName((SDL_GameControllerButton)event.cbutton.button));
   13.62                  break;
   13.63              case SDL_KEYDOWN:
   13.64                  if (event.key.keysym.sym != SDLK_ESCAPE) {
   13.65 @@ -167,7 +167,7 @@
   13.66          /* Update visual controller state */
   13.67          SDL_SetRenderDrawColor(screen, 0x00, 0xFF, 0x00, SDL_ALPHA_OPAQUE);
   13.68          for (i = 0; i <SDL_CONTROLLER_BUTTON_MAX; ++i) {
   13.69 -            if (SDL_GameControllerGetButton(gamecontroller, i) == SDL_PRESSED) {
   13.70 +            if (SDL_GameControllerGetButton(gamecontroller, (SDL_GameControllerButton)i) == SDL_PRESSED) {
   13.71                  DrawRect(screen, i * 34, SCREEN_HEIGHT - 34, 32, 32);
   13.72              }
   13.73          }
   13.74 @@ -176,7 +176,7 @@
   13.75          for (i = 0; i < SDL_CONTROLLER_AXIS_MAX / 2; ++i) {
   13.76              /* Draw the X/Y axis */
   13.77              int x, y;
   13.78 -            x = (((int) SDL_GameControllerGetAxis(gamecontroller, i * 2 + 0)) + 32768);
   13.79 +            x = (((int) SDL_GameControllerGetAxis(gamecontroller, (SDL_GameControllerAxis)(i * 2 + 0))) + 32768);
   13.80              x *= SCREEN_WIDTH;
   13.81              x /= 65535;
   13.82              if (x < 0) {
   13.83 @@ -184,7 +184,7 @@
   13.84              } else if (x > (SCREEN_WIDTH - 16)) {
   13.85                  x = SCREEN_WIDTH - 16;
   13.86              }
   13.87 -            y = (((int) SDL_GameControllerGetAxis(gamecontroller, i * 2 + 1)) + 32768);
   13.88 +            y = (((int) SDL_GameControllerGetAxis(gamecontroller, (SDL_GameControllerAxis)(i * 2 + 1))) + 32768);
   13.89              y *= SCREEN_HEIGHT;
   13.90              y /= 65535;
   13.91              if (y < 0) {
   13.92 @@ -217,9 +217,12 @@
   13.93      char guid[64];
   13.94      SDL_GameController *gamecontroller;
   13.95  
   13.96 +    /* Enable standard application logging */
   13.97 +	SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   13.98 +
   13.99      /* Initialize SDL (Note: video is required to start event loop) */
  13.100      if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER ) < 0) {
  13.101 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
  13.102 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
  13.103          return 1;
  13.104      }
  13.105  
  13.106 @@ -238,22 +241,22 @@
  13.107          } else {
  13.108              name = SDL_JoystickNameForIndex(i);
  13.109          }
  13.110 -        printf("%s %d: %s (guid %s)\n", description, i, name ? name : "Unknown", guid);
  13.111 +        SDL_Log("%s %d: %s (guid %s)\n", description, i, name ? name : "Unknown", guid);
  13.112      }
  13.113 -    printf("There are %d game controller(s) attached (%d joystick(s))\n", nController, SDL_NumJoysticks());
  13.114 +    SDL_Log("There are %d game controller(s) attached (%d joystick(s))\n", nController, SDL_NumJoysticks());
  13.115  
  13.116      if (argv[1]) {
  13.117          int device = atoi(argv[1]);
  13.118          if (device >= SDL_NumJoysticks()) {
  13.119 -            printf("%i is an invalid joystick index.\n", device);
  13.120 +			SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%i is an invalid joystick index.\n", device);
  13.121              retcode = 1;
  13.122          } else {
  13.123              SDL_JoystickGetGUIDString(SDL_JoystickGetDeviceGUID(device),
  13.124                                        guid, sizeof (guid));
  13.125 -            printf("Attempting to open device %i, guid %s\n", device, guid);
  13.126 +            SDL_Log("Attempting to open device %i, guid %s\n", device, guid);
  13.127              gamecontroller = SDL_GameControllerOpen(device);
  13.128              if (gamecontroller == NULL) {
  13.129 -                printf("Couldn't open joystick %d: %s\n", device, SDL_GetError());
  13.130 +                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open joystick %d: %s\n", device, SDL_GetError());
  13.131                  retcode = 1;
  13.132              } else {
  13.133                  WatchGameController(gamecontroller);
  13.134 @@ -272,7 +275,7 @@
  13.135  int
  13.136  main(int argc, char *argv[])
  13.137  {
  13.138 -    fprintf(stderr, "SDL compiled without Joystick support.\n");
  13.139 +    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Joystick support.\n");
  13.140      exit(1);
  13.141  }
  13.142  
    14.1 --- a/test/testgesture.c	Mon Aug 12 22:00:21 2013 -0700
    14.2 +++ b/test/testgesture.c	Wed Aug 14 23:30:10 2013 -0700
    14.3 @@ -207,6 +207,9 @@
    14.4    SDL_bool quitting = SDL_FALSE;
    14.5    SDL_RWops *src;
    14.6  
    14.7 +  /* Enable standard application logging */
    14.8 +  SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
    14.9 +
   14.10    //gesture variables
   14.11    knob.r = .1f;
   14.12    knob.ang = 0;
    15.1 --- a/test/testgl2.c	Mon Aug 12 22:00:21 2013 -0700
    15.2 +++ b/test/testgl2.c	Wed Aug 14 23:30:10 2013 -0700
    15.3 @@ -181,6 +181,9 @@
    15.4      Uint32 then, now, frames;
    15.5      int status;
    15.6  
    15.7 +    /* Enable standard application logging */
    15.8 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
    15.9 +
   15.10      /* Initialize parameters */
   15.11      fsaa = 0;
   15.12      accel = -1;
   15.13 @@ -206,7 +209,7 @@
   15.14              }
   15.15          }
   15.16          if (consumed < 0) {
   15.17 -            fprintf(stderr, "Usage: %s %s [--fsaa n] [--accel n]\n", argv[0],
   15.18 +            SDL_Log("Usage: %s %s [--fsaa n] [--accel n]\n", argv[0],
   15.19                      SDLTest_CommonUsage(state));
   15.20              quit(1);
   15.21          }
   15.22 @@ -235,7 +238,7 @@
   15.23      /* Create OpenGL context */
   15.24      context = SDL_GL_CreateContext(state->windows[0]);
   15.25      if (!context) {
   15.26 -        fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
   15.27 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
   15.28          quit(2);
   15.29      }
   15.30  
   15.31 @@ -249,63 +252,63 @@
   15.32      }
   15.33  
   15.34      SDL_GetCurrentDisplayMode(0, &mode);
   15.35 -    printf("Screen BPP    : %d\n", SDL_BITSPERPIXEL(mode.format));
   15.36 -    printf("Swap Interval : %d\n", SDL_GL_GetSwapInterval());
   15.37 -    printf("\n");
   15.38 -    printf("Vendor        : %s\n", glGetString(GL_VENDOR));
   15.39 -    printf("Renderer      : %s\n", glGetString(GL_RENDERER));
   15.40 -    printf("Version       : %s\n", glGetString(GL_VERSION));
   15.41 -    printf("Extensions    : %s\n", glGetString(GL_EXTENSIONS));
   15.42 -    printf("\n");
   15.43 +    SDL_Log("Screen BPP    : %d\n", SDL_BITSPERPIXEL(mode.format));
   15.44 +    SDL_Log("Swap Interval : %d\n", SDL_GL_GetSwapInterval());
   15.45 +    SDL_Log("\n");
   15.46 +    SDL_Log("Vendor        : %s\n", glGetString(GL_VENDOR));
   15.47 +    SDL_Log("Renderer      : %s\n", glGetString(GL_RENDERER));
   15.48 +    SDL_Log("Version       : %s\n", glGetString(GL_VERSION));
   15.49 +    SDL_Log("Extensions    : %s\n", glGetString(GL_EXTENSIONS));
   15.50 +    SDL_Log("\n");
   15.51  
   15.52      status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
   15.53      if (!status) {
   15.54 -        printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
   15.55 +        SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
   15.56      } else {
   15.57 -        printf("Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError());
   15.58 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError());
   15.59      }
   15.60      status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
   15.61      if (!status) {
   15.62 -        printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
   15.63 +        SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
   15.64      } else {
   15.65 -        printf("Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError());
   15.66 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError());
   15.67      }
   15.68      status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
   15.69      if (!status) {
   15.70 -        printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
   15.71 +        SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
   15.72      } else {
   15.73 -        printf("Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError());
   15.74 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError());
   15.75      }
   15.76      status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
   15.77      if (!status) {
   15.78 -        printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value);
   15.79 +        SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value);
   15.80      } else {
   15.81 -        printf("Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError());
   15.82 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError());
   15.83      }
   15.84      if (fsaa) {
   15.85          status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
   15.86          if (!status) {
   15.87 -            printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
   15.88 +            SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
   15.89          } else {
   15.90 -            printf("Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
   15.91 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
   15.92                     SDL_GetError());
   15.93          }
   15.94          status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
   15.95          if (!status) {
   15.96 -            printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
   15.97 +            SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
   15.98                     value);
   15.99          } else {
  15.100 -            printf("Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
  15.101 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
  15.102                     SDL_GetError());
  15.103          }
  15.104      }
  15.105      if (accel >= 0) {
  15.106          status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
  15.107          if (!status) {
  15.108 -            printf("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel,
  15.109 +            SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel,
  15.110                     value);
  15.111          } else {
  15.112 -            printf("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
  15.113 +			SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
  15.114                     SDL_GetError());
  15.115          }
  15.116      }
  15.117 @@ -343,7 +346,7 @@
  15.118      /* Print out some timing information */
  15.119      now = SDL_GetTicks();
  15.120      if (now > then) {
  15.121 -        printf("%2.2f frames per second\n",
  15.122 +        SDL_Log("%2.2f frames per second\n",
  15.123                 ((double) frames * 1000) / (now - then));
  15.124      }
  15.125      quit(0);
  15.126 @@ -355,7 +358,7 @@
  15.127  int
  15.128  main(int argc, char *argv[])
  15.129  {
  15.130 -    printf("No OpenGL support on this system\n");
  15.131 +    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system\n");
  15.132      return 1;
  15.133  }
  15.134  
    16.1 --- a/test/testgles.c	Mon Aug 12 22:00:21 2013 -0700
    16.2 +++ b/test/testgles.c	Wed Aug 14 23:30:10 2013 -0700
    16.3 @@ -110,6 +110,9 @@
    16.4      Uint32 then, now, frames;
    16.5      int status;
    16.6  
    16.7 +    /* Enable standard application logging */
    16.8 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
    16.9 +
   16.10      /* Initialize parameters */
   16.11      fsaa = 0;
   16.12      accel = 0;
   16.13 @@ -143,7 +146,7 @@
   16.14              }
   16.15          }
   16.16          if (consumed < 0) {
   16.17 -            fprintf(stderr, "Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0],
   16.18 +            SDL_Log("Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0],
   16.19                      SDLTest_CommonUsage(state));
   16.20              quit(1);
   16.21          }
   16.22 @@ -169,7 +172,7 @@
   16.23  
   16.24      context = SDL_calloc(state->num_windows, sizeof(context));
   16.25      if (context == NULL) {
   16.26 -        fprintf(stderr, "Out of memory!\n");
   16.27 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
   16.28          quit(2);
   16.29      }
   16.30  
   16.31 @@ -177,7 +180,7 @@
   16.32      for (i = 0; i < state->num_windows; i++) {
   16.33          context[i] = SDL_GL_CreateContext(state->windows[i]);
   16.34          if (!context[i]) {
   16.35 -            fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
   16.36 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
   16.37              quit(2);
   16.38          }
   16.39      }
   16.40 @@ -189,65 +192,65 @@
   16.41      }
   16.42  
   16.43      SDL_GetCurrentDisplayMode(0, &mode);
   16.44 -    printf("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
   16.45 -    printf("\n");
   16.46 -    printf("Vendor     : %s\n", glGetString(GL_VENDOR));
   16.47 -    printf("Renderer   : %s\n", glGetString(GL_RENDERER));
   16.48 -    printf("Version    : %s\n", glGetString(GL_VERSION));
   16.49 -    printf("Extensions : %s\n", glGetString(GL_EXTENSIONS));
   16.50 -    printf("\n");
   16.51 +    SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
   16.52 +    SDL_Log("\n");
   16.53 +    SDL_Log("Vendor     : %s\n", glGetString(GL_VENDOR));
   16.54 +    SDL_Log("Renderer   : %s\n", glGetString(GL_RENDERER));
   16.55 +    SDL_Log("Version    : %s\n", glGetString(GL_VERSION));
   16.56 +    SDL_Log("Extensions : %s\n", glGetString(GL_EXTENSIONS));
   16.57 +    SDL_Log("\n");
   16.58  
   16.59      status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
   16.60      if (!status) {
   16.61 -        printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
   16.62 +        SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
   16.63      } else {
   16.64 -        fprintf(stderr, "Failed to get SDL_GL_RED_SIZE: %s\n",
   16.65 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n",
   16.66                  SDL_GetError());
   16.67      }
   16.68      status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
   16.69      if (!status) {
   16.70 -        printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
   16.71 +        SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
   16.72      } else {
   16.73 -        fprintf(stderr, "Failed to get SDL_GL_GREEN_SIZE: %s\n",
   16.74 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n",
   16.75                  SDL_GetError());
   16.76      }
   16.77      status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
   16.78      if (!status) {
   16.79 -        printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
   16.80 +        SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
   16.81      } else {
   16.82 -        fprintf(stderr, "Failed to get SDL_GL_BLUE_SIZE: %s\n",
   16.83 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n",
   16.84                  SDL_GetError());
   16.85      }
   16.86      status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
   16.87      if (!status) {
   16.88 -        printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
   16.89 +        SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
   16.90      } else {
   16.91 -        fprintf(stderr, "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
   16.92 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
   16.93                  SDL_GetError());
   16.94      }
   16.95      if (fsaa) {
   16.96          status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
   16.97          if (!status) {
   16.98 -            printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
   16.99 +            SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
  16.100          } else {
  16.101 -            fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
  16.102 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
  16.103                      SDL_GetError());
  16.104          }
  16.105          status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
  16.106          if (!status) {
  16.107 -            printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
  16.108 +            SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
  16.109                     value);
  16.110          } else {
  16.111 -            fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
  16.112 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
  16.113                      SDL_GetError());
  16.114          }
  16.115      }
  16.116      if (accel) {
  16.117          status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
  16.118          if (!status) {
  16.119 -            printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
  16.120 +            SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
  16.121          } else {
  16.122 -            fprintf(stderr, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
  16.123 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
  16.124                      SDL_GetError());
  16.125          }
  16.126      }
  16.127 @@ -258,7 +261,7 @@
  16.128  
  16.129          status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
  16.130          if (status) {
  16.131 -            printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
  16.132 +            SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
  16.133  
  16.134              /* Continue for next window */
  16.135              continue;
  16.136 @@ -292,7 +295,7 @@
  16.137                              if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
  16.138                                  status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
  16.139                                  if (status) {
  16.140 -                                    printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
  16.141 +                                    SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
  16.142                                      break;
  16.143                                  }
  16.144                                  /* Change view port to the new window dimensions */
  16.145 @@ -311,7 +314,7 @@
  16.146          for (i = 0; i < state->num_windows; ++i) {
  16.147              status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
  16.148              if (status) {
  16.149 -                printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
  16.150 +                SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
  16.151  
  16.152                  /* Continue for next window */
  16.153                  continue;
  16.154 @@ -324,7 +327,7 @@
  16.155      /* Print out some timing information */
  16.156      now = SDL_GetTicks();
  16.157      if (now > then) {
  16.158 -        printf("%2.2f frames per second\n",
  16.159 +        SDL_Log("%2.2f frames per second\n",
  16.160                 ((double) frames * 1000) / (now - then));
  16.161      }
  16.162      quit(0);
  16.163 @@ -336,7 +339,7 @@
  16.164  int
  16.165  main(int argc, char *argv[])
  16.166  {
  16.167 -    printf("No OpenGL ES support on this system\n");
  16.168 +    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL ES support on this system\n");
  16.169      return 1;
  16.170  }
  16.171  
    17.1 --- a/test/testhaptic.c	Mon Aug 12 22:00:21 2013 -0700
    17.2 +++ b/test/testhaptic.c	Wed Aug 14 23:30:10 2013 -0700
    17.3 @@ -26,7 +26,6 @@
    17.4   * includes
    17.5   */
    17.6  #include <stdlib.h>
    17.7 -#include <stdio.h>              /* printf */
    17.8  #include <string.h>             /* strstr */
    17.9  #include <ctype.h>              /* isdigit */
   17.10  
   17.11 @@ -62,12 +61,15 @@
   17.12      int nefx;
   17.13      unsigned int supported;
   17.14  
   17.15 +    /* Enable standard application logging */
   17.16 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   17.17 +
   17.18      name = NULL;
   17.19      index = -1;
   17.20      if (argc > 1) {
   17.21          name = argv[1];
   17.22          if ((strcmp(name, "--help") == 0) || (strcmp(name, "-h") == 0)) {
   17.23 -            printf("USAGE: %s [device]\n"
   17.24 +            SDL_Log("USAGE: %s [device]\n"
   17.25                     "If device is a two-digit number it'll use it as an index, otherwise\n"
   17.26                     "it'll use it as if it were part of the device's name.\n",
   17.27                     argv[0]);
   17.28 @@ -84,7 +86,7 @@
   17.29      /* Initialize the force feedbackness */
   17.30      SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK |
   17.31               SDL_INIT_HAPTIC);
   17.32 -    printf("%d Haptic devices detected.\n", SDL_NumHaptics());
   17.33 +    SDL_Log("%d Haptic devices detected.\n", SDL_NumHaptics());
   17.34      if (SDL_NumHaptics() > 0) {
   17.35          /* We'll just use index or the first force feedback device found */
   17.36          if (name == NULL) {
   17.37 @@ -98,7 +100,7 @@
   17.38              }
   17.39  
   17.40              if (i >= SDL_NumHaptics()) {
   17.41 -                printf("Unable to find device matching '%s', aborting.\n",
   17.42 +                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find device matching '%s', aborting.\n",
   17.43                         name);
   17.44                  return 1;
   17.45              }
   17.46 @@ -106,14 +108,14 @@
   17.47  
   17.48          haptic = SDL_HapticOpen(i);
   17.49          if (haptic == NULL) {
   17.50 -            printf("Unable to create the haptic device: %s\n",
   17.51 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n",
   17.52                     SDL_GetError());
   17.53              return 1;
   17.54          }
   17.55 -        printf("Device: %s\n", SDL_HapticName(i));
   17.56 +        SDL_Log("Device: %s\n", SDL_HapticName(i));
   17.57          HapticPrintSupported(haptic);
   17.58      } else {
   17.59 -        printf("No Haptic devices found!\n");
   17.60 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No Haptic devices found!\n");
   17.61          return 1;
   17.62      }
   17.63  
   17.64 @@ -125,10 +127,10 @@
   17.65      nefx = 0;
   17.66      supported = SDL_HapticQuery(haptic);
   17.67  
   17.68 -    printf("\nUploading effects\n");
   17.69 +    SDL_Log("\nUploading effects\n");
   17.70      /* First we'll try a SINE effect. */
   17.71      if (supported & SDL_HAPTIC_SINE) {
   17.72 -        printf("   effect %d: Sine Wave\n", nefx);
   17.73 +        SDL_Log("   effect %d: Sine Wave\n", nefx);
   17.74          efx[nefx].type = SDL_HAPTIC_SINE;
   17.75          efx[nefx].periodic.period = 1000;
   17.76          efx[nefx].periodic.magnitude = 0x4000;
   17.77 @@ -137,14 +139,14 @@
   17.78          efx[nefx].periodic.fade_length = 1000;
   17.79          id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
   17.80          if (id[nefx] < 0) {
   17.81 -            printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
   17.82 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
   17.83              abort_execution();
   17.84          }
   17.85          nefx++;
   17.86      }
   17.87      /* Now we'll try a SAWTOOTHUP */
   17.88      if (supported & SDL_HAPTIC_SAWTOOTHUP) {
   17.89 -        printf("   effect %d: Sawtooth Up\n", nefx);
   17.90 +        SDL_Log("   effect %d: Sawtooth Up\n", nefx);
   17.91          efx[nefx].type = SDL_HAPTIC_SAWTOOTHUP;
   17.92          efx[nefx].periodic.period = 500;
   17.93          efx[nefx].periodic.magnitude = 0x5000;
   17.94 @@ -153,14 +155,14 @@
   17.95          efx[nefx].periodic.fade_length = 1000;
   17.96          id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
   17.97          if (id[nefx] < 0) {
   17.98 -            printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
   17.99 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
  17.100              abort_execution();
  17.101          }
  17.102          nefx++;
  17.103      }
  17.104      /* Now the classical constant effect. */
  17.105      if (supported & SDL_HAPTIC_CONSTANT) {
  17.106 -        printf("   effect %d: Constant Force\n", nefx);
  17.107 +        SDL_Log("   effect %d: Constant Force\n", nefx);
  17.108          efx[nefx].type = SDL_HAPTIC_CONSTANT;
  17.109          efx[nefx].constant.direction.type = SDL_HAPTIC_POLAR;
  17.110          efx[nefx].constant.direction.dir[0] = 20000;    /* Force comes from the south-west. */
  17.111 @@ -170,14 +172,14 @@
  17.112          efx[nefx].constant.fade_length = 1000;
  17.113          id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
  17.114          if (id[nefx] < 0) {
  17.115 -            printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
  17.116 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
  17.117              abort_execution();
  17.118          }
  17.119          nefx++;
  17.120      }
  17.121      /* The cute spring effect. */
  17.122      if (supported & SDL_HAPTIC_SPRING) {
  17.123 -        printf("   effect %d: Condition Spring\n", nefx);
  17.124 +        SDL_Log("   effect %d: Condition Spring\n", nefx);
  17.125          efx[nefx].type = SDL_HAPTIC_SPRING;
  17.126          efx[nefx].condition.length = 5000;
  17.127          for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
  17.128 @@ -189,14 +191,14 @@
  17.129          }
  17.130          id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
  17.131          if (id[nefx] < 0) {
  17.132 -            printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
  17.133 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
  17.134              abort_execution();
  17.135          }
  17.136          nefx++;
  17.137      }
  17.138      /* The pretty awesome inertia effect. */
  17.139      if (supported & SDL_HAPTIC_INERTIA) {
  17.140 -        printf("   effect %d: Condition Inertia\n", nefx);
  17.141 +        SDL_Log("   effect %d: Condition Inertia\n", nefx);
  17.142          efx[nefx].type = SDL_HAPTIC_SPRING;
  17.143          efx[nefx].condition.length = 5000;
  17.144          for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
  17.145 @@ -207,7 +209,7 @@
  17.146          }
  17.147          id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
  17.148          if (id[nefx] < 0) {
  17.149 -            printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
  17.150 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
  17.151              abort_execution();
  17.152          }
  17.153          nefx++;
  17.154 @@ -215,24 +217,24 @@
  17.155  
  17.156      /* Finally we'll try a left/right effect. */
  17.157      if (supported & SDL_HAPTIC_LEFTRIGHT) {
  17.158 -        printf("   effect %d: Left/Right\n", nefx);
  17.159 +        SDL_Log("   effect %d: Left/Right\n", nefx);
  17.160          efx[nefx].type = SDL_HAPTIC_LEFTRIGHT;
  17.161          efx[nefx].leftright.length = 5000;
  17.162          efx[nefx].leftright.large_magnitude = 0x3000;
  17.163          efx[nefx].leftright.small_magnitude = 0xFFFF;
  17.164          id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
  17.165          if (id[nefx] < 0) {
  17.166 -            printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
  17.167 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
  17.168              abort_execution();
  17.169          }
  17.170          nefx++;
  17.171      }
  17.172  
  17.173  
  17.174 -    printf
  17.175 +    SDL_Log
  17.176          ("\nNow playing effects for 5 seconds each with 1 second delay between\n");
  17.177      for (i = 0; i < nefx; i++) {
  17.178 -        printf("   Playing effect %d\n", i);
  17.179 +        SDL_Log("   Playing effect %d\n", i);
  17.180          SDL_HapticRunEffect(haptic, id[i], 1);
  17.181          SDL_Delay(6000);        /* Effects only have length 5000 */
  17.182      }
  17.183 @@ -252,7 +254,7 @@
  17.184  static void
  17.185  abort_execution(void)
  17.186  {
  17.187 -    printf("\nAborting program execution.\n");
  17.188 +    SDL_Log("\nAborting program execution.\n");
  17.189  
  17.190      SDL_HapticClose(haptic);
  17.191      SDL_Quit();
  17.192 @@ -270,42 +272,42 @@
  17.193      unsigned int supported;
  17.194  
  17.195      supported = SDL_HapticQuery(haptic);
  17.196 -    printf("   Supported effects [%d effects, %d playing]:\n",
  17.197 +    SDL_Log("   Supported effects [%d effects, %d playing]:\n",
  17.198             SDL_HapticNumEffects(haptic), SDL_HapticNumEffectsPlaying(haptic));
  17.199      if (supported & SDL_HAPTIC_CONSTANT)
  17.200 -        printf("      constant\n");
  17.201 +        SDL_Log("      constant\n");
  17.202      if (supported & SDL_HAPTIC_SINE)
  17.203 -        printf("      sine\n");
  17.204 +        SDL_Log("      sine\n");
  17.205      /* !!! FIXME: put this back when we have more bits in 2.1 */
  17.206      /*if (supported & SDL_HAPTIC_SQUARE)
  17.207 -        printf("      square\n");*/
  17.208 +        SDL_Log("      square\n");*/
  17.209      if (supported & SDL_HAPTIC_TRIANGLE)
  17.210 -        printf("      triangle\n");
  17.211 +        SDL_Log("      triangle\n");
  17.212      if (supported & SDL_HAPTIC_SAWTOOTHUP)
  17.213 -        printf("      sawtoothup\n");
  17.214 +        SDL_Log("      sawtoothup\n");
  17.215      if (supported & SDL_HAPTIC_SAWTOOTHDOWN)
  17.216 -        printf("      sawtoothdown\n");
  17.217 +        SDL_Log("      sawtoothdown\n");
  17.218      if (supported & SDL_HAPTIC_RAMP)
  17.219 -        printf("      ramp\n");
  17.220 +        SDL_Log("      ramp\n");
  17.221      if (supported & SDL_HAPTIC_FRICTION)
  17.222 -        printf("      friction\n");
  17.223 +        SDL_Log("      friction\n");
  17.224      if (supported & SDL_HAPTIC_SPRING)
  17.225 -        printf("      spring\n");
  17.226 +        SDL_Log("      spring\n");
  17.227      if (supported & SDL_HAPTIC_DAMPER)
  17.228 -        printf("      damper\n");
  17.229 +        SDL_Log("      damper\n");
  17.230      if (supported & SDL_HAPTIC_INERTIA)
  17.231 -        printf("      intertia\n");
  17.232 +        SDL_Log("      inertia\n");
  17.233      if (supported & SDL_HAPTIC_CUSTOM)
  17.234 -        printf("      custom\n");
  17.235 +        SDL_Log("      custom\n");
  17.236      if (supported & SDL_HAPTIC_LEFTRIGHT)
  17.237 -        printf("      left/right\n");
  17.238 -    printf("   Supported capabilities:\n");
  17.239 +        SDL_Log("      left/right\n");
  17.240 +    SDL_Log("   Supported capabilities:\n");
  17.241      if (supported & SDL_HAPTIC_GAIN)
  17.242 -        printf("      gain\n");
  17.243 +        SDL_Log("      gain\n");
  17.244      if (supported & SDL_HAPTIC_AUTOCENTER)
  17.245 -        printf("      autocenter\n");
  17.246 +        SDL_Log("      autocenter\n");
  17.247      if (supported & SDL_HAPTIC_STATUS)
  17.248 -        printf("      status\n");
  17.249 +        SDL_Log("      status\n");
  17.250  }
  17.251  
  17.252  #else
  17.253 @@ -313,7 +315,7 @@
  17.254  int
  17.255  main(int argc, char *argv[])
  17.256  {
  17.257 -    fprintf(stderr, "SDL compiled without Haptic support.\n");
  17.258 +    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Haptic support.\n");
  17.259      exit(1);
  17.260  }
  17.261  
    18.1 --- a/test/testiconv.c	Mon Aug 12 22:00:21 2013 -0700
    18.2 +++ b/test/testiconv.c	Wed Aug 14 23:30:10 2013 -0700
    18.3 @@ -49,12 +49,15 @@
    18.4      FILE *file;
    18.5      int errors = 0;
    18.6  
    18.7 +    /* Enable standard application logging */
    18.8 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
    18.9 +
   18.10      if (!argv[1]) {
   18.11          argv[1] = "utf8.txt";
   18.12      }
   18.13      file = fopen(argv[1], "rb");
   18.14      if (!file) {
   18.15 -        fprintf(stderr, "Unable to open %s\n", argv[1]);
   18.16 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to open %s\n", argv[1]);
   18.17          return (1);
   18.18      }
   18.19  
   18.20 @@ -69,7 +72,7 @@
   18.21              test[0] = SDL_iconv_string(formats[i], "UCS-4", ucs4, len);
   18.22              test[1] = SDL_iconv_string("UCS-4", formats[i], test[0], len);
   18.23              if (!test[1] || SDL_memcmp(test[1], ucs4, len) != 0) {
   18.24 -                fprintf(stderr, "FAIL: %s\n", formats[i]);
   18.25 +                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "FAIL: %s\n", formats[i]);
   18.26                  ++errors;
   18.27              }
   18.28              if (test[0]) {
    19.1 --- a/test/testime.c	Mon Aug 12 22:00:21 2013 -0700
    19.2 +++ b/test/testime.c	Wed Aug 14 23:30:10 2013 -0700
    19.3 @@ -80,7 +80,7 @@
    19.4  
    19.5  void usage()
    19.6  {
    19.7 -    printf("usage: testime [--font fontfile]\n");
    19.8 +    SDL_Log("usage: testime [--font fontfile]\n");
    19.9      exit(0);
   19.10  }
   19.11  
   19.12 @@ -210,6 +210,9 @@
   19.13      SDL_Event event;
   19.14      const char *fontname = DEFAULT_FONT;
   19.15  
   19.16 +    /* Enable standard application logging */
   19.17 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   19.18 +
   19.19      /* Initialize test framework */
   19.20      state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
   19.21      if (!state) {
   19.22 @@ -251,12 +254,12 @@
   19.23      font = TTF_OpenFont(fontname, DEFAULT_PTSIZE);
   19.24      if (! font)
   19.25      {
   19.26 -        fprintf(stderr, "Failed to find font: %s\n", TTF_GetError());
   19.27 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to find font: %s\n", TTF_GetError());
   19.28          exit(-1);
   19.29      }
   19.30  #endif
   19.31  
   19.32 -    printf("Using font: %s\n", fontname);
   19.33 +    SDL_Log("Using font: %s\n", fontname);
   19.34      atexit(SDL_Quit);
   19.35  
   19.36      InitInput();
   19.37 @@ -321,8 +324,7 @@
   19.38                          break;
   19.39                      }
   19.40  
   19.41 -                    fprintf(stderr,
   19.42 -                            "Keyboard: scancode 0x%08X = %s, keycode 0x%08X = %s\n",
   19.43 +                    SDL_Log("Keyboard: scancode 0x%08X = %s, keycode 0x%08X = %s\n",
   19.44                              event.key.keysym.scancode,
   19.45                              SDL_GetScancodeName(event.key.keysym.scancode),
   19.46                              event.key.keysym.sym, SDL_GetKeyName(event.key.keysym.sym));
   19.47 @@ -333,12 +335,12 @@
   19.48                          markedRect.w < 0)
   19.49                          break;
   19.50  
   19.51 -                    fprintf(stderr, "Keyboard: text input \"%s\"\n", event.text.text);
   19.52 +                    SDL_Log("Keyboard: text input \"%s\"\n", event.text.text);
   19.53  
   19.54                      if (SDL_strlen(text) + SDL_strlen(event.text.text) < sizeof(text))
   19.55                          SDL_strlcat(text, event.text.text, sizeof(text));
   19.56  
   19.57 -                    fprintf(stderr, "text inputed: %s\n", text);
   19.58 +                    SDL_Log("text inputed: %s\n", text);
   19.59  
   19.60                      // After text inputed, we can clear up markedText because it
   19.61                      // is committed
   19.62 @@ -347,7 +349,7 @@
   19.63                      break;
   19.64  
   19.65                  case SDL_TEXTEDITING:
   19.66 -                    fprintf(stderr, "text editing \"%s\", selected range (%d, %d)\n",
   19.67 +                    SDL_Log("text editing \"%s\", selected range (%d, %d)\n",
   19.68                              event.edit.text, event.edit.start, event.edit.length);
   19.69  
   19.70                      strcpy(markedText, event.edit.text);
    20.1 --- a/test/testintersections.c	Mon Aug 12 22:00:21 2013 -0700
    20.2 +++ b/test/testintersections.c	Wed Aug 14 23:30:10 2013 -0700
    20.3 @@ -84,7 +84,7 @@
    20.4      if ((x1 == x2) && (y1 == y2))
    20.5          return 0;
    20.6  
    20.7 -    printf("adding line (%d, %d), (%d, %d)\n", x1, y1, x2, y2);
    20.8 +    SDL_Log("adding line (%d, %d), (%d, %d)\n", x1, y1, x2, y2);
    20.9      lines[num_lines].x = x1;
   20.10      lines[num_lines].y = y1;
   20.11      lines[num_lines].w = x2;
   20.12 @@ -133,7 +133,7 @@
   20.13      if (y1 > y2)
   20.14          SWAP(int, y1, y2);
   20.15  
   20.16 -    printf("adding rect (%d, %d), (%d, %d) [%dx%d]\n", x1, y1, x2, y2,
   20.17 +    SDL_Log("adding rect (%d, %d), (%d, %d) [%dx%d]\n", x1, y1, x2, y2,
   20.18             x2 - x1, y2 - y1);
   20.19  
   20.20      rects[num_rects].x = x1;
   20.21 @@ -199,6 +199,9 @@
   20.22      SDL_Event event;
   20.23      Uint32 then, now, frames;
   20.24  
   20.25 +    /* Enable standard application logging */
   20.26 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   20.27 +
   20.28      /* Initialize parameters */
   20.29      num_objects = NUM_OBJECTS;
   20.30  
   20.31 @@ -241,8 +244,7 @@
   20.32              }
   20.33          }
   20.34          if (consumed < 0) {
   20.35 -            fprintf(stderr,
   20.36 -                    "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
   20.37 +            SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
   20.38                      argv[0], SDLTest_CommonUsage(state));
   20.39              return 1;
   20.40          }
   20.41 @@ -327,7 +329,7 @@
   20.42      now = SDL_GetTicks();
   20.43      if (now > then) {
   20.44          double fps = ((double) frames * 1000) / (now - then);
   20.45 -        printf("%2.2f frames per second\n", fps);
   20.46 +        SDL_Log("%2.2f frames per second\n", fps);
   20.47      }
   20.48      return 0;
   20.49  }
    21.1 --- a/test/testjoystick.c	Mon Aug 12 22:00:21 2013 -0700
    21.2 +++ b/test/testjoystick.c	Wed Aug 14 23:30:10 2013 -0700
    21.3 @@ -52,13 +52,13 @@
    21.4                                SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH,
    21.5                                SCREEN_HEIGHT, 0);
    21.6      if (window == NULL) {
    21.7 -        fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError());
    21.8 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
    21.9          return SDL_FALSE;
   21.10      }
   21.11  
   21.12      screen = SDL_CreateRenderer(window, -1, 0);
   21.13      if (screen == NULL) {
   21.14 -        fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError());
   21.15 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
   21.16          SDL_DestroyWindow(window);
   21.17          return SDL_FALSE;
   21.18      }
   21.19 @@ -70,9 +70,9 @@
   21.20  
   21.21      /* Print info about the joystick we are watching */
   21.22      name = SDL_JoystickName(joystick);
   21.23 -    printf("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick),
   21.24 +    SDL_Log("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick),
   21.25             name ? name : "Unknown Joystick");
   21.26 -    printf("Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
   21.27 +    SDL_Log("Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
   21.28             SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick),
   21.29             SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick));
   21.30  
   21.31 @@ -85,36 +85,36 @@
   21.32          while (SDL_PollEvent(&event)) {
   21.33              switch (event.type) {
   21.34              case SDL_JOYAXISMOTION:
   21.35 -                printf("Joystick %d axis %d value: %d\n",
   21.36 +                SDL_Log("Joystick %d axis %d value: %d\n",
   21.37                         event.jaxis.which,
   21.38                         event.jaxis.axis, event.jaxis.value);
   21.39                  break;
   21.40              case SDL_JOYHATMOTION:
   21.41 -                printf("Joystick %d hat %d value:",
   21.42 +                SDL_Log("Joystick %d hat %d value:",
   21.43                         event.jhat.which, event.jhat.hat);
   21.44                  if (event.jhat.value == SDL_HAT_CENTERED)
   21.45 -                    printf(" centered");
   21.46 +                    SDL_Log(" centered");
   21.47                  if (event.jhat.value & SDL_HAT_UP)
   21.48 -                    printf(" up");
   21.49 +                    SDL_Log(" up");
   21.50                  if (event.jhat.value & SDL_HAT_RIGHT)
   21.51 -                    printf(" right");
   21.52 +                    SDL_Log(" right");
   21.53                  if (event.jhat.value & SDL_HAT_DOWN)
   21.54 -                    printf(" down");
   21.55 +                    SDL_Log(" down");
   21.56                  if (event.jhat.value & SDL_HAT_LEFT)
   21.57 -                    printf(" left");
   21.58 -                printf("\n");
   21.59 +                    SDL_Log(" left");
   21.60 +                SDL_Log("\n");
   21.61                  break;
   21.62              case SDL_JOYBALLMOTION:
   21.63 -                printf("Joystick %d ball %d delta: (%d,%d)\n",
   21.64 +                SDL_Log("Joystick %d ball %d delta: (%d,%d)\n",
   21.65                         event.jball.which,
   21.66                         event.jball.ball, event.jball.xrel, event.jball.yrel);
   21.67                  break;
   21.68              case SDL_JOYBUTTONDOWN:
   21.69 -                printf("Joystick %d button %d down\n",
   21.70 +                SDL_Log("Joystick %d button %d down\n",
   21.71                         event.jbutton.which, event.jbutton.button);
   21.72                  break;
   21.73              case SDL_JOYBUTTONUP:
   21.74 -                printf("Joystick %d button %d up\n",
   21.75 +                SDL_Log("Joystick %d button %d up\n",
   21.76                         event.jbutton.which, event.jbutton.button);
   21.77                  break;
   21.78              case SDL_KEYDOWN:
   21.79 @@ -211,31 +211,34 @@
   21.80      int i;
   21.81      SDL_Joystick *joystick;
   21.82  
   21.83 +    /* Enable standard application logging */
   21.84 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);	
   21.85 +
   21.86      /* Initialize SDL (Note: video is required to start event loop) */
   21.87      if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) {
   21.88 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   21.89 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
   21.90          exit(1);
   21.91      }
   21.92  
   21.93      /* Print information about the joysticks */
   21.94 -    printf("There are %d joysticks attached\n", SDL_NumJoysticks());
   21.95 +    SDL_Log("There are %d joysticks attached\n", SDL_NumJoysticks());
   21.96      for (i = 0; i < SDL_NumJoysticks(); ++i) {
   21.97          name = SDL_JoystickNameForIndex(i);
   21.98 -        printf("Joystick %d: %s\n", i, name ? name : "Unknown Joystick");
   21.99 +        SDL_Log("Joystick %d: %s\n", i, name ? name : "Unknown Joystick");
  21.100          joystick = SDL_JoystickOpen(i);
  21.101          if (joystick == NULL) {
  21.102 -            fprintf(stderr, "SDL_JoystickOpen(%d) failed: %s\n", i,
  21.103 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_JoystickOpen(%d) failed: %s\n", i,
  21.104                      SDL_GetError());
  21.105          } else {
  21.106              char guid[64];
  21.107              SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick),
  21.108                                        guid, sizeof (guid));
  21.109 -            printf("       axes: %d\n", SDL_JoystickNumAxes(joystick));
  21.110 -            printf("      balls: %d\n", SDL_JoystickNumBalls(joystick));
  21.111 -            printf("       hats: %d\n", SDL_JoystickNumHats(joystick));
  21.112 -            printf("    buttons: %d\n", SDL_JoystickNumButtons(joystick));
  21.113 -            printf("instance id: %d\n", SDL_JoystickInstanceID(joystick));
  21.114 -            printf("       guid: %s\n", guid);
  21.115 +            SDL_Log("       axes: %d\n", SDL_JoystickNumAxes(joystick));
  21.116 +            SDL_Log("      balls: %d\n", SDL_JoystickNumBalls(joystick));
  21.117 +            SDL_Log("       hats: %d\n", SDL_JoystickNumHats(joystick));
  21.118 +            SDL_Log("    buttons: %d\n", SDL_JoystickNumButtons(joystick));
  21.119 +            SDL_Log("instance id: %d\n", SDL_JoystickInstanceID(joystick));
  21.120 +            SDL_Log("       guid: %s\n", guid);
  21.121              SDL_JoystickClose(joystick);
  21.122          }
  21.123      }
  21.124 @@ -256,7 +259,7 @@
  21.125          while ( keepGoing ) {
  21.126              if (joystick == NULL) {
  21.127                  if ( !reportederror ) {
  21.128 -                    printf("Couldn't open joystick %d: %s\n", atoi(argv[1]), SDL_GetError());
  21.129 +                    SDL_Log("Couldn't open joystick %d: %s\n", atoi(argv[1]), SDL_GetError());
  21.130                      keepGoing = SDL_FALSE;
  21.131                      reportederror = SDL_TRUE;
  21.132                  }
  21.133 @@ -268,7 +271,7 @@
  21.134  
  21.135              joystick = NULL;
  21.136              if (keepGoing) {
  21.137 -                printf("Waiting for attach\n");
  21.138 +                SDL_Log("Waiting for attach\n");
  21.139              }
  21.140              while (keepGoing) {
  21.141                  SDL_WaitEvent(&event);
  21.142 @@ -296,7 +299,7 @@
  21.143  int
  21.144  main(int argc, char *argv[])
  21.145  {
  21.146 -    fprintf(stderr, "SDL compiled without Joystick support.\n");
  21.147 +    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Joystick support.\n");
  21.148      exit(1);
  21.149  }
  21.150  
    22.1 --- a/test/testkeys.c	Mon Aug 12 22:00:21 2013 -0700
    22.2 +++ b/test/testkeys.c	Wed Aug 14 23:30:10 2013 -0700
    22.3 @@ -24,12 +24,15 @@
    22.4  {
    22.5      SDL_Scancode scancode;
    22.6  
    22.7 +    /* Enable standard application logging */
    22.8 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
    22.9 +
   22.10      if (SDL_Init(SDL_INIT_VIDEO) < 0) {
   22.11 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   22.12 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
   22.13          exit(1);
   22.14      }
   22.15      for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) {
   22.16 -        printf("Scancode #%d, \"%s\"\n", scancode,
   22.17 +        SDL_Log("Scancode #%d, \"%s\"\n", scancode,
   22.18                 SDL_GetScancodeName(scancode));
   22.19      }
   22.20      SDL_Quit();
    23.1 --- a/test/testloadso.c	Mon Aug 12 22:00:21 2013 -0700
    23.2 +++ b/test/testloadso.c	Wed Aug 14 23:30:10 2013 -0700
    23.3 @@ -33,14 +33,14 @@
    23.4  
    23.5      if (argc != 3) {
    23.6          const char *app = argv[0];
    23.7 -        fprintf(stderr, "USAGE: %s <library> <functionname>\n", app);
    23.8 -        fprintf(stderr, "       %s --hello <lib with puts()>\n", app);
    23.9 +        SDL_Log("USAGE: %s <library> <functionname>\n", app);
   23.10 +        SDL_Log("       %s --hello <lib with puts()>\n", app);
   23.11          return 1;
   23.12      }
   23.13  
   23.14      /* Initialize SDL */
   23.15      if (SDL_Init(0) < 0) {
   23.16 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   23.17 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
   23.18          return 2;
   23.19      }
   23.20  
   23.21 @@ -55,23 +55,23 @@
   23.22  
   23.23      lib = SDL_LoadObject(libname);
   23.24      if (lib == NULL) {
   23.25 -        fprintf(stderr, "SDL_LoadObject('%s') failed: %s\n",
   23.26 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadObject('%s') failed: %s\n",
   23.27                  libname, SDL_GetError());
   23.28          retval = 3;
   23.29      } else {
   23.30          fn = (fntype) SDL_LoadFunction(lib, symname);
   23.31          if (fn == NULL) {
   23.32 -            fprintf(stderr, "SDL_LoadFunction('%s') failed: %s\n",
   23.33 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadFunction('%s') failed: %s\n",
   23.34                      symname, SDL_GetError());
   23.35              retval = 4;
   23.36          } else {
   23.37 -            printf("Found %s in %s at %p\n", symname, libname, fn);
   23.38 +            SDL_Log("Found %s in %s at %p\n", symname, libname, fn);
   23.39              if (hello) {
   23.40 -                printf("Calling function...\n");
   23.41 +                SDL_Log("Calling function...\n");
   23.42                  fflush(stdout);
   23.43                  fn("     HELLO, WORLD!\n");
   23.44 -                printf("...apparently, we survived.  :)\n");
   23.45 -                printf("Unloading library...\n");
   23.46 +                SDL_Log("...apparently, we survived.  :)\n");
   23.47 +                SDL_Log("Unloading library...\n");
   23.48                  fflush(stdout);
   23.49              }
   23.50          }
    24.1 --- a/test/testlock.c	Mon Aug 12 22:00:21 2013 -0700
    24.2 +++ b/test/testlock.c	Wed Aug 14 23:30:10 2013 -0700
    24.3 @@ -40,7 +40,7 @@
    24.4  void
    24.5  printid(void)
    24.6  {
    24.7 -    printf("Process %lu:  exiting\n", SDL_ThreadID());
    24.8 +    SDL_Log("Process %lu:  exiting\n", SDL_ThreadID());
    24.9  }
   24.10  
   24.11  void
   24.12 @@ -55,7 +55,7 @@
   24.13  {
   24.14      SDL_threadID id = SDL_ThreadID();
   24.15      int i;
   24.16 -    printf("Process %lu:  Cleaning up...\n", id == mainthread ? 0 : id);
   24.17 +    SDL_Log("Process %lu:  Cleaning up...\n", id == mainthread ? 0 : id);
   24.18      doterminate = 1;
   24.19      for (i = 0; i < 6; ++i)
   24.20          SDL_WaitThread(threads[i], NULL);
   24.21 @@ -69,23 +69,23 @@
   24.22      if (SDL_ThreadID() == mainthread)
   24.23          signal(SIGTERM, closemutex);
   24.24      while (!doterminate) {
   24.25 -        printf("Process %lu ready to work\n", SDL_ThreadID());
   24.26 +        SDL_Log("Process %lu ready to work\n", SDL_ThreadID());
   24.27          if (SDL_LockMutex(mutex) < 0) {
   24.28 -            fprintf(stderr, "Couldn't lock mutex: %s", SDL_GetError());
   24.29 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock mutex: %s", SDL_GetError());
   24.30              exit(1);
   24.31          }
   24.32 -        printf("Process %lu, working!\n", SDL_ThreadID());
   24.33 +        SDL_Log("Process %lu, working!\n", SDL_ThreadID());
   24.34          SDL_Delay(1 * 1000);
   24.35 -        printf("Process %lu, done!\n", SDL_ThreadID());
   24.36 +        SDL_Log("Process %lu, done!\n", SDL_ThreadID());
   24.37          if (SDL_UnlockMutex(mutex) < 0) {
   24.38 -            fprintf(stderr, "Couldn't unlock mutex: %s", SDL_GetError());
   24.39 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't unlock mutex: %s", SDL_GetError());
   24.40              exit(1);
   24.41          }
   24.42          /* If this sleep isn't done, then threads may starve */
   24.43          SDL_Delay(10);
   24.44      }
   24.45      if (SDL_ThreadID() == mainthread && doterminate) {
   24.46 -        printf("Process %lu:  raising SIGTERM\n", SDL_ThreadID());
   24.47 +        SDL_Log("Process %lu:  raising SIGTERM\n", SDL_ThreadID());
   24.48          raise(SIGTERM);
   24.49      }
   24.50      return (0);
   24.51 @@ -97,26 +97,29 @@
   24.52      int i;
   24.53      int maxproc = 6;
   24.54  
   24.55 +	/* Enable standard application logging */
   24.56 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   24.57 +
   24.58      /* Load the SDL library */
   24.59      if (SDL_Init(0) < 0) {
   24.60 -        fprintf(stderr, "%s\n", SDL_GetError());
   24.61 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
   24.62          exit(1);
   24.63      }
   24.64      atexit(SDL_Quit_Wrapper);
   24.65  
   24.66      if ((mutex = SDL_CreateMutex()) == NULL) {
   24.67 -        fprintf(stderr, "Couldn't create mutex: %s\n", SDL_GetError());
   24.68 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create mutex: %s\n", SDL_GetError());
   24.69          exit(1);
   24.70      }
   24.71  
   24.72      mainthread = SDL_ThreadID();
   24.73 -    printf("Main thread: %lu\n", mainthread);
   24.74 +    SDL_Log("Main thread: %lu\n", mainthread);
   24.75      atexit(printid);
   24.76      for (i = 0; i < maxproc; ++i) {
   24.77          char name[64];
   24.78          SDL_snprintf(name, sizeof (name), "Worker%d", i);
   24.79          if ((threads[i] = SDL_CreateThread(Run, name, NULL)) == NULL)
   24.80 -            fprintf(stderr, "Couldn't create thread!\n");
   24.81 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread!\n");
   24.82      }
   24.83      signal(SIGINT, terminate);
   24.84      Run(NULL);
    25.1 --- a/test/testmessage.c	Mon Aug 12 22:00:21 2013 -0700
    25.2 +++ b/test/testmessage.c	Wed Aug 14 23:30:10 2013 -0700
    25.3 @@ -62,7 +62,7 @@
    25.4  
    25.5      success = SDL_ShowMessageBox(&data, &button);
    25.6      if (success == -1) {
    25.7 -        printf("Error Presenting MessageBox: %s\n", SDL_GetError());
    25.8 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
    25.9          if (eventNumber) {
   25.10              SDL_UserEvent event;
   25.11              event.type = (intptr_t)eventNumber;
   25.12 @@ -72,7 +72,7 @@
   25.13              quit(2);
   25.14          }
   25.15      }
   25.16 -    printf("Pressed button: %d, %s\n", button, button == 1 ? "Cancel" : "OK");
   25.17 +    SDL_Log("Pressed button: %d, %s\n", button, button == 1 ? "Cancel" : "OK");
   25.18  
   25.19      if (eventNumber) {
   25.20          SDL_UserEvent event;
   25.21 @@ -88,12 +88,15 @@
   25.22  {
   25.23      int success;
   25.24  
   25.25 +	/* Enable standard application logging */
   25.26 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   25.27 +
   25.28      success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
   25.29                  "Simple MessageBox",
   25.30                  "This is a simple error MessageBox",
   25.31                  NULL);
   25.32      if (success == -1) {
   25.33 -        printf("Error Presenting MessageBox: %s\n", SDL_GetError());
   25.34 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
   25.35          quit(1);
   25.36      }
   25.37  
   25.38 @@ -102,7 +105,7 @@
   25.39                  "This is a simple MessageBox with a newline:\r\nHello world!",
   25.40                  NULL);
   25.41      if (success == -1) {
   25.42 -        printf("Error Presenting MessageBox: %s\n", SDL_GetError());
   25.43 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
   25.44          quit(1);
   25.45      }
   25.46  
   25.47 @@ -112,7 +115,7 @@
   25.48                  "Unicode text: '牛肉西蘭花' ...",
   25.49                  NULL);
   25.50      if (success == -1) {
   25.51 -        printf("Error Presenting MessageBox: %s\n", SDL_GetError());
   25.52 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
   25.53          quit(1);
   25.54      }
   25.55  
   25.56 @@ -122,7 +125,7 @@
   25.57                  "Unicode text and newline:\r\n'牛肉西蘭花'\n'牛肉西蘭花'",
   25.58                  NULL);
   25.59      if (success == -1) {
   25.60 -        printf("Error Presenting MessageBox: %s\n", SDL_GetError());
   25.61 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
   25.62          quit(1);
   25.63      }
   25.64  
   25.65 @@ -135,7 +138,7 @@
   25.66         subsystem on the main thread.
   25.67       */
   25.68      if (SDL_Init(SDL_INIT_VIDEO) < 0) {
   25.69 -        fprintf(stderr, "Couldn't initialize SDL video subsystem: %s\n", SDL_GetError());
   25.70 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video subsystem: %s\n", SDL_GetError());
   25.71          return (1);
   25.72      }
   25.73      {
   25.74 @@ -153,7 +156,7 @@
   25.75  
   25.76          SDL_WaitThread(thread, &status);
   25.77  
   25.78 -        printf("Message box thread return %i\n", status);
   25.79 +        SDL_Log("Message box thread return %i\n", status);
   25.80      }
   25.81  
   25.82      /* Test showing a message box with a parent window */
   25.83 @@ -166,7 +169,7 @@
   25.84                      "This is a simple error MessageBox with a parent window",
   25.85                      window);
   25.86          if (success == -1) {
   25.87 -            printf("Error Presenting MessageBox: %s\n", SDL_GetError());
   25.88 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
   25.89              quit(1);
   25.90          }
   25.91  
    26.1 --- a/test/testmultiaudio.c	Mon Aug 12 22:00:21 2013 -0700
    26.2 +++ b/test/testmultiaudio.c	Wed Aug 14 23:30:10 2013 -0700
    26.3 @@ -10,7 +10,6 @@
    26.4    freely.
    26.5  */
    26.6  #include "SDL.h"
    26.7 -#include <stdio.h>
    26.8  
    26.9  static SDL_AudioSpec spec;
   26.10  static Uint8 *sound = NULL;     /* Pointer to wave data */
   26.11 @@ -51,7 +50,7 @@
   26.12      int i;
   26.13  
   26.14      if (devcount > 64) {
   26.15 -        fprintf(stderr, "Too many devices (%d), clamping to 64...\n",
   26.16 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Too many devices (%d), clamping to 64...\n",
   26.17                  devcount);
   26.18          devcount = 64;
   26.19      }
   26.20 @@ -60,33 +59,33 @@
   26.21  
   26.22      for (i = 0; i < devcount; i++) {
   26.23          const char *devname = SDL_GetAudioDeviceName(i, 0);
   26.24 -        printf("playing on device #%d: ('%s')...", i, devname);
   26.25 +        SDL_Log("playing on device #%d: ('%s')...", i, devname);
   26.26          fflush(stdout);
   26.27  
   26.28          SDL_memset(&cbd[0], '\0', sizeof(callback_data));
   26.29          spec.userdata = &cbd[0];
   26.30          cbd[0].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL, 0);
   26.31          if (cbd[0].dev == 0) {
   26.32 -            printf("\nOpen device failed: %s\n", SDL_GetError());
   26.33 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device failed: %s\n", SDL_GetError());
   26.34          } else {
   26.35              SDL_PauseAudioDevice(cbd[0].dev, 0);
   26.36              while (!cbd[0].done)
   26.37                  SDL_Delay(100);
   26.38              SDL_PauseAudioDevice(cbd[0].dev, 1);
   26.39 -            printf("done.\n");
   26.40 +            SDL_Log("done.\n");
   26.41              SDL_CloseAudioDevice(cbd[0].dev);
   26.42          }
   26.43      }
   26.44  
   26.45      SDL_memset(cbd, '\0', sizeof(cbd));
   26.46  
   26.47 -    printf("playing on all devices...\n");
   26.48 +    SDL_Log("playing on all devices...\n");
   26.49      for (i = 0; i < devcount; i++) {
   26.50          const char *devname = SDL_GetAudioDeviceName(i, 0);
   26.51          spec.userdata = &cbd[i];
   26.52          cbd[i].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL, 0);
   26.53          if (cbd[i].dev == 0) {
   26.54 -            printf("Open device %d failed: %s\n", i, SDL_GetError());
   26.55 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device %d failed: %s\n", i, SDL_GetError());
   26.56          }
   26.57      }
   26.58  
   26.59 @@ -113,7 +112,7 @@
   26.60          }
   26.61      }
   26.62  
   26.63 -    printf("All done!\n");
   26.64 +    SDL_Log("All done!\n");
   26.65  }
   26.66  
   26.67  
   26.68 @@ -122,17 +121,20 @@
   26.69  {
   26.70      int devcount = 0;
   26.71  
   26.72 +	/* Enable standard application logging */
   26.73 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   26.74 +
   26.75      /* Load the SDL library */
   26.76      if (SDL_Init(SDL_INIT_AUDIO) < 0) {
   26.77 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   26.78 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
   26.79          return (1);
   26.80      }
   26.81  
   26.82 -    printf("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
   26.83 +    SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
   26.84  
   26.85      devcount = SDL_GetNumAudioDevices(0);
   26.86      if (devcount < 1) {
   26.87 -        fprintf(stderr, "Don't see any specific audio devices!\n");
   26.88 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Don't see any specific audio devices!\n");
   26.89      } else {
   26.90          if (argv[1] == NULL) {
   26.91              argv[1] = "sample.wav";
   26.92 @@ -140,7 +142,7 @@
   26.93  
   26.94          /* Load the wave file into memory */
   26.95          if (SDL_LoadWAV(argv[1], &spec, &sound, &soundlen) == NULL) {
   26.96 -            fprintf(stderr, "Couldn't load %s: %s\n", argv[1],
   26.97 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", argv[1],
   26.98                      SDL_GetError());
   26.99          } else {
  26.100              test_multi_audio(devcount);
    27.1 --- a/test/testnative.c	Mon Aug 12 22:00:21 2013 -0700
    27.2 +++ b/test/testnative.c	Wed Aug 14 23:30:10 2013 -0700
    27.3 @@ -58,7 +58,7 @@
    27.4      /* Load the sprite image */
    27.5      temp = SDL_LoadBMP(file);
    27.6      if (temp == NULL) {
    27.7 -        fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
    27.8 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
    27.9          return 0;
   27.10      }
   27.11  
   27.12 @@ -70,7 +70,7 @@
   27.13      /* Create textures from the image */
   27.14      sprite = SDL_CreateTextureFromSurface(renderer, temp);
   27.15      if (!sprite) {
   27.16 -        fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
   27.17 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
   27.18          SDL_FreeSurface(temp);
   27.19          return 0;
   27.20      }
   27.21 @@ -131,8 +131,11 @@
   27.22      int sprite_w, sprite_h;
   27.23      SDL_Event event;
   27.24  
   27.25 +	/* Enable standard application logging */
   27.26 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   27.27 +
   27.28      if (SDL_VideoInit(NULL) < 0) {
   27.29 -        fprintf(stderr, "Couldn't initialize SDL video: %s\n",
   27.30 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video: %s\n",
   27.31                  SDL_GetError());
   27.32          exit(1);
   27.33      }
   27.34 @@ -146,19 +149,19 @@
   27.35          }
   27.36      }
   27.37      if (!factory) {
   27.38 -        fprintf(stderr, "Couldn't find native window code for %s driver\n",
   27.39 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find native window code for %s driver\n",
   27.40                  driver);
   27.41          quit(2);
   27.42      }
   27.43 -    printf("Creating native window for %s driver\n", driver);
   27.44 +    SDL_Log("Creating native window for %s driver\n", driver);
   27.45      native_window = factory->CreateNativeWindow(WINDOW_W, WINDOW_H);
   27.46      if (!native_window) {
   27.47 -        fprintf(stderr, "Couldn't create native window\n");
   27.48 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create native window\n");
   27.49          quit(3);
   27.50      }
   27.51      window = SDL_CreateWindowFrom(native_window);
   27.52      if (!window) {
   27.53 -        fprintf(stderr, "Couldn't create SDL window: %s\n", SDL_GetError());
   27.54 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create SDL window: %s\n", SDL_GetError());
   27.55          quit(4);
   27.56      }
   27.57      SDL_SetWindowTitle(window, "SDL Native Window Test");
   27.58 @@ -166,7 +169,7 @@
   27.59      /* Create the renderer */
   27.60      renderer = SDL_CreateRenderer(window, -1, 0);
   27.61      if (!renderer) {
   27.62 -        fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError());
   27.63 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
   27.64          quit(5);
   27.65      }
   27.66  
   27.67 @@ -185,7 +188,7 @@
   27.68      positions = (SDL_Rect *) SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect));
   27.69      velocities = (SDL_Rect *) SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect));
   27.70      if (!positions || !velocities) {
   27.71 -        fprintf(stderr, "Out of memory!\n");
   27.72 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
   27.73          quit(2);
   27.74      }
   27.75      srand(time(NULL));
    28.1 --- a/test/testoverlay2.c	Mon Aug 12 22:00:21 2013 -0700
    28.2 +++ b/test/testoverlay2.c	Wed Aug 14 23:30:10 2013 -0700
    28.3 @@ -209,19 +209,18 @@
    28.4  static void
    28.5  PrintUsage(char *argv0)
    28.6  {
    28.7 -    fprintf(stderr, "Usage: %s [arg] [arg] [arg] ...\n", argv0);
    28.8 -    fprintf(stderr, "\n");
    28.9 -    fprintf(stderr, "Where 'arg' is any of the following options:\n");
   28.10 -    fprintf(stderr, "\n");
   28.11 -    fprintf(stderr, "    -fps <frames per second>\n");
   28.12 -    fprintf(stderr, "    -nodelay\n");
   28.13 -    fprintf(stderr, "    -format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n");
   28.14 -    fprintf(stderr, "    -scale <scale factor> (initial scale of the overlay)\n");
   28.15 -    fprintf(stderr, "    -help (shows this help)\n");
   28.16 -    fprintf(stderr, "\n");
   28.17 -    fprintf(stderr,
   28.18 -            "Press ESC to exit, or SPACE to freeze the movie while application running.\n");
   28.19 -    fprintf(stderr, "\n");
   28.20 +    SDL_Log("Usage: %s [arg] [arg] [arg] ...\n", argv0);
   28.21 +    SDL_Log("\n");
   28.22 +    SDL_Log("Where 'arg' is any of the following options:\n");
   28.23 +    SDL_Log("\n");
   28.24 +    SDL_Log("    -fps <frames per second>\n");
   28.25 +    SDL_Log("    -nodelay\n");
   28.26 +    SDL_Log("    -format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n");
   28.27 +    SDL_Log("    -scale <scale factor> (initial scale of the overlay)\n");
   28.28 +    SDL_Log("    -help (shows this help)\n");
   28.29 +    SDL_Log("\n");
   28.30 +    SDL_Log("Press ESC to exit, or SPACE to freeze the movie while application running.\n");
   28.31 +    SDL_Log("\n");
   28.32  }
   28.33  
   28.34  int
   28.35 @@ -246,8 +245,11 @@
   28.36      int scale = 5;
   28.37      SDL_bool done = SDL_FALSE;
   28.38  
   28.39 +    /* Enable standard application logging */
   28.40 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   28.41 +
   28.42      if (SDL_Init(SDL_INIT_VIDEO) < 0) {
   28.43 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   28.44 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
   28.45          return 3;
   28.46      }
   28.47  
   28.48 @@ -256,19 +258,19 @@
   28.49              if (argv[2]) {
   28.50                  fps = atoi(argv[2]);
   28.51                  if (fps == 0) {
   28.52 -                    fprintf(stderr,
   28.53 +                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
   28.54                              "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
   28.55                      quit(10);
   28.56                  }
   28.57                  if ((fps < 0) || (fps > 1000)) {
   28.58 -                    fprintf(stderr,
   28.59 +                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
   28.60                              "The -fps option must be in range from 1 to 1000, default is 12.\n");
   28.61                      quit(10);
   28.62                  }
   28.63                  argv += 2;
   28.64                  argc -= 2;
   28.65              } else {
   28.66 -                fprintf(stderr,
   28.67 +                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
   28.68                          "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
   28.69                  quit(10);
   28.70              }
   28.71 @@ -280,19 +282,19 @@
   28.72              if (argv[2]) {
   28.73                  scale = atoi(argv[2]);
   28.74                  if (scale == 0) {
   28.75 -                    fprintf(stderr,
   28.76 +                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
   28.77                              "The -scale option requires an argument [from 1 to 50], default is 5.\n");
   28.78                      quit(10);
   28.79                  }
   28.80                  if ((scale < 0) || (scale > 50)) {
   28.81 -                    fprintf(stderr,
   28.82 +                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
   28.83                              "The -scale option must be in range from 1 to 50, default is 5.\n");
   28.84                      quit(10);
   28.85                  }
   28.86                  argv += 2;
   28.87                  argc -= 2;
   28.88              } else {
   28.89 -                fprintf(stderr,
   28.90 +                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
   28.91                          "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
   28.92                  quit(10);
   28.93              }
   28.94 @@ -301,7 +303,7 @@
   28.95              PrintUsage(argv[0]);
   28.96              quit(0);
   28.97          } else {
   28.98 -            fprintf(stderr, "Unrecognized option: %s.\n", argv[1]);
   28.99 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unrecognized option: %s.\n", argv[1]);
  28.100              quit(10);
  28.101          }
  28.102          break;
  28.103 @@ -309,7 +311,7 @@
  28.104  
  28.105      RawMooseData = (Uint8 *) malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT);
  28.106      if (RawMooseData == NULL) {
  28.107 -        fprintf(stderr, "Can't allocate memory for movie !\n");
  28.108 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't allocate memory for movie !\n");
  28.109          free(RawMooseData);
  28.110          quit(1);
  28.111      }
  28.112 @@ -317,7 +319,7 @@
  28.113      /* load the trojan moose images */
  28.114      handle = SDL_RWFromFile("moose.dat", "rb");
  28.115      if (handle == NULL) {
  28.116 -        fprintf(stderr, "Can't find the file moose.dat !\n");
  28.117 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
  28.118          free(RawMooseData);
  28.119          quit(2);
  28.120      }
  28.121 @@ -335,21 +337,21 @@
  28.122                                window_w, window_h,
  28.123                                SDL_WINDOW_RESIZABLE);
  28.124      if (!window) {
  28.125 -        fprintf(stderr, "Couldn't set create window: %s\n", SDL_GetError());
  28.126 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError());
  28.127          free(RawMooseData);
  28.128          quit(4);
  28.129      }
  28.130  
  28.131      renderer = SDL_CreateRenderer(window, -1, 0);
  28.132      if (!renderer) {
  28.133 -        fprintf(stderr, "Couldn't set create renderer: %s\n", SDL_GetError());
  28.134 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError());
  28.135          free(RawMooseData);
  28.136          quit(4);
  28.137      }
  28.138  
  28.139      MooseTexture = SDL_CreateTexture(renderer, pixel_format, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H);
  28.140      if (!MooseTexture) {
  28.141 -        fprintf(stderr, "Couldn't set create texture: %s\n", SDL_GetError());
  28.142 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());
  28.143          free(RawMooseData);
  28.144          quit(5);
  28.145      }
    29.1 --- a/test/testplatform.c	Mon Aug 12 22:00:21 2013 -0700
    29.2 +++ b/test/testplatform.c	Wed Aug 14 23:30:10 2013 -0700
    29.3 @@ -35,30 +35,30 @@
    29.4  
    29.5      if (badsize(sizeof(Uint8), 1)) {
    29.6          if (verbose)
    29.7 -            printf("sizeof(Uint8) != 1, instead = %u\n",
    29.8 +            SDL_Log("sizeof(Uint8) != 1, instead = %u\n",
    29.9                     (unsigned int)sizeof(Uint8));
   29.10          ++error;
   29.11      }
   29.12      if (badsize(sizeof(Uint16), 2)) {
   29.13          if (verbose)
   29.14 -            printf("sizeof(Uint16) != 2, instead = %u\n",
   29.15 +            SDL_Log("sizeof(Uint16) != 2, instead = %u\n",
   29.16                     (unsigned int)sizeof(Uint16));
   29.17          ++error;
   29.18      }
   29.19      if (badsize(sizeof(Uint32), 4)) {
   29.20          if (verbose)
   29.21 -            printf("sizeof(Uint32) != 4, instead = %u\n",
   29.22 +            SDL_Log("sizeof(Uint32) != 4, instead = %u\n",
   29.23                     (unsigned int)sizeof(Uint32));
   29.24          ++error;
   29.25      }
   29.26      if (badsize(sizeof(Uint64), 8)) {
   29.27          if (verbose)
   29.28 -            printf("sizeof(Uint64) != 8, instead = %u\n",
   29.29 +            SDL_Log("sizeof(Uint64) != 8, instead = %u\n",
   29.30                     (unsigned int)sizeof(Uint64));
   29.31          ++error;
   29.32      }
   29.33      if (verbose && !error)
   29.34 -        printf("All data types are the expected size.\n");
   29.35 +        SDL_Log("All data types are the expected size.\n");
   29.36  
   29.37      return (error ? 1 : 0);
   29.38  }
   29.39 @@ -83,7 +83,7 @@
   29.40      swapped64 |= 0xDEADBEEF;
   29.41  
   29.42      if (verbose) {
   29.43 -        printf("Detected a %s endian machine.\n",
   29.44 +        SDL_Log("Detected a %s endian machine.\n",
   29.45                 (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big");
   29.46      }
   29.47      if ((*((char *) &value) >> 4) == 0x1) {
   29.48 @@ -93,44 +93,44 @@
   29.49      }
   29.50      if (real_byteorder != SDL_BYTEORDER) {
   29.51          if (verbose) {
   29.52 -            printf("Actually a %s endian machine!\n",
   29.53 +            SDL_Log("Actually a %s endian machine!\n",
   29.54                     (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big");
   29.55          }
   29.56          ++error;
   29.57      }
   29.58      if (verbose) {
   29.59 -        printf("Value 16 = 0x%X, swapped = 0x%X\n", value16,
   29.60 +        SDL_Log("Value 16 = 0x%X, swapped = 0x%X\n", value16,
   29.61                 SDL_Swap16(value16));
   29.62      }
   29.63      if (SDL_Swap16(value16) != swapped16) {
   29.64          if (verbose) {
   29.65 -            printf("16 bit value swapped incorrectly!\n");
   29.66 +            SDL_Log("16 bit value swapped incorrectly!\n");
   29.67          }
   29.68          ++error;
   29.69      }
   29.70      if (verbose) {
   29.71 -        printf("Value 32 = 0x%X, swapped = 0x%X\n", value32,
   29.72 +        SDL_Log("Value 32 = 0x%X, swapped = 0x%X\n", value32,
   29.73                 SDL_Swap32(value32));
   29.74      }
   29.75      if (SDL_Swap32(value32) != swapped32) {
   29.76          if (verbose) {
   29.77 -            printf("32 bit value swapped incorrectly!\n");
   29.78 +            SDL_Log("32 bit value swapped incorrectly!\n");
   29.79          }
   29.80          ++error;
   29.81      }
   29.82      if (verbose) {
   29.83  #ifdef _MSC_VER
   29.84 -        printf("Value 64 = 0x%I64X, swapped = 0x%I64X\n", value64,
   29.85 +        SDL_Log("Value 64 = 0x%I64X, swapped = 0x%I64X\n", value64,
   29.86                 SDL_Swap64(value64));
   29.87  #else
   29.88 -        printf("Value 64 = 0x%llX, swapped = 0x%llX\n",
   29.89 +        SDL_Log("Value 64 = 0x%llX, swapped = 0x%llX\n",
   29.90                 (unsigned long long) value64,
   29.91                 (unsigned long long) SDL_Swap64(value64));
   29.92  #endif
   29.93      }
   29.94      if (SDL_Swap64(value64) != swapped64) {
   29.95          if (verbose) {
   29.96 -            printf("64 bit value swapped incorrectly!\n");
   29.97 +            SDL_Log("64 bit value swapped incorrectly!\n");
   29.98          }
   29.99          ++error;
  29.100      }
  29.101 @@ -142,17 +142,17 @@
  29.102  TestCPUInfo(SDL_bool verbose)
  29.103  {
  29.104      if (verbose) {
  29.105 -        printf("CPU count: %d\n", SDL_GetCPUCount());
  29.106 -        printf("CPU cache line size: %d\n", SDL_GetCPUCacheLineSize());
  29.107 -        printf("RDTSC %s\n", SDL_HasRDTSC()? "detected" : "not detected");
  29.108 -        printf("AltiVec %s\n", SDL_HasAltiVec()? "detected" : "not detected");
  29.109 -        printf("MMX %s\n", SDL_HasMMX()? "detected" : "not detected");
  29.110 -        printf("3DNow! %s\n", SDL_Has3DNow()? "detected" : "not detected");
  29.111 -        printf("SSE %s\n", SDL_HasSSE()? "detected" : "not detected");
  29.112 -        printf("SSE2 %s\n", SDL_HasSSE2()? "detected" : "not detected");
  29.113 -        printf("SSE3 %s\n", SDL_HasSSE3()? "detected" : "not detected");
  29.114 -        printf("SSE4.1 %s\n", SDL_HasSSE41()? "detected" : "not detected");
  29.115 -        printf("SSE4.2 %s\n", SDL_HasSSE42()? "detected" : "not detected");
  29.116 +        SDL_Log("CPU count: %d\n", SDL_GetCPUCount());
  29.117 +        SDL_Log("CPU cache line size: %d\n", SDL_GetCPUCacheLineSize());
  29.118 +        SDL_Log("RDTSC %s\n", SDL_HasRDTSC()? "detected" : "not detected");
  29.119 +        SDL_Log("AltiVec %s\n", SDL_HasAltiVec()? "detected" : "not detected");
  29.120 +        SDL_Log("MMX %s\n", SDL_HasMMX()? "detected" : "not detected");
  29.121 +        SDL_Log("3DNow! %s\n", SDL_Has3DNow()? "detected" : "not detected");
  29.122 +        SDL_Log("SSE %s\n", SDL_HasSSE()? "detected" : "not detected");
  29.123 +        SDL_Log("SSE2 %s\n", SDL_HasSSE2()? "detected" : "not detected");
  29.124 +        SDL_Log("SSE3 %s\n", SDL_HasSSE3()? "detected" : "not detected");
  29.125 +        SDL_Log("SSE4.1 %s\n", SDL_HasSSE41()? "detected" : "not detected");
  29.126 +        SDL_Log("SSE4.2 %s\n", SDL_HasSSE42()? "detected" : "not detected");
  29.127      }
  29.128      return (0);
  29.129  }
  29.130 @@ -176,7 +176,7 @@
  29.131      {
  29.132          const SDL_assert_data *item = SDL_GetAssertionReport();
  29.133          while (item) {
  29.134 -            printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n",
  29.135 +            SDL_Log("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n",
  29.136                  item->condition, item->function, item->filename,
  29.137                  item->linenum, item->trigger_count,
  29.138                  item->always_ignore ? "yes" : "no");
  29.139 @@ -192,11 +192,14 @@
  29.140      SDL_bool verbose = SDL_TRUE;
  29.141      int status = 0;
  29.142  
  29.143 +    /* Enable standard application logging */
  29.144 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
  29.145 +
  29.146      if (argv[1] && (SDL_strcmp(argv[1], "-q") == 0)) {
  29.147          verbose = SDL_FALSE;
  29.148      }
  29.149      if (verbose) {
  29.150 -        printf("This system is running %s\n", SDL_GetPlatform());
  29.151 +        SDL_Log("This system is running %s\n", SDL_GetPlatform());
  29.152      }
  29.153  
  29.154      status += TestTypes(verbose);
    30.1 --- a/test/testpower.c	Mon Aug 12 22:00:21 2013 -0700
    30.2 +++ b/test/testpower.c	Wed Aug 14 23:30:10 2013 -0700
    30.3 @@ -21,7 +21,7 @@
    30.4      const SDL_PowerState state = SDL_GetPowerInfo(&seconds, &percent);
    30.5      char *statestr = NULL;
    30.6  
    30.7 -    printf("SDL-reported power info...\n");
    30.8 +    SDL_Log("SDL-reported power info...\n");
    30.9      switch (state) {
   30.10      case SDL_POWERSTATE_UNKNOWN:
   30.11          statestr = "Unknown";
   30.12 @@ -43,18 +43,18 @@
   30.13          break;
   30.14      }
   30.15  
   30.16 -    printf("State: %s\n", statestr);
   30.17 +    SDL_Log("State: %s\n", statestr);
   30.18  
   30.19      if (percent == -1) {
   30.20 -        printf("Percent left: unknown\n");
   30.21 +        SDL_Log("Percent left: unknown\n");
   30.22      } else {
   30.23 -        printf("Percent left: %d%%\n", percent);
   30.24 +        SDL_Log("Percent left: %d%%\n", percent);
   30.25      }
   30.26  
   30.27      if (seconds == -1) {
   30.28 -        printf("Time left: unknown\n");
   30.29 +        SDL_Log("Time left: unknown\n");
   30.30      } else {
   30.31 -        printf("Time left: %d minutes, %d seconds\n", (int) (seconds / 60),
   30.32 +        SDL_Log("Time left: %d minutes, %d seconds\n", (int) (seconds / 60),
   30.33                 (int) (seconds % 60));
   30.34      }
   30.35  }
   30.36 @@ -63,8 +63,11 @@
   30.37  int
   30.38  main(int argc, char *argv[])
   30.39  {
   30.40 +    /* Enable standard application logging */
   30.41 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   30.42 +
   30.43      if (SDL_Init(0) == -1) {
   30.44 -        fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError());
   30.45 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
   30.46          return 1;
   30.47      }
   30.48  
    31.1 --- a/test/testrelative.c	Mon Aug 12 22:00:21 2013 -0700
    31.2 +++ b/test/testrelative.c	Wed Aug 14 23:30:10 2013 -0700
    31.3 @@ -35,6 +35,8 @@
    31.4      int i, done;
    31.5      SDL_Event event;
    31.6  
    31.7 +	/* Enable standard application logging */
    31.8 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
    31.9  
   31.10      /* Initialize test framework */
   31.11      state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
   31.12 @@ -74,10 +76,8 @@
   31.13              switch(event.type) {
   31.14                  case SDL_MOUSEMOTION:
   31.15                  {
   31.16 -                    /*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);*/
   31.17                      rect.x += event.motion.xrel;
   31.18                      rect.y += event.motion.yrel;
   31.19 -
   31.20                  }
   31.21                  break;
   31.22              }
    32.1 --- a/test/testrendercopyex.c	Mon Aug 12 22:00:21 2013 -0700
    32.2 +++ b/test/testrendercopyex.c	Wed Aug 14 23:30:10 2013 -0700
    32.3 @@ -46,7 +46,7 @@
    32.4      /* Load the sprite image */
    32.5      temp = SDL_LoadBMP(file);
    32.6      if (temp == NULL) {
    32.7 -        fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
    32.8 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
    32.9          return NULL;
   32.10      }
   32.11  
   32.12 @@ -77,7 +77,7 @@
   32.13      /* Create textures from the image */
   32.14      texture = SDL_CreateTextureFromSurface(renderer, temp);
   32.15      if (!texture) {
   32.16 -        fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
   32.17 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
   32.18          SDL_FreeSurface(temp);
   32.19          return NULL;
   32.20      }
   32.21 @@ -139,6 +139,9 @@
   32.22      int frames;
   32.23      Uint32 then, now;
   32.24  
   32.25 +	/* Enable standard application logging */
   32.26 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   32.27 +
   32.28      /* Initialize test framework */
   32.29      state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
   32.30      if (!state) {
   32.31 @@ -149,7 +152,7 @@
   32.32  
   32.33          consumed = SDLTest_CommonArg(state, i);
   32.34          if (consumed == 0) {
   32.35 -            fprintf(stderr, "Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
   32.36 +            SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
   32.37              return 1;
   32.38          }
   32.39          i += consumed;
   32.40 @@ -193,7 +196,7 @@
   32.41      now = SDL_GetTicks();
   32.42      if (now > then) {
   32.43          double fps = ((double) frames * 1000) / (now - then);
   32.44 -        printf("%2.2f frames per second\n", fps);
   32.45 +        SDL_Log("%2.2f frames per second\n", fps);
   32.46      }
   32.47  
   32.48      SDL_stack_free(drawstates);
    33.1 --- a/test/testrendertarget.c	Mon Aug 12 22:00:21 2013 -0700
    33.2 +++ b/test/testrendertarget.c	Wed Aug 14 23:30:10 2013 -0700
    33.3 @@ -46,7 +46,7 @@
    33.4      /* Load the sprite image */
    33.5      temp = SDL_LoadBMP(file);
    33.6      if (temp == NULL) {
    33.7 -        fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
    33.8 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
    33.9          return NULL;
   33.10      }
   33.11  
   33.12 @@ -77,7 +77,7 @@
   33.13      /* Create textures from the image */
   33.14      texture = SDL_CreateTextureFromSurface(renderer, temp);
   33.15      if (!texture) {
   33.16 -        fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
   33.17 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
   33.18          SDL_FreeSurface(temp);
   33.19          return NULL;
   33.20      }
   33.21 @@ -114,7 +114,7 @@
   33.22          SDL_RenderCopy(s->renderer, A, NULL, NULL);
   33.23          SDL_RenderReadPixels(s->renderer, NULL, SDL_PIXELFORMAT_ARGB8888, &P, sizeof(P));
   33.24  
   33.25 -        printf("Blended pixel: 0x%8.8X\n", P);
   33.26 +        SDL_Log("Blended pixel: 0x%8.8X\n", P);
   33.27  
   33.28          SDL_DestroyTexture(A);
   33.29          SDL_DestroyTexture(B);
   33.30 @@ -218,6 +218,9 @@
   33.31      Uint32 then, now;
   33.32      SDL_bool test_composite = SDL_FALSE;
   33.33  
   33.34 +    /* Enable standard application logging */
   33.35 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   33.36 +
   33.37      /* Initialize test framework */
   33.38      state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
   33.39      if (!state) {
   33.40 @@ -235,8 +238,7 @@
   33.41              }
   33.42          }
   33.43          if (consumed < 0) {
   33.44 -            fprintf(stderr,
   33.45 -                    "Usage: %s %s [--composite]\n",
   33.46 +            SDL_Log("Usage: %s %s [--composite]\n",
   33.47                      argv[0], SDLTest_CommonUsage(state));
   33.48              quit(1);
   33.49          }
   33.50 @@ -289,7 +291,7 @@
   33.51      now = SDL_GetTicks();
   33.52      if (now > then) {
   33.53          double fps = ((double) frames * 1000) / (now - then);
   33.54 -        printf("%2.2f frames per second\n", fps);
   33.55 +        SDL_Log("%2.2f frames per second\n", fps);
   33.56      }
   33.57  
   33.58      SDL_stack_free(drawstates);
    34.1 --- a/test/testresample.c	Mon Aug 12 22:00:21 2013 -0700
    34.2 +++ b/test/testresample.c	Wed Aug 14 23:30:10 2013 -0700
    34.3 @@ -9,7 +9,7 @@
    34.4    including commercial applications, and to alter it and redistribute it
    34.5    freely.
    34.6  */
    34.7 -#include <stdio.h>
    34.8 +
    34.9  #include "SDL.h"
   34.10  
   34.11  int
   34.12 @@ -25,27 +25,30 @@
   34.13      int avgbytes = 0;
   34.14      SDL_RWops *io = NULL;
   34.15  
   34.16 +	/* Enable standard application logging */
   34.17 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   34.18 +
   34.19      if (argc != 4) {
   34.20 -        fprintf(stderr, "USAGE: %s in.wav out.wav newfreq\n", argv[0]);
   34.21 +        SDL_Log("USAGE: %s in.wav out.wav newfreq\n", argv[0]);
   34.22          return 1;
   34.23      }
   34.24  
   34.25      cvtfreq = SDL_atoi(argv[3]);
   34.26  
   34.27      if (SDL_Init(SDL_INIT_AUDIO) == -1) {
   34.28 -        fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError());
   34.29 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
   34.30          return 2;
   34.31      }
   34.32  
   34.33      if (SDL_LoadWAV(argv[1], &spec, &data, &len) == NULL) {
   34.34 -        fprintf(stderr, "failed to load %s: %s\n", argv[1], SDL_GetError());
   34.35 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to load %s: %s\n", argv[1], SDL_GetError());
   34.36          SDL_Quit();
   34.37          return 3;
   34.38      }
   34.39  
   34.40      if (SDL_BuildAudioCVT(&cvt, spec.format, spec.channels, spec.freq,
   34.41                            spec.format, spec.channels, cvtfreq) == -1) {
   34.42 -        fprintf(stderr, "failed to build CVT: %s\n", SDL_GetError());
   34.43 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to build CVT: %s\n", SDL_GetError());
   34.44          SDL_FreeWAV(data);
   34.45          SDL_Quit();
   34.46          return 4;
   34.47 @@ -54,7 +57,7 @@
   34.48      cvt.len = len;
   34.49      cvt.buf = (Uint8 *) SDL_malloc(len * cvt.len_mult);
   34.50      if (cvt.buf == NULL) {
   34.51 -        fprintf(stderr, "Out of memory.\n");
   34.52 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory.\n");
   34.53          SDL_FreeWAV(data);
   34.54          SDL_Quit();
   34.55          return 5;
   34.56 @@ -62,7 +65,7 @@
   34.57      SDL_memcpy(cvt.buf, data, len);
   34.58  
   34.59      if (SDL_ConvertAudio(&cvt) == -1) {
   34.60 -        fprintf(stderr, "Conversion failed: %s\n", SDL_GetError());
   34.61 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Conversion failed: %s\n", SDL_GetError());
   34.62          SDL_free(cvt.buf);
   34.63          SDL_FreeWAV(data);
   34.64          SDL_Quit();
   34.65 @@ -72,7 +75,7 @@
   34.66      /* write out a WAV header... */
   34.67      io = SDL_RWFromFile(argv[2], "wb");
   34.68      if (io == NULL) {
   34.69 -        fprintf(stderr, "fopen('%s') failed: %s\n", argv[2], SDL_GetError());
   34.70 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fopen('%s') failed: %s\n", argv[2], SDL_GetError());
   34.71          SDL_free(cvt.buf);
   34.72          SDL_FreeWAV(data);
   34.73          SDL_Quit();
   34.74 @@ -99,7 +102,7 @@
   34.75      SDL_RWwrite(io, cvt.buf, cvt.len_cvt, 1);
   34.76  
   34.77      if (SDL_RWclose(io) == -1) {
   34.78 -        fprintf(stderr, "fclose('%s') failed: %s\n", argv[2], SDL_GetError());
   34.79 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fclose('%s') failed: %s\n", argv[2], SDL_GetError());
   34.80          SDL_free(cvt.buf);
   34.81          SDL_FreeWAV(data);
   34.82          SDL_Quit();
    35.1 --- a/test/testrumble.c	Mon Aug 12 22:00:21 2013 -0700
    35.2 +++ b/test/testrumble.c	Wed Aug 14 23:30:10 2013 -0700
    35.3 @@ -26,7 +26,6 @@
    35.4   * includes
    35.5   */
    35.6  #include <stdlib.h>
    35.7 -#include <stdio.h>              /* printf */
    35.8  #include <string.h>             /* strstr */
    35.9  #include <ctype.h>              /* isdigit */
   35.10  
   35.11 @@ -51,12 +50,15 @@
   35.12      char *name;
   35.13      int index;
   35.14  
   35.15 +	/* Enable standard application logging */
   35.16 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   35.17 +
   35.18      name = NULL;
   35.19      index = -1;
   35.20      if (argc > 1) {
   35.21          name = argv[1];
   35.22          if ((strcmp(name, "--help") == 0) || (strcmp(name, "-h") == 0)) {
   35.23 -            printf("USAGE: %s [device]\n"
   35.24 +            SDL_Log("USAGE: %s [device]\n"
   35.25                     "If device is a two-digit number it'll use it as an index, otherwise\n"
   35.26                     "it'll use it as if it were part of the device's name.\n",
   35.27                     argv[0]);
   35.28 @@ -73,7 +75,7 @@
   35.29      /* Initialize the force feedbackness */
   35.30      SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK |
   35.31               SDL_INIT_HAPTIC);
   35.32 -    printf("%d Haptic devices detected.\n", SDL_NumHaptics());
   35.33 +    SDL_Log("%d Haptic devices detected.\n", SDL_NumHaptics());
   35.34      if (SDL_NumHaptics() > 0) {
   35.35          /* We'll just use index or the first force feedback device found */
   35.36          if (name == NULL) {
   35.37 @@ -87,7 +89,7 @@
   35.38              }
   35.39  
   35.40              if (i >= SDL_NumHaptics()) {
   35.41 -                printf("Unable to find device matching '%s', aborting.\n",
   35.42 +                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find device matching '%s', aborting.\n",
   35.43                         name);
   35.44                  return 1;
   35.45              }
   35.46 @@ -95,13 +97,13 @@
   35.47  
   35.48          haptic = SDL_HapticOpen(i);
   35.49          if (haptic == NULL) {
   35.50 -            printf("Unable to create the haptic device: %s\n",
   35.51 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n",
   35.52                     SDL_GetError());
   35.53              return 1;
   35.54          }
   35.55 -        printf("Device: %s\n", SDL_HapticName(i));
   35.56 +        SDL_Log("Device: %s\n", SDL_HapticName(i));
   35.57      } else {
   35.58 -        printf("No Haptic devices found!\n");
   35.59 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No Haptic devices found!\n");
   35.60          return 1;
   35.61      }
   35.62  
   35.63 @@ -109,25 +111,25 @@
   35.64      SDL_ClearError();
   35.65  
   35.66      if (SDL_HapticRumbleSupported(haptic) == SDL_FALSE) {
   35.67 -        printf("\nRumble not supported!\n");
   35.68 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Rumble not supported!\n");
   35.69          return 1;
   35.70      }
   35.71      if (SDL_HapticRumbleInit(haptic) != 0) {
   35.72 -        printf("\nFailed to initialize rumble: %s\n", SDL_GetError());
   35.73 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to initialize rumble: %s\n", SDL_GetError());
   35.74          return 1;
   35.75      }
   35.76 -    printf("Playing 2 second rumble at 0.5 magnitude.\n");
   35.77 +    SDL_Log("Playing 2 second rumble at 0.5 magnitude.\n");
   35.78      if (SDL_HapticRumblePlay(haptic, 0.5, 5000) != 0) {
   35.79 -       printf("\nFailed to play rumble: %s\n", SDL_GetError() );
   35.80 +       SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError() );
   35.81         return 1;
   35.82      }
   35.83      SDL_Delay(2000);
   35.84 -    printf("Stopping rumble.\n");
   35.85 +    SDL_Log("Stopping rumble.\n");
   35.86      SDL_HapticRumbleStop(haptic);
   35.87      SDL_Delay(2000);
   35.88 -    printf("Playing 2 second rumble at 0.3 magnitude.\n");
   35.89 +    SDL_Log("Playing 2 second rumble at 0.3 magnitude.\n");
   35.90      if (SDL_HapticRumblePlay(haptic, 0.3f, 5000) != 0) {
   35.91 -       printf("\nFailed to play rumble: %s\n", SDL_GetError() );
   35.92 +       SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError() );
   35.93         return 1;
   35.94      }
   35.95      SDL_Delay(2000);
   35.96 @@ -145,7 +147,7 @@
   35.97  int
   35.98  main(int argc, char *argv[])
   35.99  {
  35.100 -    fprintf(stderr, "SDL compiled without Haptic support.\n");
  35.101 +    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Haptic support.\n");
  35.102      exit(1);
  35.103  }
  35.104  
    36.1 --- a/test/testscale.c	Mon Aug 12 22:00:21 2013 -0700
    36.2 +++ b/test/testscale.c	Wed Aug 14 23:30:10 2013 -0700
    36.3 @@ -48,7 +48,7 @@
    36.4      /* Load the sprite image */
    36.5      temp = SDL_LoadBMP(file);
    36.6      if (temp == NULL) {
    36.7 -        fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
    36.8 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
    36.9          return NULL;
   36.10      }
   36.11  
   36.12 @@ -79,7 +79,7 @@
   36.13      /* Create textures from the image */
   36.14      texture = SDL_CreateTextureFromSurface(renderer, temp);
   36.15      if (!texture) {
   36.16 -        fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
   36.17 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
   36.18          SDL_FreeSurface(temp);
   36.19          return NULL;
   36.20      }
   36.21 @@ -129,6 +129,9 @@
   36.22      int frames;
   36.23      Uint32 then, now;
   36.24  
   36.25 +    /* Enable standard application logging */
   36.26 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   36.27 +
   36.28      /* Initialize test framework */
   36.29      state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
   36.30      if (!state) {
   36.31 @@ -139,7 +142,7 @@
   36.32  
   36.33          consumed = SDLTest_CommonArg(state, i);
   36.34          if (consumed == 0) {
   36.35 -            fprintf(stderr, "Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
   36.36 +            SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
   36.37              return 1;
   36.38          }
   36.39          i += consumed;
   36.40 @@ -183,7 +186,7 @@
   36.41      now = SDL_GetTicks();
   36.42      if (now > then) {
   36.43          double fps = ((double) frames * 1000) / (now - then);
   36.44 -        printf("%2.2f frames per second\n", fps);
   36.45 +        SDL_Log("%2.2f frames per second\n", fps);
   36.46      }
   36.47  
   36.48      SDL_stack_free(drawstates);
    37.1 --- a/test/testsem.c	Mon Aug 12 22:00:21 2013 -0700
    37.2 +++ b/test/testsem.c	Wed Aug 14 23:30:10 2013 -0700
    37.3 @@ -30,17 +30,15 @@
    37.4      int threadnum = (int) (uintptr_t) data;
    37.5      while (alive) {
    37.6          SDL_SemWait(sem);
    37.7 -        fprintf(stderr,
    37.8 -                "Thread number %d has got the semaphore (value = %d)!\n",
    37.9 +        SDL_Log("Thread number %d has got the semaphore (value = %d)!\n",
   37.10                  threadnum, SDL_SemValue(sem));
   37.11          SDL_Delay(200);
   37.12          SDL_SemPost(sem);
   37.13 -        fprintf(stderr,
   37.14 -                "Thread number %d has released the semaphore (value = %d)!\n",
   37.15 +        SDL_Log("Thread number %d has released the semaphore (value = %d)!\n",
   37.16                  threadnum, SDL_SemValue(sem));
   37.17          SDL_Delay(1);           /* For the scheduler */
   37.18      }
   37.19 -    printf("Thread number %d exiting.\n", threadnum);
   37.20 +    SDL_Log("Thread number %d exiting.\n", threadnum);
   37.21      return 0;
   37.22  }
   37.23  
   37.24 @@ -59,7 +57,7 @@
   37.25      int retval;
   37.26  
   37.27      sem = SDL_CreateSemaphore(0);
   37.28 -    printf("Waiting 2 seconds on semaphore\n");
   37.29 +    SDL_Log("Waiting 2 seconds on semaphore\n");
   37.30  
   37.31      start_ticks = SDL_GetTicks();
   37.32      retval = SDL_SemWaitTimeout(sem, 2000);
   37.33 @@ -69,13 +67,13 @@
   37.34  
   37.35      /* Accept a little offset in the effective wait */
   37.36      if (duration > 1900 && duration < 2050)
   37.37 -        printf("Wait done.\n");
   37.38 +        SDL_Log("Wait done.\n");
   37.39      else
   37.40 -        fprintf(stderr, "Wait took %d milliseconds\n", duration);
   37.41 +        SDL_Log("Wait took %d milliseconds\n", duration);
   37.42  
   37.43      /* Check to make sure the return value indicates timed out */
   37.44      if (retval != SDL_MUTEX_TIMEDOUT)
   37.45 -        fprintf(stderr, "SDL_SemWaitTimeout returned: %d; expected: %d\n", retval, SDL_MUTEX_TIMEDOUT);
   37.46 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_SemWaitTimeout returned: %d; expected: %d\n", retval, SDL_MUTEX_TIMEDOUT);
   37.47  }
   37.48  
   37.49  int
   37.50 @@ -85,14 +83,17 @@
   37.51      uintptr_t i;
   37.52      int init_sem;
   37.53  
   37.54 +	/* Enable standard application logging */
   37.55 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   37.56 +
   37.57      if (argc < 2) {
   37.58 -        fprintf(stderr, "Usage: %s init_value\n", argv[0]);
   37.59 +        SDL_Log("Usage: %s init_value\n", argv[0]);
   37.60          return (1);
   37.61      }
   37.62  
   37.63      /* Load the SDL library */
   37.64      if (SDL_Init(0) < 0) {
   37.65 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   37.66 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
   37.67          return (1);
   37.68      }
   37.69      signal(SIGTERM, killed);
   37.70 @@ -101,7 +102,7 @@
   37.71      init_sem = atoi(argv[1]);
   37.72      sem = SDL_CreateSemaphore(init_sem);
   37.73  
   37.74 -    printf("Running %d threads, semaphore value = %d\n", NUM_THREADS,
   37.75 +    SDL_Log("Running %d threads, semaphore value = %d\n", NUM_THREADS,
   37.76             init_sem);
   37.77      /* Create all the threads */
   37.78      for (i = 0; i < NUM_THREADS; ++i) {
   37.79 @@ -114,12 +115,12 @@
   37.80      SDL_Delay(10 * 1000);
   37.81  
   37.82      /* Wait for all threads to finish */
   37.83 -    printf("Waiting for threads to finish\n");
   37.84 +    SDL_Log("Waiting for threads to finish\n");
   37.85      alive = 0;
   37.86      for (i = 0; i < NUM_THREADS; ++i) {
   37.87          SDL_WaitThread(threads[i], NULL);
   37.88      }
   37.89 -    printf("Finished waiting for threads\n");
   37.90 +    SDL_Log("Finished waiting for threads\n");
   37.91  
   37.92      SDL_DestroySemaphore(sem);
   37.93  
    38.1 --- a/test/testshader.c	Mon Aug 12 22:00:21 2013 -0700
    38.2 +++ b/test/testshader.c	Wed Aug 14 23:30:10 2013 -0700
    38.3 @@ -11,7 +11,6 @@
    38.4  */
    38.5  /* This is a simple example of using GLSL shaders with SDL */
    38.6  
    38.7 -#include <stdio.h> /* for printf() */
    38.8  #include "SDL.h"
    38.9  
   38.10  #ifdef HAVE_OPENGL
   38.11 @@ -139,7 +138,7 @@
   38.12          glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
   38.13          info = SDL_stack_alloc(char, length+1);
   38.14          glGetInfoLogARB(shader, length, NULL, info);
   38.15 -        fprintf(stderr, "Failed to compile shader:\n%s\n%s", source, info);
   38.16 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to compile shader:\n%s\n%s", source, info);
   38.17          SDL_stack_free(info);
   38.18  
   38.19          return SDL_FALSE;
   38.20 @@ -245,7 +244,7 @@
   38.21      /* Compile all the shaders */
   38.22      for (i = 0; i < NUM_SHADERS; ++i) {
   38.23          if (!CompileShaderProgram(&shaders[i])) {
   38.24 -            fprintf(stderr, "Unable to compile shader!\n");
   38.25 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to compile shader!\n");
   38.26              return SDL_FALSE;
   38.27          }
   38.28      }
   38.29 @@ -422,29 +421,32 @@
   38.30      GLuint texture;
   38.31      GLfloat texcoords[4];
   38.32  
   38.33 +	/* Enable standard application logging */
   38.34 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   38.35 +
   38.36      /* Initialize SDL for video output */
   38.37      if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
   38.38 -        fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
   38.39 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to initialize SDL: %s\n", SDL_GetError());
   38.40          exit(1);
   38.41      }
   38.42  
   38.43      /* Create a 640x480 OpenGL screen */
   38.44      window = SDL_CreateWindow( "Shader Demo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_OPENGL );
   38.45      if ( !window ) {
   38.46 -        fprintf(stderr, "Unable to create OpenGL window: %s\n", SDL_GetError());
   38.47 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL window: %s\n", SDL_GetError());
   38.48          SDL_Quit();
   38.49          exit(2);
   38.50      }
   38.51  
   38.52      if ( !SDL_GL_CreateContext(window)) {
   38.53 -        fprintf(stderr, "Unable to create OpenGL context: %s\n", SDL_GetError());
   38.54 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL context: %s\n", SDL_GetError());
   38.55          SDL_Quit();
   38.56          exit(2);
   38.57      }
   38.58  
   38.59      surface = SDL_LoadBMP("icon.bmp");
   38.60      if ( ! surface ) {
   38.61 -        fprintf(stderr, "Unable to load icon.bmp: %s\n", SDL_GetError());
   38.62 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to load icon.bmp: %s\n", SDL_GetError());
   38.63          SDL_Quit();
   38.64          exit(3);
   38.65      }
   38.66 @@ -454,9 +456,9 @@
   38.67      /* Loop, drawing and checking events */
   38.68      InitGL(640, 480);
   38.69      if (InitShaders()) {
   38.70 -        printf("Shaders supported, press SPACE to cycle them.\n");
   38.71 +        SDL_Log("Shaders supported, press SPACE to cycle them.\n");
   38.72      } else {
   38.73 -        printf("Shaders not supported!\n");
   38.74 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Shaders not supported!\n");
   38.75      }
   38.76      done = 0;
   38.77      while ( ! done ) {
   38.78 @@ -489,7 +491,7 @@
   38.79  int
   38.80  main(int argc, char *argv[])
   38.81  {
   38.82 -    printf("No OpenGL support on this system\n");
   38.83 +    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system\n");
   38.84      return 1;
   38.85  }
   38.86  
    39.1 --- a/test/testshape.c	Mon Aug 12 22:00:21 2013 -0700
    39.2 +++ b/test/testshape.c	Wed Aug 14 23:30:10 2013 -0700
    39.3 @@ -68,13 +68,16 @@
    39.4      int access = 0;
    39.5      SDL_Rect texture_dimensions;;
    39.6  
    39.7 +    /* Enable standard application logging */
    39.8 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
    39.9 +
   39.10      if(argc < 2) {
   39.11 -        printf("SDL_Shape requires at least one bitmap file as argument.\n");
   39.12 +		SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Shape requires at least one bitmap file as argument.");
   39.13          exit(-1);
   39.14      }
   39.15  
   39.16      if(SDL_VideoInit(NULL) == -1) {
   39.17 -        printf("Could not initialize SDL video.\n");
   39.18 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not initialize SDL video.");
   39.19          exit(-2);
   39.20      }
   39.21  
   39.22 @@ -91,7 +94,7 @@
   39.23                      SDL_FreeSurface(pictures[j].surface);
   39.24              SDL_free(pictures);
   39.25              SDL_VideoQuit();
   39.26 -            printf("Could not load surface from named bitmap file.\n");
   39.27 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not load surface from named bitmap file.");
   39.28              exit(-3);
   39.29          }
   39.30  
   39.31 @@ -112,7 +115,7 @@
   39.32              SDL_FreeSurface(pictures[i].surface);
   39.33          SDL_free(pictures);
   39.34          SDL_VideoQuit();
   39.35 -        printf("Could not create shaped window for SDL_Shape.\n");
   39.36 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create shaped window for SDL_Shape.");
   39.37          exit(-4);
   39.38      }
   39.39      renderer = SDL_CreateRenderer(window,-1,0);
   39.40 @@ -122,7 +125,7 @@
   39.41              SDL_FreeSurface(pictures[i].surface);
   39.42          SDL_free(pictures);
   39.43          SDL_VideoQuit();
   39.44 -        printf("Could not create rendering context for SDL_Shape window.\n");
   39.45 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create rendering context for SDL_Shape window.");
   39.46          exit(-5);
   39.47      }
   39.48  
   39.49 @@ -141,7 +144,7 @@
   39.50              SDL_DestroyRenderer(renderer);
   39.51              SDL_DestroyWindow(window);
   39.52              SDL_VideoQuit();
   39.53 -            printf("Could not create texture for SDL_shape.\n");
   39.54 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create texture for SDL_shape.");
   39.55              exit(-6);
   39.56          }
   39.57      }
    40.1 --- a/test/testsprite2.c	Mon Aug 12 22:00:21 2013 -0700
    40.2 +++ b/test/testsprite2.c	Wed Aug 14 23:30:10 2013 -0700
    40.3 @@ -64,7 +64,7 @@
    40.4      /* Load the sprite image */
    40.5      temp = SDL_LoadBMP(file);
    40.6      if (temp == NULL) {
    40.7 -        fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
    40.8 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
    40.9          return (-1);
   40.10      }
   40.11      sprite_w = temp->w;
   40.12 @@ -95,7 +95,7 @@
   40.13          SDL_Renderer *renderer = state->renderers[i];
   40.14          sprites[i] = SDL_CreateTextureFromSurface(renderer, temp);
   40.15          if (!sprites[i]) {
   40.16 -            fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
   40.17 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
   40.18              SDL_FreeSurface(temp);
   40.19              return (-1);
   40.20          }
   40.21 @@ -299,8 +299,7 @@
   40.22              }
   40.23          }
   40.24          if (consumed < 0) {
   40.25 -            fprintf(stderr,
   40.26 -                    "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha] [--iterations N] [num_sprites] [icon.bmp]\n",
   40.27 +            SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha] [--iterations N] [num_sprites] [icon.bmp]\n",
   40.28                      argv[0], SDLTest_CommonUsage(state));
   40.29              quit(1);
   40.30          }
   40.31 @@ -314,7 +313,7 @@
   40.32      sprites =
   40.33          (SDL_Texture **) SDL_malloc(state->num_windows * sizeof(*sprites));
   40.34      if (!sprites) {
   40.35 -        fprintf(stderr, "Out of memory!\n");
   40.36 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
   40.37          quit(2);
   40.38      }
   40.39      for (i = 0; i < state->num_windows; ++i) {
   40.40 @@ -330,7 +329,7 @@
   40.41      positions = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect));
   40.42      velocities = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect));
   40.43      if (!positions || !velocities) {
   40.44 -        fprintf(stderr, "Out of memory!\n");
   40.45 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
   40.46          quit(2);
   40.47      }
   40.48  
   40.49 @@ -375,7 +374,7 @@
   40.50      now = SDL_GetTicks();
   40.51      if (now > then) {
   40.52          double fps = ((double) frames * 1000) / (now - then);
   40.53 -        printf("%2.2f frames per second\n", fps);
   40.54 +        SDL_Log("%2.2f frames per second\n", fps);
   40.55      }
   40.56      quit(0);
   40.57      return 0;
    41.1 --- a/test/testspriteminimal.c	Mon Aug 12 22:00:21 2013 -0700
    41.2 +++ b/test/testspriteminimal.c	Wed Aug 14 23:30:10 2013 -0700
    41.3 @@ -42,7 +42,7 @@
    41.4      /* Load the sprite image */
    41.5      temp = SDL_LoadBMP(file);
    41.6      if (temp == NULL) {
    41.7 -        fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
    41.8 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", file, SDL_GetError());
    41.9          return (-1);
   41.10      }
   41.11      sprite_w = temp->w;
   41.12 @@ -73,7 +73,7 @@
   41.13      /* Create textures from the image */
   41.14      sprite = SDL_CreateTextureFromSurface(renderer, temp);
   41.15      if (!sprite) {
   41.16 -        fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
   41.17 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
   41.18          SDL_FreeSurface(temp);
   41.19          return (-1);
   41.20      }
   41.21 @@ -126,6 +126,9 @@
   41.22      int i, done;
   41.23      SDL_Event event;
   41.24  
   41.25 +	/* Enable standard application logging */
   41.26 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   41.27 +
   41.28      if (SDL_CreateWindowAndRenderer(WINDOW_WIDTH, WINDOW_HEIGHT, 0, &window, &renderer) < 0) {
   41.29          quit(2);
   41.30      }
    42.1 --- a/test/teststreaming.c	Mon Aug 12 22:00:21 2013 -0700
    42.2 +++ b/test/teststreaming.c	Wed Aug 14 23:30:10 2013 -0700
    42.3 @@ -68,7 +68,7 @@
    42.4      int pitch;
    42.5  
    42.6      if (SDL_LockTexture(texture, NULL, &pixels, &pitch) < 0) {
    42.7 -        fprintf(stderr, "Couldn't lock texture: %s\n", SDL_GetError());
    42.8 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock texture: %s\n", SDL_GetError());
    42.9          quit(5);
   42.10      }
   42.11      src = MooseFrames[frame];
   42.12 @@ -93,15 +93,18 @@
   42.13      SDL_bool done = SDL_FALSE;
   42.14      int frame;
   42.15  
   42.16 +	/* Enable standard application logging */
   42.17 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   42.18 +
   42.19      if (SDL_Init(SDL_INIT_VIDEO) < 0) {
   42.20 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   42.21 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
   42.22          return 1;
   42.23      }
   42.24  
   42.25      /* load the moose images */
   42.26      handle = SDL_RWFromFile("moose.dat", "rb");
   42.27      if (handle == NULL) {
   42.28 -        fprintf(stderr, "Can't find the file moose.dat !\n");
   42.29 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
   42.30          quit(2);
   42.31      }
   42.32      SDL_RWread(handle, MooseFrames, MOOSEFRAME_SIZE, MOOSEFRAMES_COUNT);
   42.33 @@ -115,19 +118,19 @@
   42.34                                MOOSEPIC_W*4, MOOSEPIC_H*4,
   42.35                                SDL_WINDOW_RESIZABLE);
   42.36      if (!window) {
   42.37 -        fprintf(stderr, "Couldn't set create window: %s\n", SDL_GetError());
   42.38 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError());
   42.39          quit(3);
   42.40      }
   42.41  
   42.42      renderer = SDL_CreateRenderer(window, -1, 0);
   42.43      if (!renderer) {
   42.44 -        fprintf(stderr, "Couldn't set create renderer: %s\n", SDL_GetError());
   42.45 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError());
   42.46          quit(4);
   42.47      }
   42.48  
   42.49      MooseTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H);
   42.50      if (!MooseTexture) {
   42.51 -        fprintf(stderr, "Couldn't set create texture: %s\n", SDL_GetError());
   42.52 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());
   42.53          quit(5);
   42.54      }
   42.55  
    43.1 --- a/test/testthread.c	Mon Aug 12 22:00:21 2013 -0700
    43.2 +++ b/test/testthread.c	Wed Aug 14 23:30:10 2013 -0700
    43.3 @@ -34,20 +34,20 @@
    43.4  ThreadFunc(void *data)
    43.5  {
    43.6      SDL_TLSSet(tls, "baby thread", NULL);
    43.7 -    printf("Started thread %s: My thread id is %lu, thread data = %s\n",
    43.8 +    SDL_Log("Started thread %s: My thread id is %lu, thread data = %s\n",
    43.9             (char *) data, SDL_ThreadID(), (const char *)SDL_TLSGet(tls));
   43.10      while (alive) {
   43.11 -        printf("Thread '%s' is alive!\n", (char *) data);
   43.12 +        SDL_Log("Thread '%s' is alive!\n", (char *) data);
   43.13          SDL_Delay(1 * 1000);
   43.14      }
   43.15 -    printf("Thread '%s' exiting!\n", (char *) data);
   43.16 +    SDL_Log("Thread '%s' exiting!\n", (char *) data);
   43.17      return (0);
   43.18  }
   43.19  
   43.20  static void
   43.21  killed(int sig)
   43.22  {
   43.23 -    printf("Killed with SIGTERM, waiting 5 seconds to exit\n");
   43.24 +    SDL_Log("Killed with SIGTERM, waiting 5 seconds to exit\n");
   43.25      SDL_Delay(5 * 1000);
   43.26      alive = 0;
   43.27      quit(0);
   43.28 @@ -58,35 +58,38 @@
   43.29  {
   43.30      SDL_Thread *thread;
   43.31  
   43.32 +	/* Enable standard application logging */
   43.33 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   43.34 +
   43.35      /* Load the SDL library */
   43.36      if (SDL_Init(0) < 0) {
   43.37 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   43.38 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
   43.39          return (1);
   43.40      }
   43.41  
   43.42      tls = SDL_TLSCreate();
   43.43      SDL_assert(tls);
   43.44      SDL_TLSSet(tls, "main thread", NULL);
   43.45 -    printf("Main thread data initially: %s\n", (const char *)SDL_TLSGet(tls));
   43.46 +    SDL_Log("Main thread data initially: %s\n", (const char *)SDL_TLSGet(tls));
   43.47  
   43.48      alive = 1;
   43.49      thread = SDL_CreateThread(ThreadFunc, "One", "#1");
   43.50      if (thread == NULL) {
   43.51 -        fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
   43.52 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
   43.53          quit(1);
   43.54      }
   43.55      SDL_Delay(5 * 1000);
   43.56 -    printf("Waiting for thread #1\n");
   43.57 +    SDL_Log("Waiting for thread #1\n");
   43.58      alive = 0;
   43.59      SDL_WaitThread(thread, NULL);
   43.60  
   43.61 -    printf("Main thread data finally: %s\n", (const char *)SDL_TLSGet(tls));
   43.62 +    SDL_Log("Main thread data finally: %s\n", (const char *)SDL_TLSGet(tls));
   43.63  
   43.64      alive = 1;
   43.65      signal(SIGTERM, killed);
   43.66      thread = SDL_CreateThread(ThreadFunc, "Two", "#2");
   43.67      if (thread == NULL) {
   43.68 -        fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
   43.69 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
   43.70          quit(1);
   43.71      }
   43.72      raise(SIGTERM);
    44.1 --- a/test/testtimer.c	Mon Aug 12 22:00:21 2013 -0700
    44.2 +++ b/test/testtimer.c	Wed Aug 14 23:30:10 2013 -0700
    44.3 @@ -33,7 +33,7 @@
    44.4  static Uint32 SDLCALL
    44.5  callback(Uint32 interval, void *param)
    44.6  {
    44.7 -    printf("Timer %d : param = %d\n", interval, (int) (uintptr_t) param);
    44.8 +    SDL_Log("Timer %d : param = %d\n", interval, (int) (uintptr_t) param);
    44.9      return interval;
   44.10  }
   44.11  
   44.12 @@ -45,8 +45,11 @@
   44.13      Uint32 start32, now32;
   44.14      Uint64 start, now;
   44.15  
   44.16 +	/* Enable standard application logging */
   44.17 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   44.18 +
   44.19      if (SDL_Init(SDL_INIT_TIMER) < 0) {
   44.20 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   44.21 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
   44.22          return (1);
   44.23      }
   44.24  
   44.25 @@ -61,7 +64,7 @@
   44.26      t1 = SDL_AddTimer(desired, ticktock, NULL);
   44.27  
   44.28      /* Wait 10 seconds */
   44.29 -    printf("Waiting 10 seconds\n");
   44.30 +    SDL_Log("Waiting 10 seconds\n");
   44.31      SDL_Delay(10 * 1000);
   44.32  
   44.33      /* Stop the timer */
   44.34 @@ -69,28 +72,27 @@
   44.35  
   44.36      /* Print the results */
   44.37      if (ticks) {
   44.38 -        fprintf(stderr,
   44.39 -                "Timer resolution: desired = %d ms, actual = %f ms\n",
   44.40 +        SDL_Log("Timer resolution: desired = %d ms, actual = %f ms\n",
   44.41                  desired, (double) (10 * 1000) / ticks);
   44.42      }
   44.43  
   44.44      /* Test multiple timers */
   44.45 -    printf("Testing multiple timers...\n");
   44.46 +    SDL_Log("Testing multiple timers...\n");
   44.47      t1 = SDL_AddTimer(100, callback, (void *) 1);
   44.48      if (!t1)
   44.49 -        fprintf(stderr, "Could not create timer 1: %s\n", SDL_GetError());
   44.50 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 1: %s\n", SDL_GetError());
   44.51      t2 = SDL_AddTimer(50, callback, (void *) 2);
   44.52      if (!t2)
   44.53 -        fprintf(stderr, "Could not create timer 2: %s\n", SDL_GetError());
   44.54 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 2: %s\n", SDL_GetError());
   44.55      t3 = SDL_AddTimer(233, callback, (void *) 3);
   44.56      if (!t3)
   44.57 -        fprintf(stderr, "Could not create timer 3: %s\n", SDL_GetError());
   44.58 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 3: %s\n", SDL_GetError());
   44.59  
   44.60      /* Wait 10 seconds */
   44.61 -    printf("Waiting 10 seconds\n");
   44.62 +    SDL_Log("Waiting 10 seconds\n");
   44.63      SDL_Delay(10 * 1000);
   44.64  
   44.65 -    printf("Removing timer 1 and waiting 5 more seconds\n");
   44.66 +    SDL_Log("Removing timer 1 and waiting 5 more seconds\n");
   44.67      SDL_RemoveTimer(t1);
   44.68  
   44.69      SDL_Delay(5 * 1000);
   44.70 @@ -103,15 +105,15 @@
   44.71          ticktock(0, NULL);
   44.72      }
   44.73      now = SDL_GetPerformanceCounter();
   44.74 -    printf("1 million iterations of ticktock took %f ms\n", (double)((now - start)*1000) / SDL_GetPerformanceFrequency());
   44.75 +    SDL_Log("1 million iterations of ticktock took %f ms\n", (double)((now - start)*1000) / SDL_GetPerformanceFrequency());
   44.76  
   44.77 -    printf("Performance counter frequency: %llu\n", (unsigned long long) SDL_GetPerformanceFrequency());
   44.78 +    SDL_Log("Performance counter frequency: %llu\n", (unsigned long long) SDL_GetPerformanceFrequency());
   44.79      start32 = SDL_GetTicks();
   44.80      start = SDL_GetPerformanceCounter();
   44.81      SDL_Delay(1000);
   44.82      now = SDL_GetPerformanceCounter();
   44.83      now32 = SDL_GetTicks();
   44.84 -    printf("Delay 1 second = %d ms in ticks, %f ms according to performance counter\n", (now32-start32), (double)((now - start)*1000) / SDL_GetPerformanceFrequency());
   44.85 +    SDL_Log("Delay 1 second = %d ms in ticks, %f ms according to performance counter\n", (now32-start32), (double)((now - start)*1000) / SDL_GetPerformanceFrequency());
   44.86  
   44.87      SDL_Quit();
   44.88      return (0);
    45.1 --- a/test/testver.c	Mon Aug 12 22:00:21 2013 -0700
    45.2 +++ b/test/testver.c	Wed Aug 14 23:30:10 2013 -0700
    45.3 @@ -26,17 +26,20 @@
    45.4      SDL_version compiled;
    45.5      SDL_version linked;
    45.6  
    45.7 +	/* Enable standard application logging */
    45.8 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
    45.9 +
   45.10  #if SDL_VERSION_ATLEAST(2, 0, 0)
   45.11 -    printf("Compiled with SDL 2.0 or newer\n");
   45.12 +    SDL_Log("Compiled with SDL 2.0 or newer\n");
   45.13  #else
   45.14 -    printf("Compiled with SDL older than 2.0\n");
   45.15 +    SDL_Log("Compiled with SDL older than 2.0\n");
   45.16  #endif
   45.17      SDL_VERSION(&compiled);
   45.18 -    printf("Compiled version: %d.%d.%d.%d (%s)\n",
   45.19 +    SDL_Log("Compiled version: %d.%d.%d.%d (%s)\n",
   45.20             compiled.major, compiled.minor, compiled.patch,
   45.21             SDL_REVISION_NUMBER, SDL_REVISION);
   45.22      SDL_GetVersion(&linked);
   45.23 -    printf("Linked version: %d.%d.%d.%d (%s)\n",
   45.24 +    SDL_Log("Linked version: %d.%d.%d.%d (%s)\n",
   45.25             linked.major, linked.minor, linked.patch,
   45.26             SDL_GetRevisionNumber(), SDL_GetRevision());
   45.27      SDL_Quit();
    46.1 --- a/test/testwm2.c	Mon Aug 12 22:00:21 2013 -0700
    46.2 +++ b/test/testwm2.c	Wed Aug 14 23:30:10 2013 -0700
    46.3 @@ -48,6 +48,9 @@
    46.4      int system_cursor = -1;
    46.5      SDL_Cursor *cursor = NULL;
    46.6  
    46.7 +	/* Enable standard application logging */
    46.8 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
    46.9 +
   46.10      SDL_assert(SDL_arraysize(cursorNames) == SDL_NUM_SYSTEM_CURSORS);
   46.11  
   46.12      /* Initialize test framework */
   46.13 @@ -64,7 +67,7 @@
   46.14              consumed = -1;
   46.15          }
   46.16          if (consumed < 0) {
   46.17 -            fprintf(stderr, "Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
   46.18 +            SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
   46.19              quit(1);
   46.20          }
   46.21          i += consumed;
   46.22 @@ -84,7 +87,7 @@
   46.23                  if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
   46.24                      SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
   46.25                      if (window) {
   46.26 -                        printf("Window %d resized to %dx%d\n",
   46.27 +                        SDL_Log("Window %d resized to %dx%d\n",
   46.28                              event.window.windowID,
   46.29                              event.window.data1,
   46.30                              event.window.data2);
   46.31 @@ -93,7 +96,7 @@
   46.32                  if (event.window.event == SDL_WINDOWEVENT_MOVED) {
   46.33                      SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
   46.34                      if (window) {
   46.35 -                        printf("Window %d moved to %d,%d (display %s)\n",
   46.36 +                        SDL_Log("Window %d moved to %d,%d (display %s)\n",
   46.37                              event.window.windowID,
   46.38                              event.window.data1,
   46.39                              event.window.data2,
    47.1 --- a/test/torturethread.c	Mon Aug 12 22:00:21 2013 -0700
    47.2 +++ b/test/torturethread.c	Wed Aug 14 23:30:10 2013 -0700
    47.3 @@ -49,7 +49,7 @@
    47.4      int i;
    47.5      int tid = (int) (uintptr_t) data;
    47.6  
    47.7 -    fprintf(stderr, "Creating Thread %d\n", tid);
    47.8 +    SDL_Log("Creating Thread %d\n", tid);
    47.9  
   47.10      for (i = 0; i < NUMTHREADS; i++) {
   47.11          char name[64];
   47.12 @@ -58,18 +58,18 @@
   47.13          sub_threads[i] = SDL_CreateThread(SubThreadFunc, name, &flags[i]);
   47.14      }
   47.15  
   47.16 -    printf("Thread '%d' waiting for signal\n", tid);
   47.17 +    SDL_Log("Thread '%d' waiting for signal\n", tid);
   47.18      while (time_for_threads_to_die[tid] != 1) {
   47.19          ;                       /* do nothing */
   47.20      }
   47.21  
   47.22 -    printf("Thread '%d' sending signals to subthreads\n", tid);
   47.23 +    SDL_Log("Thread '%d' sending signals to subthreads\n", tid);
   47.24      for (i = 0; i < NUMTHREADS; i++) {
   47.25          flags[i] = 1;
   47.26          SDL_WaitThread(sub_threads[i], NULL);
   47.27      }
   47.28  
   47.29 -    printf("Thread '%d' exiting!\n", tid);
   47.30 +    SDL_Log("Thread '%d' exiting!\n", tid);
   47.31  
   47.32      return 0;
   47.33  }
   47.34 @@ -80,9 +80,12 @@
   47.35      SDL_Thread *threads[NUMTHREADS];
   47.36      int i;
   47.37  
   47.38 +	/* Enable standard application logging */
   47.39 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
   47.40 +
   47.41      /* Load the SDL library */
   47.42      if (SDL_Init(0) < 0) {
   47.43 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   47.44 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
   47.45          return (1);
   47.46      }
   47.47  
   47.48 @@ -94,7 +97,7 @@
   47.49          threads[i] = SDL_CreateThread(ThreadFunc, name, (void*) (uintptr_t) i);
   47.50  
   47.51          if (threads[i] == NULL) {
   47.52 -            fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
   47.53 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
   47.54              quit(1);
   47.55          }
   47.56      }