log: Remove log_to_stdout option

Now that we've simplified how usage() works, nothing ever sets the
log_to_stdout flag. Eliminate it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
David Gibson 2024-06-05 10:42:42 +10:00 committed by Stefano Brivio
parent 7cb2088835
commit b3aeb004ea
2 changed files with 3 additions and 6 deletions

8
log.c
View file

@ -46,18 +46,16 @@ static char log_header[BUFSIZ]; /* File header, written back on cuts */
static time_t log_start; /* Start timestamp */ static time_t log_start; /* Start timestamp */
int log_trace; /* --trace mode enabled */ int log_trace; /* --trace mode enabled */
int log_to_stdout; /* Print to stdout instead of stderr */
void vlogmsg(int pri, const char *format, va_list ap) void vlogmsg(int pri, const char *format, va_list ap)
{ {
bool debug_print = (log_mask & LOG_MASK(LOG_DEBUG)) && log_file == -1; bool debug_print = (log_mask & LOG_MASK(LOG_DEBUG)) && log_file == -1;
bool early_print = LOG_PRI(log_mask) == LOG_EARLY; bool early_print = LOG_PRI(log_mask) == LOG_EARLY;
FILE *out = log_to_stdout ? stdout : stderr;
struct timespec tp; struct timespec tp;
if (debug_print) { if (debug_print) {
clock_gettime(CLOCK_REALTIME, &tp); clock_gettime(CLOCK_REALTIME, &tp);
fprintf(out, "%lli.%04lli: ", fprintf(stderr, "%lli.%04lli: ",
(long long int)tp.tv_sec - log_start, (long long int)tp.tv_sec - log_start,
(long long int)tp.tv_nsec / (100L * 1000)); (long long int)tp.tv_nsec / (100L * 1000));
} }
@ -75,9 +73,9 @@ void vlogmsg(int pri, const char *format, va_list ap)
} }
if (debug_print || (early_print && !(log_opt & LOG_PERROR))) { if (debug_print || (early_print && !(log_opt & LOG_PERROR))) {
(void)vfprintf(out, format, ap); (void)vfprintf(stderr, format, ap);
if (format[strlen(format)] != '\n') if (format[strlen(format)] != '\n')
fprintf(out, "\n"); fprintf(stderr, "\n");
} }
} }

1
log.h
View file

@ -28,7 +28,6 @@ void logmsg(int pri, const char *format, ...)
} while (0) } while (0)
extern int log_trace; extern int log_trace;
extern int log_to_stdout;
void trace_init(int enable); void trace_init(int enable);
#define trace(...) \ #define trace(...) \
do { \ do { \