From 6694d6aa23f527b51df255b23078954033583641 Mon Sep 17 00:00:00 2001 From: Siddharth Chandrasekaran Date: Sat, 28 Oct 2023 09:49:54 +0200 Subject: [PATCH] Revert "libosdp: Demote osdp_logger_init to a macro alias" This reverts commit c932fbebdc481ac7cb1a98f5c4410df83a75ec1a. In preparation for a minor release, let's revert this commit as it breaks the ABI. This will revert will be undone soon after the release. Signed-off-by: Siddharth Chandrasekaran --- include/osdp.h | 17 ++++++++++++----- src/osdp_common.c | 6 ++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/include/osdp.h b/include/osdp.h index 37b2158c..8040e003 100644 --- a/include/osdp.h +++ b/include/osdp.h @@ -994,12 +994,19 @@ void osdp_logger_init3(const char *name, int log_level, osdp_log_puts_fn_t puts_fn); /** - * @brief This macro alias Provided for API compatiblity for existing users who - * using the old osdp_logger_init() API. For description of parameters and use, - * see osdp_logger_init3 documentation. + * @brief Configure OSDP Logging (deprecated). Provided for backward + * compatiblity. Use osdp_logger_init3 instead. + * + * @param log_level OSDP log levels of type `enum osdp_log_level_e`. Default is + * LOG_INFO. + * @param puts_fn A puts() like function that will be invoked to write the log + * buffer. Can be handy if you want to log to file on a UART + * device without putchar redirection. See `osdp_log_puts_fn_t` + * definition to see the behavioral expectations. When this is + * set to NULL, LibOSDP will log to stderr. */ -#define osdp_logger_init(log_level, log_fn) \ - osdp_logger_init3("osdp", log_level, log_fn) +void osdp_logger_init(int log_level, osdp_log_puts_fn_t puts_fn) + __attribute__((deprecated("Use osdp_logger_init3 instead!"))); /** * @brief A callback function that gets called when LibOSDP wants to emit a log diff --git a/src/osdp_common.c b/src/osdp_common.c index 251bb56d..247d1a4b 100644 --- a/src/osdp_common.c +++ b/src/osdp_common.c @@ -209,6 +209,12 @@ void osdp_logger_init3(const char *name, int log_level, logger_set_default(&ctx); /* Mark this config as logging default */ } +OSDP_EXPORT +void osdp_logger_init(int log_level, osdp_log_puts_fn_t log_fn) +{ + osdp_logger_init3("osdp", log_level, log_fn); +} + OSDP_EXPORT void osdp_set_log_callback(osdp_log_callback_fn_t cb) {