summaryrefslogtreecommitdiffstats
path: root/common/logging.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2010-03-15 12:15:45 +0100
committerWerner Koch <wk@gnupg.org>2010-03-15 12:15:45 +0100
commitfb2ba98963beea249474f5d6d7345cf9b4b7f570 (patch)
tree3c9b25d63f90a71caec5685fca945341d54bef9d /common/logging.c
parentUse a custom log handler for libassuan. (diff)
downloadgnupg2-fb2ba98963beea249474f5d6d7345cf9b4b7f570.tar.xz
gnupg2-fb2ba98963beea249474f5d6d7345cf9b4b7f570.zip
Finished the bulk of changes to use estream in most places instead of
stdio.
Diffstat (limited to 'common/logging.c')
-rw-r--r--common/logging.c37
1 files changed, 11 insertions, 26 deletions
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. */