X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fverbose.c;h=3a0559e1a481f62a746185d42c285929e8f389b0;hb=c0b2c34c3a493ed4ed84586b9bb4a7842a9dc816;hp=2045bde172bb7cf928c138eb9e14819618e95f75;hpb=3a6e947bef1b2942e24d2fdee1a76dbf3305b508;p=src%2Fapp-framework-main.git diff --git a/src/verbose.c b/src/verbose.c index 2045bde..3a0559e 100644 --- a/src/verbose.c +++ b/src/verbose.c @@ -43,14 +43,18 @@ void vverbose(int level, const char *file, int line, const char *fmt, va_list ar void verbose_set_name(const char *name, int authority) { + closelog(); openlog(name, LOG_PERROR, authority ? LOG_AUTH : LOG_USER); } #else +#include +#include #include +#include -static const char *appname; +static char *appname; static int appauthority; @@ -67,7 +71,9 @@ static const char *prefixes[] = { void vverbose(int level, const char *file, int line, const char *fmt, va_list args) { + int saverr = errno; int tty = isatty(fileno(stderr)); + errno = saverr; fprintf(stderr, "%s: ", prefixes[LEVEL(level)] + (tty ? 4 : 0)); vfprintf(stderr, fmt, args); @@ -79,7 +85,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) { - appname = name; + free(appname); + appname = name ? strdup(name) : NULL; appauthority = authority; }