Home GnuPG

core: Add logging API.

Description

core: Add logging API.

* src/visibility.c (gpgrt_get_errorcount): New API.
(gpgrt_inc_errorcount): New API.
(gpgrt_log_set_sink): New API.
(gpgrt_log_set_socket_dir_cb): New API.
(gpgrt_log_set_pid_suffix_cb): New API.
(gpgrt_log_set_prefix): New API.
(gpgrt_log_get_prefix): New API.
(gpgrt_log_test_fd): New API.
(gpgrt_log_get_fd): New API.
(gpgrt_log_get_stream): New API.
(gpgrt_log): New API.
(gpgrt_logv): New API.
(gpgrt_logv_prefix): New API.
(gpgrt_log_string): New API.
(gpgrt_log_info): New API.
(gpgrt_log_error): New API.
(gpgrt_log_fatal): New API.
(gpgrt_log_bug): New API.
(gpgrt_log_debug): New API.
(gpgrt_log_debug_string): New API.
(gpgrt_log_printf): New API.
(gpgrt_log_flush): New API.
(gpgrt_log_printhex): New API.
(gpgrt_log_clock): New API.
(_gpgrt_log_assert): New function for the ABI.
* src/visibility.h: Add corresponding macros.
* src/gpg-error.def.in: Add new functions.
* src/gpg-error.vers: Add new functions.
* src/gpg-error.h.in (GPGRT_LOG_WITH_PREFIX): New constant.
(GPGRT_LOG_WITH_TIME): New constant.
(GPGRT_LOG_WITH_PID): New constant.
(GPGRT_LOG_RUN_DETACHED): New constant.
(GPGRT_LOG_NO_REGISTRY): New constant.
(GPGRT_LOG_BEGIN): New enum value.
(GPGRT_LOG_CONT): New enum value.
(GPGRT_LOG_INFO): New enum value.
(GPGRT_LOG_WARN): New enum value.
(GPGRT_LOG_ERROR): New enum value.
(GPGRT_LOG_FATAL): New enum value.
(GPGRT_LOG_BUG): New enum value.
(GPGRT_LOG_DEBUG): New enum value.
(log_get_errorcount, log_inc_errorcount, log_set_file, log_set_fd)
(log_set_stream, log_set_socket_dir_cb, log_set_pid_suffix_cb)
(log_set_prefix, log_get_prefix, log_test_fd, log_get_fd)
(log_get_stream, log_log, log_logv, log_logv_prefix, log_string)
(log_bug, log_fatal, log_error, log_info, log_debug, log_debug_string)
(log_printf, log_printhex, log_clock)
(log_flush) [GPGRT_ENABLE_LOG_MACROS]: New wrapper macros.
(gpgrt_assert): New macro.
* src/gpgrt-int.h: Add prototypes for logging.c.
(gpgrt_assert): Redefine for internal use.
* src/logging.h: Remove.
* src/logging.c: Include gpgrt-int.h instead of the stuff from GnuPG.
Use _gpgrt malloc funcsions and the internal versions of the estream
functions.  Rename all public fucntions with a _gpgrt_ prefix.
(print_prefix): Return the printed length.
(_gpgrt_logv_internal): Ditto.
(_gpgrt_log_printhex): Change order of args and turn into a printf
like function.
(_gpgrt_logv_printhex): New. Take the core of the former
log_printhex.
(_gpgrt_log_clock): Turn into a printf like functions.
(_gpgrt_logv_clock): New.  Take the core of the former log_clock.

This logging API is a slightly modified version of what we are using
in GnuPG.

  • Signed-off-by: Werner Koch <wk@gnupg.org>

Details

Provenance
wernerAuthored on Nov 17 2017, 9:37 AM
Parents
rE9c904765c9b2: New configure options and macros for internal use.
Branches
Unknown
Tags
Unknown