util/log: Don't print an extra \n if the format string had one.

You're not supposed to include a '\n' in mesa_log*() messages because
android logging will log what you provide on its own line anyway, so each
mesa_log() should be the body of a log line.  But also, getting everyone
to consistently not do that is hopeless because we're all so trained by
printf().  So, just detect an existing \n and don't add a new one.

Cleans up deqp-vk debug output a bunch from turnip.

Acked-by: Daniel Stone <daniels@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15332>
This commit is contained in:
Emma Anholt 2022-03-10 12:30:16 -08:00 committed by Marge Bot
parent e0b431da33
commit 0ee0d54985
1 changed files with 2 additions and 1 deletions

View File

@ -87,7 +87,8 @@ mesa_log_v(enum mesa_log_level level, const char *tag, const char *format,
#endif
fprintf(stderr, "%s: %s: ", tag, level_to_str(level));
vfprintf(stderr, format, va);
fprintf(stderr, "\n");
if (format[strlen(format) - 1] != '\n')
fprintf(stderr, "\n");
#if !DETECT_OS_WINDOWS
funlockfile(stderr);
#endif