From e88d2014ba4507604c0f3f690788f82c35a61e83 Mon Sep 17 00:00:00 2001 From: Nedko Arnaudov Date: Mon, 1 May 2023 13:04:54 +0300 Subject: [PATCH] Adjust for the updated log cdbus interface --- alsapid/alsapid.h | 7 ++++++- common/log.c | 33 +++++++++++++++++---------------- log.h | 19 ++++++------------- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/alsapid/alsapid.h b/alsapid/alsapid.h index c0acbc72..9920c038 100644 --- a/alsapid/alsapid.h +++ b/alsapid/alsapid.h @@ -27,7 +27,10 @@ #ifndef ALSAPID_H__0A27F284_7538_4791_8023_0FBED929EAF3__INCLUDED #define ALSAPID_H__0A27F284_7538_4791_8023_0FBED929EAF3__INCLUDED -#include "../common.h" +#include "config.h" /* configure stage result */ + +#include /* C99 bool */ +#include /* pid_t */ void alsapid_compose_src_link(int alsa_client_id, char * buffer); void alsapid_compose_dst_link(char * buffer); @@ -35,4 +38,6 @@ bool alsapid_get_pid(int alsa_client_id, pid_t * pid_ptr); #define MAX_ALSAPID_PATH 255 +#define LADISH_PUBLIC __attribute__ ((visibility ("default"))) + #endif /* #ifndef ALSAPID_H__0A27F284_7538_4791_8023_0FBED929EAF3__INCLUDED */ diff --git a/common/log.c b/common/log.c index acd50a90..6417d88d 100644 --- a/common/log.c +++ b/common/log.c @@ -25,6 +25,7 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "config.h" #include "../common.h" #include @@ -133,6 +134,7 @@ void ladish_log_init() } ladish_log_open(); + cdbus_log_setup(ladish_log); free_log_dir: free(ladish_log_dir); @@ -157,11 +159,11 @@ void ladish_log_uninit() #endif /* #if !defined(LOG_OUTPUT_STDOUT) */ #if 0 -# define log_debug(fmt, args...) ladish_log(LADISH_LOG_LEVEL_DEBUG, "%s:%d:%s: " fmt "\n", __FILE__, __LINE__, __func__, ## args) -# define log_info(fmt, args...) ladish_log(LADISH_LOG_LEVEL_INFO, fmt "\n", ## args) -# define log_warn(fmt, args...) ladish_log(LADISH_LOG_LEVEL_WARN, ANSI_COLOR_YELLOW "WARNING: " ANSI_RESET "%s: " fmt "\n", __func__, ## args) -# define log_error(fmt, args...) ladish_log(LADISH_LOG_LEVEL_ERROR, ANSI_COLOR_RED "ERROR: " ANSI_RESET "%s: " fmt "\n", __func__, ## args) -# define log_error_plain(fmt, args...) ladish_log(LADISH_LOG_LEVEL_ERROR_PLAIN, ANSI_COLOR_RED "ERROR: " ANSI_RESET fmt "\n", ## args) +# define log_debug(fmt, args...) ladish_log(CDBUS_LOG_LEVEL_DEBUG, "%s:%d:%s: " fmt "\n", __FILE__, __LINE__, __func__, ## args) +# define log_info(fmt, args...) ladish_log(CDBUS_LOG_LEVEL_INFO, fmt "\n", ## args) +# define log_warn(fmt, args...) ladish_log(CDBUS_LOG_LEVEL_WARN, ANSI_COLOR_YELLOW "WARNING: " ANSI_RESET "%s: " fmt "\n", __func__, ## args) +# define log_error(fmt, args...) ladish_log(CDBUS_LOG_LEVEL_ERROR, ANSI_COLOR_RED "ERROR: " ANSI_RESET "%s: " fmt "\n", __func__, ## args) +# define log_error_plain(fmt, args...) ladish_log(CDBUS_LOG_LEVEL_ERROR_PLAIN, ANSI_COLOR_RED "ERROR: " ANSI_RESET fmt "\n", ## args) #endif static @@ -172,10 +174,9 @@ ladish_log_enabled( unsigned int UNUSED(line), const char * UNUSED(func)) { - return level != LADISH_LOG_LEVEL_DEBUG; + return level != CDBUS_LOG_LEVEL_DEBUG; } -__attribute__((visibility("default"))) void ladish_log( unsigned int level, @@ -208,13 +209,13 @@ ladish_log( { switch (level) { - case LADISH_LOG_LEVEL_DEBUG: - case LADISH_LOG_LEVEL_INFO: + case CDBUS_LOG_LEVEL_DEBUG: + case CDBUS_LOG_LEVEL_INFO: stream = stdout; break; - case LADISH_LOG_LEVEL_WARN: - case LADISH_LOG_LEVEL_ERROR: - case LADISH_LOG_LEVEL_ERROR_PLAIN: + case CDBUS_LOG_LEVEL_WARN: + case CDBUS_LOG_LEVEL_ERROR: + case CDBUS_LOG_LEVEL_ERROR_PLAIN: default: stream = stderr; } @@ -231,14 +232,14 @@ ladish_log( color = NULL; switch (level) { - case LADISH_LOG_LEVEL_DEBUG: + case CDBUS_LOG_LEVEL_DEBUG: fprintf(stream, "%s:%d:%s ", file, line, func); break; - case LADISH_LOG_LEVEL_WARN: + case CDBUS_LOG_LEVEL_WARN: color = ANSI_COLOR_YELLOW; break; - case LADISH_LOG_LEVEL_ERROR: - case LADISH_LOG_LEVEL_ERROR_PLAIN: + case CDBUS_LOG_LEVEL_ERROR: + case CDBUS_LOG_LEVEL_ERROR_PLAIN: color = ANSI_COLOR_RED; break; } diff --git a/log.h b/log.h index 18bd3545..20905867 100644 --- a/log.h +++ b/log.h @@ -36,6 +36,7 @@ #define ANSI_RESET "\033[0m" #include +#include #include "config.h" @@ -49,8 +50,6 @@ # endif #endif -#define ladish_log cdbus_log - #ifdef __cplusplus extern "C" #endif @@ -67,16 +66,10 @@ ladish_log( #endif ; -#define LADISH_LOG_LEVEL_DEBUG 0 -#define LADISH_LOG_LEVEL_INFO 1 -#define LADISH_LOG_LEVEL_WARN 2 -#define LADISH_LOG_LEVEL_ERROR 3 -#define LADISH_LOG_LEVEL_ERROR_PLAIN 4 - -#define log_debug(fmt, args...) ladish_log(LADISH_LOG_LEVEL_DEBUG, __FILE__, __LINE__, __func__, fmt, ## args) -#define log_info(fmt, args...) ladish_log(LADISH_LOG_LEVEL_INFO, __FILE__, __LINE__, __func__, fmt, ## args) -#define log_warn(fmt, args...) ladish_log(LADISH_LOG_LEVEL_WARN, __FILE__, __LINE__, __func__, fmt, ## args) -#define log_error(fmt, args...) ladish_log(LADISH_LOG_LEVEL_ERROR, __FILE__, __LINE__, __func__, fmt, ## args) -#define log_error_plain(fmt, args...) ladish_log(LADISH_LOG_LEVEL_ERROR_PLAIN, __FILE__, __LINE__, __func__, fmt, ## args) +#define log_debug(fmt, args...) ladish_log(CDBUS_LOG_LEVEL_DEBUG, __FILE__, __LINE__, __func__, fmt, ## args) +#define log_info(fmt, args...) ladish_log(CDBUS_LOG_LEVEL_INFO, __FILE__, __LINE__, __func__, fmt, ## args) +#define log_warn(fmt, args...) ladish_log(CDBUS_LOG_LEVEL_WARN, __FILE__, __LINE__, __func__, fmt, ## args) +#define log_error(fmt, args...) ladish_log(CDBUS_LOG_LEVEL_ERROR, __FILE__, __LINE__, __func__, fmt, ## args) +#define log_error_plain(fmt, args...) ladish_log(CDBUS_LOG_LEVEL_ERROR_PLAIN, __FILE__, __LINE__, __func__, fmt, ## args) #endif /* __LADISH_LOG__ */