X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fverbose.c;h=d725881cf40acea319dbebc0d1775b0ccb73f738;hb=7553044c59814c33763bb4b1c34664dceed68735;hp=a91aeb1f02d2f3ca62fd463d1b8b8a6b0a639124;hpb=f58eb17b6fd797e1c969f4fd902f450c237a3079;p=src%2Fapp-framework-main.git diff --git a/src/verbose.c b/src/verbose.c index a91aeb1..d725881 100644 --- a/src/verbose.c +++ b/src/verbose.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 "IoT.bzh" + Copyright (C) 2016-2019 "IoT.bzh" author: José Bollo @@ -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; }