Removed log message length limitation for Apple platforms This works in conjunction with https://github.com/libsdl-org/SDL/pull/5584
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
diff --git a/src/SDL_log.c b/src/SDL_log.c
index 02ac4e4..d3896e2 100644
--- a/src/SDL_log.c
+++ b/src/SDL_log.c
@@ -430,17 +430,10 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
#elif defined(__APPLE__) && (defined(SDL_VIDEO_DRIVER_COCOA) || defined(SDL_VIDEO_DRIVER_UIKIT))
/* Technically we don't need Cocoa/UIKit, but that's where this function is defined for now.
*/
- extern void SDL_NSLog(const char *text);
+ extern void SDL_NSLog(const char *prefix, const char *text);
{
- char *text;
- /* !!! FIXME: why not just "char text[SDL_MAX_LOG_MESSAGE];" ? */
- text = SDL_stack_alloc(char, SDL_MAX_LOG_MESSAGE);
- if (text) {
- SDL_snprintf(text, SDL_MAX_LOG_MESSAGE, "%s: %s", SDL_priority_prefixes[priority], message);
- SDL_NSLog(text);
- SDL_stack_free(text);
- return;
- }
+ SDL_NSLog(SDL_priority_prefixes[priority], message);
+ return;
}
#elif defined(__PSP__)
{
diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m
index 74d8538..c5e5d64 100644
--- a/src/video/cocoa/SDL_cocoavideo.m
+++ b/src/video/cocoa/SDL_cocoavideo.m
@@ -270,11 +270,16 @@ Cocoa_CreateImage(SDL_Surface * surface)
* versions remain identical!
*/
-void SDL_NSLog(const char *text)
+void SDL_NSLog(const char *prefix, const char *text)
{
@autoreleasepool {
- NSString *str = [NSString stringWithUTF8String:text];
- NSLog(@"%@", str);
+ NSString *nsText = [NSString stringWithUTF8String:text];
+ if (prefix) {
+ NSString *nsPrefix = [NSString stringWithUTF8String:prefix];
+ NSLog(@"%@: %@", nsPrefix, nsText);
+ } else {
+ NSLog(@"%@", nsText);
+ }
}
}
diff --git a/src/video/uikit/SDL_uikitvideo.m b/src/video/uikit/SDL_uikitvideo.m
index 5d2b96e..81d7bf6 100644
--- a/src/video/uikit/SDL_uikitvideo.m
+++ b/src/video/uikit/SDL_uikitvideo.m
@@ -278,11 +278,16 @@ UIKit_ForceUpdateHomeIndicator()
*/
#if !defined(SDL_VIDEO_DRIVER_COCOA)
-void SDL_NSLog(const char *text)
+void SDL_NSLog(const char *prefix, const char *text)
{
@autoreleasepool {
- NSString *str = [NSString stringWithUTF8String:text];
- NSLog(@"%@", str);
+ NSString *nsText = [NSString stringWithUTF8String:text];
+ if (prefix) {
+ NSString *nsPrefix = [NSString stringWithUTF8String:prefix];
+ NSLog(@"%@: %@", nsPrefix, nsText);
+ } else {
+ NSLog(@"%@", nsText);
+ }
}
}
#endif /* SDL_VIDEO_DRIVER_COCOA */