mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-04 10:30:28 +01:00
test: detect linebreaks in log messages
If a single log message is composed of multiple calls (as are all from evdev_log_*), don't prefix multiple times. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
0bd36f2542
commit
6ab2999be9
1 changed files with 6 additions and 4 deletions
|
|
@ -786,6 +786,7 @@ litest_log_handler(struct libinput *libinput,
|
||||||
va_list args)
|
va_list args)
|
||||||
{
|
{
|
||||||
static int is_tty = -1;
|
static int is_tty = -1;
|
||||||
|
static bool had_newline = true;
|
||||||
const char *priority = NULL;
|
const char *priority = NULL;
|
||||||
const char *color;
|
const char *color;
|
||||||
|
|
||||||
|
|
@ -812,11 +813,12 @@ litest_log_handler(struct libinput *libinput,
|
||||||
if (!is_tty)
|
if (!is_tty)
|
||||||
color = "";
|
color = "";
|
||||||
|
|
||||||
|
if (had_newline)
|
||||||
fprintf(stderr, "%slitest %s ", color, priority);
|
fprintf(stderr, "%slitest %s ", color, priority);
|
||||||
|
|
||||||
vfprintf(stderr, format, args);
|
vfprintf(stderr, format, args);
|
||||||
|
had_newline = strlen(format) >= 1 &&
|
||||||
if (is_tty)
|
format[strlen(format) - 1] == '\n';
|
||||||
|
if (is_tty && had_newline)
|
||||||
fprintf(stderr, ANSI_NORMAL);
|
fprintf(stderr, ANSI_NORMAL);
|
||||||
|
|
||||||
if (strstr(format, "client bug: ") ||
|
if (strstr(format, "client bug: ") ||
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue