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
#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_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 */

View File

@ -25,6 +25,7 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "../common.h"
#include <errno.h>
@ -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;
}

19
log.h
View File

@ -36,6 +36,7 @@
#define ANSI_RESET "\033[0m"
#include <stdio.h>
#include <cdbus/log.h>
#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__ */