231 #endif /* __ANDROID__ */ |
231 #endif /* __ANDROID__ */ |
232 |
232 |
233 void |
233 void |
234 SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list ap) |
234 SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list ap) |
235 { |
235 { |
236 char message[SDL_MAX_LOG_MESSAGE]; |
236 char *message; |
237 |
237 |
238 /* Make sure we don't exceed array bounds */ |
238 /* Make sure we don't exceed array bounds */ |
239 if (priority < 0 || priority >= SDL_NUM_LOG_PRIORITIES) { |
239 if (priority < 0 || priority >= SDL_NUM_LOG_PRIORITIES) { |
240 return; |
240 return; |
241 } |
241 } |
243 /* See if we want to do anything with this message */ |
243 /* See if we want to do anything with this message */ |
244 if (priority < SDL_LogGetPriority(category)) { |
244 if (priority < SDL_LogGetPriority(category)) { |
245 return; |
245 return; |
246 } |
246 } |
247 |
247 |
248 SDL_vsnprintf(message, SDL_arraysize(message), fmt, ap); |
248 message = SDL_stack_alloc(char, SDL_MAX_LOG_MESSAGE); |
|
249 if (!message) { |
|
250 return; |
|
251 } |
|
252 SDL_vsnprintf(message, SDL_MAX_LOG_MESSAGE, fmt, ap); |
249 |
253 |
250 #if defined(__WIN32__) |
254 #if defined(__WIN32__) |
|
255 /* Way too many allocations here, urgh */ |
251 { |
256 { |
252 char output[32+SDL_MAX_LOG_MESSAGE]; |
257 char *output; |
|
258 size_t length; |
253 LPTSTR tstr; |
259 LPTSTR tstr; |
254 |
260 |
255 SDL_snprintf(output, SDL_arraysize(output), "%s: %s", SDL_priority_prefixes[priority], message); |
261 length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1; |
|
262 output = SDL_stack_alloc(char, length); |
|
263 SDL_snprintf(output, length, "%s: %s", SDL_priority_prefixes[priority], message); |
256 tstr = WIN_UTF8ToString(output); |
264 tstr = WIN_UTF8ToString(output); |
257 OutputDebugString(tstr); |
265 OutputDebugString(tstr); |
258 SDL_free(tstr); |
266 SDL_free(tstr); |
|
267 SDL_stack_free(output); |
259 } |
268 } |
260 #elif defined(__ANDROID__) |
269 #elif defined(__ANDROID__) |
261 { |
270 { |
262 char tag[32]; |
271 char tag[32]; |
263 |
272 |