changeset 5226:2ee8112bfc6b

Added a simple log message API
author Sam Lantinga <slouken@libsdl.org>
date Mon, 07 Feb 2011 16:45:40 -0800
parents 1fbe1c202501
children c66b2a778b7e
files Makefile.in VisualC/SDL/SDL_VS2008.vcproj VisualC/SDL/SDL_VS2010.vcxproj VisualCE/SDL/SDL.vcproj Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj Xcode/SDL/SDL.xcodeproj/project.pbxproj include/SDL.h include/SDL_error.h include/SDL_log.h src/SDL.c src/SDL_error.c src/SDL_log.c src/render/SDL_render.c
diffstat 13 files changed, 549 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.in	Mon Feb 07 10:40:21 2011 -0800
+++ b/Makefile.in	Mon Feb 07 16:45:40 2011 -0800
@@ -59,6 +59,7 @@
 	SDL_keyboard.h \
 	SDL_keysym.h \
 	SDL_loadso.h \
+	SDL_log.h \
 	SDL_main.h \
 	SDL_mouse.h \
 	SDL_mutex.h \
--- a/VisualC/SDL/SDL_VS2008.vcproj	Mon Feb 07 10:40:21 2011 -0800
+++ b/VisualC/SDL/SDL_VS2008.vcproj	Mon Feb 07 16:45:40 2011 -0800
@@ -458,6 +458,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\include\SDL_log.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\include\SDL_main.h"
 				>
 			</File>
@@ -919,6 +923,10 @@
 			>
 		</File>
 		<File
+			RelativePath="..\..\src\SDL_log.c"
+			>
+		</File>
+		<File
 			RelativePath="..\..\src\stdlib\SDL_malloc.c"
 			>
 		</File>
--- a/VisualC/SDL/SDL_VS2010.vcxproj	Mon Feb 07 10:40:21 2011 -0800
+++ b/VisualC/SDL/SDL_VS2010.vcxproj	Mon Feb 07 16:45:40 2011 -0800
@@ -249,6 +249,7 @@
     <ClInclude Include="..\..\include\SDL_keyboard.h" />
     <ClInclude Include="..\..\include\SDL_keysym.h" />
     <ClInclude Include="..\..\include\SDL_loadso.h" />
+    <ClInclude Include="..\..\include\SDL_log.h" />
     <ClInclude Include="..\..\include\SDL_main.h" />
     <ClInclude Include="..\..\include\SDL_mouse.h" />
     <ClInclude Include="..\..\include\SDL_mutex.h" />
@@ -390,6 +391,7 @@
     <ClCompile Include="..\..\src\audio\SDL_audiodev.c" />
     <ClCompile Include="..\..\src\audio\SDL_audiotypecvt.c" />
     <ClCompile Include="..\..\src\SDL_hints.c" />
+    <ClCompile Include="..\..\src\SDL_log.c" />
     <ClCompile Include="..\..\src\video\dummy\SDL_nullframebuffer.c" />
     <ClCompile Include="..\..\src\video\SDL_blit.c" />
     <ClCompile Include="..\..\src\video\SDL_blit_0.c" />
--- a/VisualCE/SDL/SDL.vcproj	Mon Feb 07 10:40:21 2011 -0800
+++ b/VisualCE/SDL/SDL.vcproj	Mon Feb 07 16:45:40 2011 -0800
@@ -878,6 +878,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\src\SDL_hints.c"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\stdlib\SDL_iconv.c"
 				>
 			</File>
@@ -890,6 +894,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\src\SDL_log.c"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\stdlib\SDL_malloc.c"
 				>
 			</File>
@@ -938,7 +946,7 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\render\software\SDL_renderer_sw.c"
+				RelativePath="..\..\src\render\software\SDL_render_sw.c"
 				>
 			</File>
 			<File
@@ -1231,18 +1239,46 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\include\SDL_hints.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\include\SDL_input.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\include\SDL_joystick.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\joystick\SDL_joystick_c.h"
 				>
 			</File>
 			<File
+				RelativePath="..\..\include\SDL_keyboard.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\events\SDL_keyboard_c.h"
 				>
 			</File>
 			<File
+				RelativePath="..\..\include\SDL_keysym.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\video\SDL_leaks.h"
 				>
 			</File>
 			<File
+				RelativePath="..\..\include\SDL_loadso.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\include\SDL_log.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\events\SDL_mouse_c.h"
 				>
 			</File>
@@ -1271,6 +1307,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\src\render\software\SDL_render_sw_c.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\render\software\SDL_renderer_sw_c.h"
 				>
 			</File>
--- a/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj	Mon Feb 07 10:40:21 2011 -0800
+++ b/Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj	Mon Feb 07 16:45:40 2011 -0800
@@ -99,6 +99,9 @@
 		04BA9D6611EF474A00B60E01 /* SDL_touch.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BA9D6211EF474A00B60E01 /* SDL_touch.c */; };
 		04BA9D7D11EF497E00B60E01 /* SDL_gesture.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BA9D7B11EF497E00B60E01 /* SDL_gesture.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		04BA9D7E11EF497E00B60E01 /* SDL_touch.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BA9D7C11EF497E00B60E01 /* SDL_touch.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		04BAC0991300C0F70055DE28 /* SDL_log.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BAC0981300C0F70055DE28 /* SDL_log.h */; };
+		04BAC09C1300C1290055DE28 /* SDL_assert_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BAC09A1300C1290055DE28 /* SDL_assert_c.h */; };
+		04BAC09D1300C1290055DE28 /* SDL_log.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BAC09B1300C1290055DE28 /* SDL_log.c */; };
 		04EC8B521025D12900431D42 /* SDL_config_iphoneos.h in Headers */ = {isa = PBXBuildFile; fileRef = 04EC8B501025D12900431D42 /* SDL_config_iphoneos.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		04F2AF541104ABC300D6DDF7 /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F2AF531104ABC300D6DDF7 /* SDL_assert.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		04F2AF561104ABD200D6DDF7 /* SDL_assert.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F2AF551104ABD200D6DDF7 /* SDL_assert.c */; };
@@ -362,6 +365,9 @@
 		04BA9D6211EF474A00B60E01 /* SDL_touch.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_touch.c; sourceTree = "<group>"; };
 		04BA9D7B11EF497E00B60E01 /* SDL_gesture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_gesture.h; path = ../../include/SDL_gesture.h; sourceTree = SOURCE_ROOT; };
 		04BA9D7C11EF497E00B60E01 /* SDL_touch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_touch.h; path = ../../include/SDL_touch.h; sourceTree = SOURCE_ROOT; };
+		04BAC0981300C0F70055DE28 /* SDL_log.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_log.h; path = ../../include/SDL_log.h; sourceTree = SOURCE_ROOT; };
+		04BAC09A1300C1290055DE28 /* SDL_assert_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_assert_c.h; path = ../../src/SDL_assert_c.h; sourceTree = SOURCE_ROOT; };
+		04BAC09B1300C1290055DE28 /* SDL_log.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_log.c; path = ../../src/SDL_log.c; sourceTree = SOURCE_ROOT; };
 		04EC8B501025D12900431D42 /* SDL_config_iphoneos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_config_iphoneos.h; path = ../../include/SDL_config_iphoneos.h; sourceTree = SOURCE_ROOT; };
 		04F2AF531104ABC300D6DDF7 /* SDL_assert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_assert.h; path = ../../include/SDL_assert.h; sourceTree = SOURCE_ROOT; };
 		04F2AF551104ABD200D6DDF7 /* SDL_assert.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_assert.c; path = ../../src/SDL_assert.c; sourceTree = SOURCE_ROOT; };
@@ -930,6 +936,7 @@
 				FD99B8DF0DD52EB400FB1D6B /* SDL_keyboard.h */,
 				FD99B8E00DD52EB400FB1D6B /* SDL_keysym.h */,
 				FD99B8E10DD52EB400FB1D6B /* SDL_loadso.h */,
+				04BAC0981300C0F70055DE28 /* SDL_log.h */,
 				FD99B8E20DD52EB400FB1D6B /* SDL_main.h */,
 				FD99B8E30DD52EB400FB1D6B /* SDL_mouse.h */,
 				FD99B8E40DD52EB400FB1D6B /* SDL_mutex.h */,
@@ -978,12 +985,14 @@
 				FD99BA1E0DD52EDC00FB1D6B /* timer */,
 				FDA682420DF2374D00F98A1A /* video */,
 				04F2AF551104ABD200D6DDF7 /* SDL_assert.c */,
+				04BAC09A1300C1290055DE28 /* SDL_assert_c.h */,
 				FD99B9D30DD52EDC00FB1D6B /* SDL_compat.c */,
 				FD99B9D40DD52EDC00FB1D6B /* SDL_error_c.h */,
 				FD99B9D50DD52EDC00FB1D6B /* SDL_error.c */,
 				FD99B9D60DD52EDC00FB1D6B /* SDL_fatal.c */,
 				FD99B9D70DD52EDC00FB1D6B /* SDL_fatal.h */,
 				0442EC5412FE1C3F004C9285 /* SDL_hints.c */,
+				04BAC09B1300C1290055DE28 /* SDL_log.c */,
 				FD99B9D80DD52EDC00FB1D6B /* SDL.c */,
 			);
 			name = "Library Source";
@@ -1260,6 +1269,8 @@
 				0442EC5012FE1C1E004C9285 /* SDL_render_sw_c.h in Headers */,
 				0402A85A12FE70C600CECEE3 /* SDL_shaders_gles2.h in Headers */,
 				04043B8D12FEA9350076DB1F /* SDL_opengles2.h in Headers */,
+				04BAC0991300C0F70055DE28 /* SDL_log.h in Headers */,
+				04BAC09C1300C1290055DE28 /* SDL_assert_c.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -1509,6 +1520,7 @@
 				0442EC5512FE1C3F004C9285 /* SDL_hints.c in Sources */,
 				0402A85812FE70C600CECEE3 /* SDL_render_gles2.c in Sources */,
 				0402A85912FE70C600CECEE3 /* SDL_shaders_gles2.c in Sources */,
+				04BAC09D1300C1290055DE28 /* SDL_log.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
--- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj	Mon Feb 07 10:40:21 2011 -0800
+++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj	Mon Feb 07 16:45:40 2011 -0800
@@ -155,6 +155,10 @@
 		044E5F8611E6051C0076F181 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5F8411E6051C0076F181 /* SDL_clipboard.h */; };
 		0469A10B12EE4BF100B846D6 /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0469A10912EE4BF100B846D6 /* SDL_blendmode.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		0469A10D12EE4BF100B846D6 /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0469A10912EE4BF100B846D6 /* SDL_blendmode.h */; };
+		04BAC0B31300C1CB0055DE28 /* SDL_log.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BAC0B21300C1CB0055DE28 /* SDL_log.h */; };
+		04BAC0B41300C1CB0055DE28 /* SDL_log.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BAC0B21300C1CB0055DE28 /* SDL_log.h */; };
+		04BAC0C81300C2160055DE28 /* SDL_log.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BAC0C71300C2160055DE28 /* SDL_log.c */; };
+		04BAC0C91300C2160055DE28 /* SDL_log.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BAC0C71300C2160055DE28 /* SDL_log.c */; };
 		04BD000812E6671800899322 /* SDL_diskaudio.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFD8812E6671700899322 /* SDL_diskaudio.c */; };
 		04BD000912E6671800899322 /* SDL_diskaudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFD8912E6671700899322 /* SDL_diskaudio.h */; };
 		04BD001012E6671800899322 /* SDL_dummyaudio.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFD9412E6671700899322 /* SDL_dummyaudio.c */; };
@@ -709,6 +713,8 @@
 		0442EC5E12FE1C75004C9285 /* SDL_hints.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_hints.c; path = ../../src/SDL_hints.c; sourceTree = SOURCE_ROOT; };
 		044E5F8411E6051C0076F181 /* SDL_clipboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_clipboard.h; path = ../../include/SDL_clipboard.h; sourceTree = SOURCE_ROOT; };
 		0469A10912EE4BF100B846D6 /* SDL_blendmode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_blendmode.h; path = ../../include/SDL_blendmode.h; sourceTree = SOURCE_ROOT; };
+		04BAC0B21300C1CB0055DE28 /* SDL_log.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_log.h; path = ../../include/SDL_log.h; sourceTree = SOURCE_ROOT; };
+		04BAC0C71300C2160055DE28 /* SDL_log.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = SDL_log.c; path = ../../src/SDL_log.c; sourceTree = SOURCE_ROOT; };
 		04BDFD7412E6671700899322 /* SDL_atomic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_atomic.c; sourceTree = "<group>"; };
 		04BDFD7512E6671700899322 /* SDL_spinlock.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_spinlock.c; sourceTree = "<group>"; };
 		04BDFD8812E6671700899322 /* SDL_diskaudio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_diskaudio.c; sourceTree = "<group>"; };
@@ -1137,6 +1143,7 @@
 				0C5AF5F101191D2B7F000001 /* SDL_keyboard.h */,
 				0C5AF5F201191D2B7F000001 /* SDL_keysym.h */,
 				B29A290D04E5B28700A80002 /* SDL_loadso.h */,
+				04BAC0B21300C1CB0055DE28 /* SDL_log.h */,
 				0C5AF5F301191D2B7F000001 /* SDL_main.h */,
 				0C5AF5F401191D2B7F000001 /* SDL_mouse.h */,
 				0C5AF5F501191D2B7F000001 /* SDL_mutex.h */,
@@ -1722,6 +1729,7 @@
 				04BDFE5A12E6671700899322 /* SDL_fatal.c */,
 				04BDFE5B12E6671700899322 /* SDL_fatal.h */,
 				0442EC5E12FE1C75004C9285 /* SDL_hints.c */,
+				04BAC0C71300C2160055DE28 /* SDL_log.c */,
 				04BDFE5C12E6671700899322 /* SDL.c */,
 			);
 			name = "Library Source";
@@ -1932,6 +1940,7 @@
 				0442EC1C12FE1BCB004C9285 /* SDL_render_sw_c.h in Headers */,
 				0442EC5B12FE1C60004C9285 /* SDL_x11framebuffer.h in Headers */,
 				04043BBB12FEB1BE0076DB1F /* SDL_glfuncs.h in Headers */,
+				04BAC0B31300C1CB0055DE28 /* SDL_log.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2061,6 +2070,7 @@
 				0442EC1E12FE1BCB004C9285 /* SDL_render_sw_c.h in Headers */,
 				0442EC5D12FE1C60004C9285 /* SDL_x11framebuffer.h in Headers */,
 				04043BBC12FEB1BE0076DB1F /* SDL_glfuncs.h in Headers */,
+				04BAC0B41300C1CB0055DE28 /* SDL_log.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2431,6 +2441,7 @@
 				0442EC1D12FE1BCB004C9285 /* SDL_render_sw.c in Sources */,
 				0442EC5A12FE1C60004C9285 /* SDL_x11framebuffer.c in Sources */,
 				0442EC5F12FE1C75004C9285 /* SDL_hints.c in Sources */,
+				04BAC0C81300C2160055DE28 /* SDL_log.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2550,6 +2561,7 @@
 				0442EC1F12FE1BCB004C9285 /* SDL_render_sw.c in Sources */,
 				0442EC5C12FE1C60004C9285 /* SDL_x11framebuffer.c in Sources */,
 				0442EC6012FE1C75004C9285 /* SDL_hints.c in Sources */,
+				04BAC0C91300C2160055DE28 /* SDL_log.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
--- a/include/SDL.h	Mon Feb 07 10:40:21 2011 -0800
+++ b/include/SDL.h	Mon Feb 07 16:45:40 2011 -0800
@@ -81,6 +81,7 @@
 #include "SDL_events.h"
 #include "SDL_hints.h"
 #include "SDL_loadso.h"
+#include "SDL_log.h"
 #include "SDL_mutex.h"
 #include "SDL_power.h"
 #include "SDL_render.h"
--- a/include/SDL_error.h	Mon Feb 07 10:40:21 2011 -0800
+++ b/include/SDL_error.h	Mon Feb 07 16:45:40 2011 -0800
@@ -48,7 +48,7 @@
  *  \name Internal error functions
  *  
  *  \internal 
- *  Private error message function - used internally.
+ *  Private error reporting function - used internally.
  */
 /*@{*/
 #define SDL_OutOfMemory()	SDL_Error(SDL_ENOMEM)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_log.h	Mon Feb 07 16:45:40 2011 -0800
@@ -0,0 +1,191 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+
+/**
+ *  \file SDL_log.h
+ *  
+ *  Simple log messages with categories and priorities.
+ *
+ *  By default logs are quiet, but if you're debugging SDL you might want:
+ *
+ *      SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN);
+ *
+ *  Here's where the messages go on different platforms:
+ *      Windows: debug output stream
+ *      Android: log output
+ *      Others: standard error output (stderr)
+ */
+
+#ifndef _SDL_log_h
+#define _SDL_log_h
+
+#include "SDL_stdinc.h"
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+
+/**
+ *  \brief The maximum size of a log message
+ *
+ *  Messages longer than the maximum size will be truncated
+ */
+#define SDL_MAX_LOG_MESSAGE 4096
+
+/**
+ *  \brief The predefined log categories
+ *
+ *  By default the application category is enabled at the INFO level,
+ *  and all other categories are enabled at the CRITICAL level.
+ */
+enum
+{
+    SDL_LOG_CATEGORY_APPLICATION,
+    SDL_LOG_CATEGORY_ERROR,
+    SDL_LOG_CATEGORY_SYSTEM,
+    SDL_LOG_CATEGORY_AUDIO,
+    SDL_LOG_CATEGORY_VIDEO,
+    SDL_LOG_CATEGORY_RENDER,
+    SDL_LOG_CATEGORY_INPUT,
+
+    /* Reserved for future SDL library use */
+    SDL_LOG_CATEGORY_RESERVED1,
+    SDL_LOG_CATEGORY_RESERVED2,
+    SDL_LOG_CATEGORY_RESERVED3,
+    SDL_LOG_CATEGORY_RESERVED4,
+    SDL_LOG_CATEGORY_RESERVED5,
+    SDL_LOG_CATEGORY_RESERVED6,
+    SDL_LOG_CATEGORY_RESERVED7,
+    SDL_LOG_CATEGORY_RESERVED8,
+    SDL_LOG_CATEGORY_RESERVED9,
+    SDL_LOG_CATEGORY_RESERVED10,
+
+    /* Beyond this point is reserved for application use, e.g.
+       enum {
+           MYAPP_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM,
+           MYAPP_CATEGORY_AWESOME2,
+           MYAPP_CATEGORY_AWESOME3,
+           ...
+       };
+     */
+    SDL_LOG_CATEGORY_CUSTOM,
+};
+
+/**
+ *  \brief The predefined log priorities
+ */
+typedef enum
+{
+    SDL_LOG_PRIORITY_VERBOSE = 1,
+    SDL_LOG_PRIORITY_DEBUG,
+    SDL_LOG_PRIORITY_INFO,
+    SDL_LOG_PRIORITY_WARN,
+    SDL_LOG_PRIORITY_ERROR,
+    SDL_LOG_PRIORITY_CRITICAL,
+    SDL_NUM_LOG_PRIORITIES
+} SDL_LogPriority;
+
+
+/**
+ *  \brief Set the priority of all log categories
+ */
+extern DECLSPEC void SDLCALL SDL_LogSetAllPriority(SDL_LogPriority priority);
+
+/**
+ *  \brief Set the priority of a particular log category
+ */
+extern DECLSPEC void SDLCALL SDL_LogSetPriority(int category,
+                                                SDL_LogPriority priority);
+
+/**
+ *  \brief Set the priority of a particular log category
+ */
+extern DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(int category);
+
+/**
+ *  \brief Reset all priorities to default.
+ *
+ *  \note This is called in SDL_Quit().
+ */
+extern DECLSPEC void SDLCALL SDL_LogResetPriorities(void);
+
+/**
+ *  \brief Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO
+ */
+extern DECLSPEC void SDLCALL SDL_Log(const char *fmt, ...);
+
+/**
+ *  \brief Log a message with SDL_LOG_PRIORITY_VERBOSE
+ */
+extern DECLSPEC void SDLCALL SDL_LogVerbose(int category, const char *fmt, ...);
+
+/**
+ *  \brief Log a message with SDL_LOG_PRIORITY_INFO
+ */
+extern DECLSPEC void SDLCALL SDL_LogInfo(int category, const char *fmt, ...);
+
+/**
+ *  \brief Log a message with SDL_LOG_PRIORITY_WARN
+ */
+extern DECLSPEC void SDLCALL SDL_LogWarn(int category, const char *fmt, ...);
+
+/**
+ *  \brief Log a message with SDL_LOG_PRIORITY_ERROR
+ */
+extern DECLSPEC void SDLCALL SDL_LogError(int category, const char *fmt, ...);
+
+/**
+ *  \brief Log a message with SDL_LOG_PRIORITY_CRITICAL
+ */
+extern DECLSPEC void SDLCALL SDL_LogCritical(int category, const char *fmt, ...);
+
+/**
+ *  \brief Log a message with the specified category and priority.
+ */
+extern DECLSPEC void SDLCALL SDL_LogMessage(int category,
+                                            SDL_LogPriority priority,
+                                            const char *fmt, ...);
+
+/**
+ *  \brief Log a message with the specified category and priority.
+ */
+extern DECLSPEC void SDLCALL SDL_LogMessageV(int category,
+                                             SDL_LogPriority priority,
+                                             const char *fmt, va_list ap);
+
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_log_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/SDL.c	Mon Feb 07 10:40:21 2011 -0800
+++ b/src/SDL.c	Mon Feb 07 16:45:40 2011 -0800
@@ -215,22 +215,12 @@
 SDL_Quit(void)
 {
     /* Quit all subsystems */
-#ifdef DEBUG_BUILD
-    printf("[SDL_Quit] : Enter! Calling QuitSubSystem()\n");
-    fflush(stdout);
-#endif
-
 #if defined(__WIN32__)
     SDL_HelperWindowDestroy();
 #endif
     SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
 
 #ifdef CHECK_LEAKS
-#ifdef DEBUG_BUILD
-    printf("[SDL_Quit] : CHECK_LEAKS\n");
-    fflush(stdout);
-#endif
-
     /* !!! FIXME: make this an assertion. */
     /* Print the number of surfaces not freed */
     if (surfaces_allocated != 0) {
@@ -238,22 +228,13 @@
                 surfaces_allocated);
     }
 #endif
-#ifdef DEBUG_BUILD
-    printf("[SDL_Quit] : SDL_UninstallParachute()\n");
-    fflush(stdout);
-#endif
 
     /* Uninstall any parachute signal handlers */
     SDL_UninstallParachute();
 
     SDL_ClearHints();
     SDL_AssertionsQuit();
-
-#ifdef DEBUG_BUILD
-    printf("[SDL_Quit] : Returning!\n");
-    fflush(stdout);
-#endif
-
+    SDL_LogResetPriorities();
 }
 
 /* Get the library version number */
--- a/src/SDL_error.c	Mon Feb 07 10:40:21 2011 -0800
+++ b/src/SDL_error.c	Mon Feb 07 16:45:40 2011 -0800
@@ -23,14 +23,10 @@
 
 /* Simple error handling in SDL */
 
-#ifdef __ANDROID__
-#include <android/log.h>
-#endif
-
+#include "SDL_log.h"
 #include "SDL_error.h"
 #include "SDL_error_c.h"
 
-/*#define DEBUG_ERROR*/
 
 /* Routine to get the thread-specific error variable */
 #if SDL_THREADS_DISABLED
@@ -113,12 +109,7 @@
     va_end(ap);
 
     /* If we are in debug mode, print out an error message */
-#ifdef DEBUG_ERROR
-    fprintf(stderr, "SDL_SetError: %s\n", SDL_GetError());
-#ifdef __ANDROID__
-    __android_log_print(ANDROID_LOG_INFO, "SDL", "ERROR: %s", SDL_GetError());
-#endif
-#endif /* DEBUG_ERROR */
+    SDL_LogError(SDL_LOG_CATEGORY_ERROR, "%s", SDL_GetError());
 }
 
 /* This function has a bit more overhead than most error functions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/SDL_log.c	Mon Feb 07 16:45:40 2011 -0800
@@ -0,0 +1,273 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/* Simple log messages in SDL */
+
+#include "SDL_log.h"
+
+#if HAVE_STDIO_H
+#include <stdio.h>
+#endif
+
+#if defined(__WIN32__)
+#include "core/windows/SDL_windows.h"
+#elif defined(__ANDROID__)
+#include <android/log.h>
+#endif
+
+#define DEFAULT_PRIORITY                SDL_LOG_PRIORITY_CRITICAL
+#define DEFAULT_APPLICATION_PRIORITY    SDL_LOG_PRIORITY_INFO
+
+typedef struct SDL_LogLevel
+{
+    int category;
+    SDL_LogPriority priority;
+    struct SDL_LogLevel *next;
+} SDL_LogLevel;
+
+static SDL_LogLevel *SDL_loglevels;
+static SDL_LogPriority SDL_application_priority = DEFAULT_APPLICATION_PRIORITY;
+static SDL_LogPriority SDL_default_priority = DEFAULT_PRIORITY;
+
+static const char *SDL_priority_prefixes[SDL_NUM_LOG_PRIORITIES] = {
+    "VERBOSE",
+    "DEBUG",
+    "INFO",
+    "WARN",
+    "ERROR",
+    "CRITICAL"
+};
+
+#ifdef __ANDROID__
+static const char *SDL_category_prefixes[SDL_LOG_CATEGORY_RESERVED1] = {
+    "APP",
+    "ERROR",
+    "SYSTEM",
+    "AUDIO",
+    "VIDEO",
+    "RENDER",
+    "INPUT"
+};
+
+static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = {
+    ANDROID_LOG_VERBOSE,
+    ANDROID_LOG_DEBUG,
+    ANDROID_LOG_INFO,
+    ANDROID_LOG_WARN,
+    ANDROID_LOG_ERROR,
+    ANDROID_LOG_FATAL
+};
+#endif /* __ANDROID__ */
+
+
+void
+SDL_LogSetAllPriority(SDL_LogPriority priority)
+{
+    SDL_LogLevel *entry;
+
+    for (entry = SDL_loglevels; entry; entry = entry->next) {
+        entry->priority = priority;
+    }
+    SDL_application_priority = SDL_default_priority = priority;
+}
+
+void
+SDL_LogSetPriority(int category, SDL_LogPriority priority)
+{
+    SDL_LogLevel *entry;
+
+    for (entry = SDL_loglevels; entry; entry = entry->next) {
+        if (entry->category == category) {
+            entry->priority = priority;
+            return;
+        }
+    }
+
+    /* Create a new entry */
+    entry = (SDL_LogLevel *)SDL_malloc(sizeof(*entry));
+    if (entry) {
+        entry->category = category;
+        entry->priority = priority;
+        entry->next = SDL_loglevels;
+        SDL_loglevels = entry;
+    }
+}
+
+SDL_LogPriority
+SDL_LogGetPriority(int category)
+{
+    SDL_LogLevel *entry;
+
+    for (entry = SDL_loglevels; entry; entry = entry->next) {
+        if (entry->category == category) {
+            return entry->priority;
+        }
+    }
+
+    if (category == SDL_LOG_CATEGORY_APPLICATION) {
+        return SDL_application_priority;
+    } else {
+        return SDL_default_priority;
+    }
+}
+
+void
+SDL_LogResetPriorities(void)
+{
+    SDL_LogLevel *entry;
+
+    while (SDL_loglevels) {
+        entry = SDL_loglevels;
+        SDL_loglevels = entry->next;
+        SDL_free(entry);
+    }
+
+    SDL_application_priority = DEFAULT_APPLICATION_PRIORITY;
+    SDL_default_priority = DEFAULT_PRIORITY;
+}
+
+void
+SDL_Log(const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, fmt, ap);
+    va_end(ap);
+}
+
+void
+SDL_LogVerbose(int category, const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    SDL_LogMessageV(category, SDL_LOG_PRIORITY_VERBOSE, fmt, ap);
+    va_end(ap);
+}
+
+void
+SDL_LogInfo(int category, const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    SDL_LogMessageV(category, SDL_LOG_PRIORITY_INFO, fmt, ap);
+    va_end(ap);
+}
+
+void
+SDL_LogWarn(int category, const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    SDL_LogMessageV(category, SDL_LOG_PRIORITY_WARN, fmt, ap);
+    va_end(ap);
+}
+
+void
+SDL_LogError(int category, const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    SDL_LogMessageV(category, SDL_LOG_PRIORITY_ERROR, fmt, ap);
+    va_end(ap);
+}
+
+void
+SDL_LogCritical(int category, const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    SDL_LogMessageV(category, SDL_LOG_PRIORITY_CRITICAL, fmt, ap);
+    va_end(ap);
+}
+
+void
+SDL_LogMessage(int category, SDL_LogPriority priority, const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    SDL_LogMessageV(category, priority, fmt, ap);
+    va_end(ap);
+}
+
+#ifdef __ANDROID__
+static const char *
+GetCategoryPrefix(int category)
+{
+    if (category < SDL_LOG_CATEGORY_RESERVED1) {
+        return SDL_category_prefixes[category];
+    }
+    if (category < SDL_LOG_CATEGORY_CUSTOM) {
+        return "RESERVED";
+    }
+    return "CUSTOM";
+}
+#endif /* __ANDROID__ */
+
+void
+SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list ap)
+{
+    char message[SDL_MAX_LOG_MESSAGE];
+
+    /* Make sure we don't exceed array bounds */
+    if (priority < 0 || priority >= SDL_NUM_LOG_PRIORITIES) {
+        return;
+    }
+
+    /* See if we want to do anything with this message */
+    if (priority < SDL_LogGetPriority(category)) {
+        return;
+    }
+
+    SDL_vsnprintf(message, SDL_arraysize(message), fmt, ap);
+
+#if defined(__WIN32__)
+    {
+        char output[32+SDL_MAX_LOG_MESSAGE];
+        LPTSTR tstr;
+
+        SDL_snprintf(output, SDL_arraysize(output), "%s: %s", SDL_priority_prefixes[priority], message);
+        tstr = WIN_UTF8ToString(output);
+        OutputDebugString(tstr);
+        SDL_free(tstr);
+    }
+#elif defined(__ANDROID__)
+    {
+        char tag[32];
+
+        SDL_snprintf(tag, SDL_arraysize(tag), "SDL/%s", GetCategoryPrefix(category));
+        __android_log_write(SDL_android_priority[priority], tag, message);
+    }
+#endif
+#if HAVE_STDIO_H
+    fprintf(stderr, "%s: %s\n", SDL_priority_prefixes[priority], message);
+#endif
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/render/SDL_render.c	Mon Feb 07 10:40:21 2011 -0800
+++ b/src/render/SDL_render.c	Mon Feb 07 16:45:40 2011 -0800
@@ -24,6 +24,7 @@
 /* The SDL 2D rendering system */
 
 #include "SDL_hints.h"
+#include "SDL_log.h"
 #include "SDL_render.h"
 #include "SDL_sysrender.h"
 #include "../video/SDL_pixels_c.h"
@@ -159,6 +160,9 @@
         renderer->window = window;
 
         SDL_AddEventWatch(SDL_RendererEventWatch, renderer);
+
+        SDL_LogInfo(SDL_LOG_CATEGORY_RENDER,
+                    "Created renderer: %s", renderer->info.name);
     }
     return renderer;
 }