From fb2ba98963beea249474f5d6d7345cf9b4b7f570 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 15 Mar 2010 11:15:45 +0000 Subject: Finished the bulk of changes to use estream in most places instead of stdio. --- common/logging.c | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) (limited to 'common/logging.c') diff --git a/common/logging.c b/common/logging.c index 3b767cb97..6bc35eee5 100644 --- a/common/logging.c +++ b/common/logging.c @@ -283,32 +283,7 @@ set_file_fd (const char *name, int fd) /* On error default to a stderr based estream. */ if (!fp) - { - fp = es_fpopen (stderr, "a"); - if (fp) - { - if (name) - es_fprintf (fp, "failed to open log file `%s': %s\n", - name, strerror (errno)); - else - es_fprintf (fp, "failed to fdopen file descriptor %d: %s\n", - fd, strerror (errno)); - } - else - { - fprintf (stderr, "failed to use stderr as log stream: %s\n", - strerror (errno)); - /* No way to log something. Create a dummy estream so that - there is something we can use. */ - fp = es_fpopen (NULL, "a"); - if (!fp) - { - fprintf (stderr, "fatal: failed to open dummy stream: %s\n", - strerror (errno)); - abort(); - } - } - } + fp = es_stderr; es_setvbuf (fp, NULL, _IOLBF, 0); @@ -605,6 +580,16 @@ log_printf (const char *fmt, ...) } +/* Flush the log - this is useful to make sure that the trailing + linefeed has been printed. */ +void +log_flush (void) +{ + volatile va_list dummy_arg_ptr; + do_logv (JNLIB_LOG_CONT, 1, NULL, dummy_arg_ptr); +} + + /* Print a hexdump of BUFFER. With TEXT of NULL print just the raw dump, with TEXT just an empty string, print a trailing linefeed, otherwise print an entire debug line. */ -- cgit v1.2.3