X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fverbose.c;h=2045bde172bb7cf928c138eb9e14819618e95f75;hb=8d322ebdd04d6de2d5649626bbc23aae0d0ed556;hp=53811c0017fb2d10ba353239b6fa95716237f796;hpb=be4e0e2d3855ccbd3b683bfe6cc4c7f9d3254314;p=src%2Fapp-framework-binder.git diff --git a/src/verbose.c b/src/verbose.c index 53811c00..2045bde1 100644 --- a/src/verbose.c +++ b/src/verbose.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 "IoT.bzh" + Copyright (C) 2016, 2017 "IoT.bzh" author: José Bollo @@ -48,6 +48,12 @@ void verbose_set_name(const char *name, int authority) #else +#include + +static const char *appname; + +static int appauthority; + static const char *prefixes[] = { "<0> EMERGENCY", "<1> ALERT", @@ -61,9 +67,11 @@ static const char *prefixes[] = { void vverbose(int level, const char *file, int line, const char *fmt, va_list args) { - fprintf(stderr, "%s: ", prefixes[LEVEL(level)]); + int tty = isatty(fileno(stderr)); + + fprintf(stderr, "%s: ", prefixes[LEVEL(level)] + (tty ? 4 : 0)); vfprintf(stderr, fmt, args); - if (file != NULL) + if (file != NULL && (!tty || verbosity >5)) fprintf(stderr, " [%s:%d]\n", file, line); else fprintf(stderr, "\n"); @@ -71,7 +79,8 @@ void vverbose(int level, const char *file, int line, const char *fmt, va_list ar void verbose_set_name(const char *name, int authority) { - fprintf(stderr, "%s: application name is '%s' for '%s'\n", prefixes[5], name, authority ? "AUTHORITY" : "USER"); + appname = name; + appauthority = authority; } #endif