Mercurial > sdl-ios-xcode
annotate src/SDL_log.c @ 5282:8e421890cdb8
Fixed bug #1117
There's a new event that's always sent when the window changes size, and that event is what the renderers listen for to determine if they need to rebind their context.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 12 Feb 2011 19:02:14 -0800 |
parents | b530ef003506 |
children |
rev | line source |
---|---|
5226
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
5267 | 3 Copyright (C) 1997-2011 Sam Lantinga |
5226
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 /* Simple log messages in SDL */ |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 #include "SDL_log.h" |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 #if HAVE_STDIO_H |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #include <stdio.h> |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 #endif |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 #if defined(__WIN32__) |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 #include "core/windows/SDL_windows.h" |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 #elif defined(__ANDROID__) |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 #include <android/log.h> |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 #endif |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 #define DEFAULT_PRIORITY SDL_LOG_PRIORITY_CRITICAL |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 #define DEFAULT_APPLICATION_PRIORITY SDL_LOG_PRIORITY_INFO |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 typedef struct SDL_LogLevel |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 int category; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 SDL_LogPriority priority; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 struct SDL_LogLevel *next; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 } SDL_LogLevel; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 |
5240
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
48 /* The default log output function */ |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
49 static void SDL_LogOutput(void *userdata, |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
50 int category, SDL_LogPriority priority, |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
51 const char *message); |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
52 |
5226
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 static SDL_LogLevel *SDL_loglevels; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 static SDL_LogPriority SDL_application_priority = DEFAULT_APPLICATION_PRIORITY; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 static SDL_LogPriority SDL_default_priority = DEFAULT_PRIORITY; |
5240
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
56 static SDL_LogOutputFunction SDL_log_function = SDL_LogOutput; |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
57 static void *SDL_log_userdata = NULL; |
5226
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 static const char *SDL_priority_prefixes[SDL_NUM_LOG_PRIORITIES] = { |
5240
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
60 NULL, |
5226
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 "VERBOSE", |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 "DEBUG", |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 "INFO", |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 "WARN", |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 "ERROR", |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 "CRITICAL" |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 }; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 #ifdef __ANDROID__ |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 static const char *SDL_category_prefixes[SDL_LOG_CATEGORY_RESERVED1] = { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 "APP", |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 "ERROR", |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 "SYSTEM", |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 "AUDIO", |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 "VIDEO", |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 "RENDER", |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 "INPUT" |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 }; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 ANDROID_LOG_VERBOSE, |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 ANDROID_LOG_DEBUG, |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 ANDROID_LOG_INFO, |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 ANDROID_LOG_WARN, |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 ANDROID_LOG_ERROR, |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 ANDROID_LOG_FATAL |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 }; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 #endif /* __ANDROID__ */ |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 void |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 SDL_LogSetAllPriority(SDL_LogPriority priority) |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 SDL_LogLevel *entry; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 for (entry = SDL_loglevels; entry; entry = entry->next) { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 entry->priority = priority; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 SDL_application_priority = SDL_default_priority = priority; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 void |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 SDL_LogSetPriority(int category, SDL_LogPriority priority) |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 SDL_LogLevel *entry; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 for (entry = SDL_loglevels; entry; entry = entry->next) { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 if (entry->category == category) { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 entry->priority = priority; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 return; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 /* Create a new entry */ |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 entry = (SDL_LogLevel *)SDL_malloc(sizeof(*entry)); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 if (entry) { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 entry->category = category; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 entry->priority = priority; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 entry->next = SDL_loglevels; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 SDL_loglevels = entry; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 SDL_LogPriority |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 SDL_LogGetPriority(int category) |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 SDL_LogLevel *entry; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 for (entry = SDL_loglevels; entry; entry = entry->next) { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 if (entry->category == category) { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 return entry->priority; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 if (category == SDL_LOG_CATEGORY_APPLICATION) { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 return SDL_application_priority; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 } else { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 return SDL_default_priority; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 void |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 SDL_LogResetPriorities(void) |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 SDL_LogLevel *entry; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 while (SDL_loglevels) { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 entry = SDL_loglevels; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 SDL_loglevels = entry->next; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 SDL_free(entry); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 SDL_application_priority = DEFAULT_APPLICATION_PRIORITY; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 SDL_default_priority = DEFAULT_PRIORITY; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 void |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 SDL_Log(const char *fmt, ...) |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 va_list ap; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 va_start(ap, fmt); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, fmt, ap); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 va_end(ap); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 void |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 SDL_LogVerbose(int category, const char *fmt, ...) |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 va_list ap; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 va_start(ap, fmt); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 SDL_LogMessageV(category, SDL_LOG_PRIORITY_VERBOSE, fmt, ap); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 va_end(ap); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 void |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 SDL_LogInfo(int category, const char *fmt, ...) |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 va_list ap; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 va_start(ap, fmt); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 SDL_LogMessageV(category, SDL_LOG_PRIORITY_INFO, fmt, ap); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 va_end(ap); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 void |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 SDL_LogWarn(int category, const char *fmt, ...) |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 va_list ap; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 va_start(ap, fmt); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 SDL_LogMessageV(category, SDL_LOG_PRIORITY_WARN, fmt, ap); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 va_end(ap); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 void |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 SDL_LogError(int category, const char *fmt, ...) |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 va_list ap; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 va_start(ap, fmt); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 SDL_LogMessageV(category, SDL_LOG_PRIORITY_ERROR, fmt, ap); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 va_end(ap); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 void |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 SDL_LogCritical(int category, const char *fmt, ...) |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 va_list ap; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 va_start(ap, fmt); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 SDL_LogMessageV(category, SDL_LOG_PRIORITY_CRITICAL, fmt, ap); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 va_end(ap); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 void |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 SDL_LogMessage(int category, SDL_LogPriority priority, const char *fmt, ...) |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 va_list ap; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 va_start(ap, fmt); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 SDL_LogMessageV(category, priority, fmt, ap); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 va_end(ap); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 #ifdef __ANDROID__ |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 static const char * |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 GetCategoryPrefix(int category) |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 if (category < SDL_LOG_CATEGORY_RESERVED1) { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 return SDL_category_prefixes[category]; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 if (category < SDL_LOG_CATEGORY_CUSTOM) { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 return "RESERVED"; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 return "CUSTOM"; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 #endif /* __ANDROID__ */ |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 void |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list ap) |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 { |
5228
ab0d7cecc0f6
Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
5226
diff
changeset
|
244 char *message; |
5226
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 |
5240
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
246 /* Nothing to do if we don't have an output function */ |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
247 if (!SDL_log_function) { |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
248 return; |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
249 } |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
250 |
5226
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 /* Make sure we don't exceed array bounds */ |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 if (priority < 0 || priority >= SDL_NUM_LOG_PRIORITIES) { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 return; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 /* See if we want to do anything with this message */ |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 if (priority < SDL_LogGetPriority(category)) { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 return; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 |
5228
ab0d7cecc0f6
Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
5226
diff
changeset
|
261 message = SDL_stack_alloc(char, SDL_MAX_LOG_MESSAGE); |
ab0d7cecc0f6
Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
5226
diff
changeset
|
262 if (!message) { |
ab0d7cecc0f6
Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
5226
diff
changeset
|
263 return; |
ab0d7cecc0f6
Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
5226
diff
changeset
|
264 } |
ab0d7cecc0f6
Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
5226
diff
changeset
|
265 SDL_vsnprintf(message, SDL_MAX_LOG_MESSAGE, fmt, ap); |
5240
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
266 SDL_log_function(SDL_log_userdata, category, priority, message); |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
267 SDL_stack_free(message); |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
268 } |
5226
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 |
5240
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
270 static void |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
271 SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
272 const char *message) |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
273 { |
5226
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 #if defined(__WIN32__) |
5228
ab0d7cecc0f6
Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
5226
diff
changeset
|
275 /* Way too many allocations here, urgh */ |
5226
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 { |
5228
ab0d7cecc0f6
Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
5226
diff
changeset
|
277 char *output; |
ab0d7cecc0f6
Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
5226
diff
changeset
|
278 size_t length; |
5226
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 LPTSTR tstr; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 |
5228
ab0d7cecc0f6
Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
5226
diff
changeset
|
281 length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1; |
ab0d7cecc0f6
Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
5226
diff
changeset
|
282 output = SDL_stack_alloc(char, length); |
ab0d7cecc0f6
Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
5226
diff
changeset
|
283 SDL_snprintf(output, length, "%s: %s", SDL_priority_prefixes[priority], message); |
5226
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 tstr = WIN_UTF8ToString(output); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 OutputDebugString(tstr); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 SDL_free(tstr); |
5228
ab0d7cecc0f6
Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
5226
diff
changeset
|
287 SDL_stack_free(output); |
5226
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 #elif defined(__ANDROID__) |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 { |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 char tag[32]; |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 SDL_snprintf(tag, SDL_arraysize(tag), "SDL/%s", GetCategoryPrefix(category)); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 __android_log_write(SDL_android_priority[priority], tag, message); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 #endif |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 #if HAVE_STDIO_H |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 fprintf(stderr, "%s: %s\n", SDL_priority_prefixes[priority], message); |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 #endif |
5240
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
300 } |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
301 |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
302 void |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
303 SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata) |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
304 { |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
305 if (callback) { |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
306 *callback = SDL_log_function; |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
307 } |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
308 if (userdata) { |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
309 *userdata = SDL_log_userdata; |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
310 } |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
311 } |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
312 |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
313 void |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
314 SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata) |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
315 { |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
316 SDL_log_function = callback; |
1e28342cb15d
Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents:
5228
diff
changeset
|
317 SDL_log_userdata = userdata; |
5226
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 } |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 |
2ee8112bfc6b
Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 /* vi: set ts=4 sw=4 expandtab: */ |