Adjust for the updated log cdbus interface

This commit is contained in:
Nedko Arnaudov 2023-05-01 13:04:54 +03:00
parent ca769c4ec8
commit e88d2014ba
3 changed files with 29 additions and 30 deletions

View File

@ -27,7 +27,10 @@
#ifndef ALSAPID_H__0A27F284_7538_4791_8023_0FBED929EAF3__INCLUDED #ifndef ALSAPID_H__0A27F284_7538_4791_8023_0FBED929EAF3__INCLUDED
#define 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 <stdbool.h> /* C99 bool */
#include <stdlib.h> /* pid_t */
void alsapid_compose_src_link(int alsa_client_id, char * buffer); void alsapid_compose_src_link(int alsa_client_id, char * buffer);
void alsapid_compose_dst_link(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 MAX_ALSAPID_PATH 255
#define LADISH_PUBLIC __attribute__ ((visibility ("default")))
#endif /* #ifndef ALSAPID_H__0A27F284_7538_4791_8023_0FBED929EAF3__INCLUDED */ #endif /* #ifndef ALSAPID_H__0A27F284_7538_4791_8023_0FBED929EAF3__INCLUDED */

View File

@ -25,6 +25,7 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#include "config.h"
#include "../common.h" #include "../common.h"
#include <errno.h> #include <errno.h>
@ -133,6 +134,7 @@ void ladish_log_init()
} }
ladish_log_open(); ladish_log_open();
cdbus_log_setup(ladish_log);
free_log_dir: free_log_dir:
free(ladish_log_dir); free(ladish_log_dir);
@ -157,11 +159,11 @@ void ladish_log_uninit()
#endif /* #if !defined(LOG_OUTPUT_STDOUT) */ #endif /* #if !defined(LOG_OUTPUT_STDOUT) */
#if 0 #if 0
# define log_debug(fmt, args...) ladish_log(LADISH_LOG_LEVEL_DEBUG, "%s:%d:%s: " fmt "\n", __FILE__, __LINE__, __func__, ## 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(LADISH_LOG_LEVEL_INFO, fmt "\n", ## args) # define log_info(fmt, args...) ladish_log(CDBUS_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_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(LADISH_LOG_LEVEL_ERROR, ANSI_COLOR_RED "ERROR: " 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(LADISH_LOG_LEVEL_ERROR_PLAIN, ANSI_COLOR_RED "ERROR: " ANSI_RESET fmt "\n", ## args) # define log_error_plain(fmt, args...) ladish_log(CDBUS_LOG_LEVEL_ERROR_PLAIN, ANSI_COLOR_RED "ERROR: " ANSI_RESET fmt "\n", ## args)
#endif #endif
static static
@ -172,10 +174,9 @@ ladish_log_enabled(
unsigned int UNUSED(line), unsigned int UNUSED(line),
const char * UNUSED(func)) const char * UNUSED(func))
{ {
return level != LADISH_LOG_LEVEL_DEBUG; return level != CDBUS_LOG_LEVEL_DEBUG;
} }
__attribute__((visibility("default")))
void void
ladish_log( ladish_log(
unsigned int level, unsigned int level,
@ -208,13 +209,13 @@ ladish_log(
{ {
switch (level) switch (level)
{ {
case LADISH_LOG_LEVEL_DEBUG: case CDBUS_LOG_LEVEL_DEBUG:
case LADISH_LOG_LEVEL_INFO: case CDBUS_LOG_LEVEL_INFO:
stream = stdout; stream = stdout;
break; break;
case LADISH_LOG_LEVEL_WARN: case CDBUS_LOG_LEVEL_WARN:
case LADISH_LOG_LEVEL_ERROR: case CDBUS_LOG_LEVEL_ERROR:
case LADISH_LOG_LEVEL_ERROR_PLAIN: case CDBUS_LOG_LEVEL_ERROR_PLAIN:
default: default:
stream = stderr; stream = stderr;
} }
@ -231,14 +232,14 @@ ladish_log(
color = NULL; color = NULL;
switch (level) switch (level)
{ {
case LADISH_LOG_LEVEL_DEBUG: case CDBUS_LOG_LEVEL_DEBUG:
fprintf(stream, "%s:%d:%s ", file, line, func); fprintf(stream, "%s:%d:%s ", file, line, func);
break; break;
case LADISH_LOG_LEVEL_WARN: case CDBUS_LOG_LEVEL_WARN:
color = ANSI_COLOR_YELLOW; color = ANSI_COLOR_YELLOW;
break; break;
case LADISH_LOG_LEVEL_ERROR: case CDBUS_LOG_LEVEL_ERROR:
case LADISH_LOG_LEVEL_ERROR_PLAIN: case CDBUS_LOG_LEVEL_ERROR_PLAIN:
color = ANSI_COLOR_RED; color = ANSI_COLOR_RED;
break; break;
} }

19
log.h
View File

@ -36,6 +36,7 @@
#define ANSI_RESET "\033[0m" #define ANSI_RESET "\033[0m"
#include <stdio.h> #include <stdio.h>
#include <cdbus/log.h>
#include "config.h" #include "config.h"
@ -49,8 +50,6 @@
# endif # endif
#endif #endif
#define ladish_log cdbus_log
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
#endif #endif
@ -67,16 +66,10 @@ ladish_log(
#endif #endif
; ;
#define LADISH_LOG_LEVEL_DEBUG 0 #define log_debug(fmt, args...) ladish_log(CDBUS_LOG_LEVEL_DEBUG, __FILE__, __LINE__, __func__, fmt, ## args)
#define LADISH_LOG_LEVEL_INFO 1 #define log_info(fmt, args...) ladish_log(CDBUS_LOG_LEVEL_INFO, __FILE__, __LINE__, __func__, fmt, ## args)
#define LADISH_LOG_LEVEL_WARN 2 #define log_warn(fmt, args...) ladish_log(CDBUS_LOG_LEVEL_WARN, __FILE__, __LINE__, __func__, fmt, ## args)
#define LADISH_LOG_LEVEL_ERROR 3 #define log_error(fmt, args...) ladish_log(CDBUS_LOG_LEVEL_ERROR, __FILE__, __LINE__, __func__, fmt, ## args)
#define LADISH_LOG_LEVEL_ERROR_PLAIN 4 #define log_error_plain(fmt, args...) ladish_log(CDBUS_LOG_LEVEL_ERROR_PLAIN, __FILE__, __LINE__, __func__, fmt, ## args)
#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)
#endif /* __LADISH_LOG__ */ #endif /* __LADISH_LOG__ */