mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-05 13:30:02 -05:00
spa: add debug log context
Make a real debug context with a log function and move it to a new file. This way we don't need to redefine a macro. Make a new context for debugging to a log file. Make new functions to debug to a log file. Move the stringbuffer to string utils. Integrate file/line/func and topics into the debug log. We can remove some more things from the pipewire log_object function and also add support for topics.
This commit is contained in:
parent
3c67821c4a
commit
6207d98ff1
21 changed files with 231 additions and 164 deletions
|
|
@ -46,10 +46,8 @@
|
|||
#include <spa/param/param.h>
|
||||
#include <spa/pod/filter.h>
|
||||
#include <spa/pod/parser.h>
|
||||
|
||||
#undef spa_debugc
|
||||
#define spa_debugc(l,...) spa_log_debug(l, __VA_ARGS__)
|
||||
#include <spa/debug/pod.h>
|
||||
#include <spa/debug/log.h>
|
||||
|
||||
#include "alsa.h"
|
||||
|
||||
|
|
@ -739,7 +737,7 @@ static int impl_set_param(void *object,
|
|||
SPA_PARAM_PROFILE_index, SPA_POD_Int(&idx),
|
||||
SPA_PARAM_PROFILE_save, SPA_POD_OPT_Bool(&save))) < 0) {
|
||||
spa_log_warn(this->log, "can't parse profile");
|
||||
spa_debugc_pod(this->log, 0, NULL, param);
|
||||
spa_debug_log_pod(this->log, SPA_LOG_LEVEL_DEBUG, 0, NULL, param);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -764,7 +762,7 @@ static int impl_set_param(void *object,
|
|||
SPA_PARAM_ROUTE_props, SPA_POD_OPT_Pod(&props),
|
||||
SPA_PARAM_ROUTE_save, SPA_POD_OPT_Bool(&save))) < 0) {
|
||||
spa_log_warn(this->log, "can't parse route");
|
||||
spa_debugc_pod(this->log, 0, NULL, param);
|
||||
spa_debug_log_pod(this->log, SPA_LOG_LEVEL_DEBUG, 0, NULL, param);
|
||||
return res;
|
||||
}
|
||||
if (device >= this->card->n_devices)
|
||||
|
|
|
|||
|
|
@ -44,10 +44,8 @@
|
|||
#include <spa/param/param.h>
|
||||
#include <spa/pod/filter.h>
|
||||
#include <spa/pod/parser.h>
|
||||
|
||||
#undef spa_debugc
|
||||
#define spa_debugc(l,...) spa_log_debug(l, __VA_ARGS__)
|
||||
#include <spa/debug/pod.h>
|
||||
#include <spa/debug/log.h>
|
||||
|
||||
#include "alsa.h"
|
||||
|
||||
|
|
@ -466,7 +464,7 @@ static int impl_set_param(void *object,
|
|||
SPA_TYPE_OBJECT_ParamProfile, NULL,
|
||||
SPA_PARAM_PROFILE_index, SPA_POD_Int(&idx))) < 0) {
|
||||
spa_log_warn(this->log, "can't parse profile");
|
||||
spa_debugc_pod(this->log, 0, NULL, param);
|
||||
spa_debug_log_pod(this->log, SPA_LOG_LEVEL_DEBUG, 0, NULL, param);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,16 +40,14 @@
|
|||
#include <spa/param/param.h>
|
||||
#include <spa/param/audio/format-utils.h>
|
||||
#include <spa/param/latency-utils.h>
|
||||
#include <spa/debug/format.h>
|
||||
#include <spa/debug/pod.h>
|
||||
#include <spa/debug/log.h>
|
||||
|
||||
#undef SPA_LOG_TOPIC_DEFAULT
|
||||
#define SPA_LOG_TOPIC_DEFAULT log_topic
|
||||
static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.audioadapter");
|
||||
|
||||
#undef spa_debugc
|
||||
#define spa_debugc(l,...) spa_log_debug(l, __VA_ARGS__)
|
||||
#include <spa/debug/format.h>
|
||||
#include <spa/debug/pod.h>
|
||||
|
||||
#define DEFAULT_ALIGN 16
|
||||
|
||||
#define MAX_PORTS (SPA_AUDIO_MAX_CHANNELS+1)
|
||||
|
|
@ -336,7 +334,7 @@ static int debug_params(struct impl *this, struct spa_node *node,
|
|||
|
||||
if (filter) {
|
||||
spa_log_error(this->log, "with this filter:");
|
||||
spa_debugc_pod(this->log, 2, NULL, filter);
|
||||
spa_debug_log_pod(this->log, SPA_LOG_LEVEL_DEBUG, 2, NULL, filter);
|
||||
} else {
|
||||
spa_log_error(this->log, "there was no filter");
|
||||
}
|
||||
|
|
@ -354,7 +352,7 @@ static int debug_params(struct impl *this, struct spa_node *node,
|
|||
break;
|
||||
}
|
||||
spa_log_error(this->log, "unmatched %s %d:", debug, count);
|
||||
spa_debugc_pod(this->log, 2, NULL, param);
|
||||
spa_debug_log_pod(this->log, SPA_LOG_LEVEL_DEBUG, 2, NULL, param);
|
||||
count++;
|
||||
}
|
||||
if (count == 0)
|
||||
|
|
@ -483,8 +481,8 @@ static int configure_format(struct impl *this, uint32_t flags, const struct spa_
|
|||
return 0;
|
||||
|
||||
spa_log_debug(this->log, "%p: configure format:", this);
|
||||
if (format && spa_log_level_enabled(this->log, SPA_LOG_LEVEL_DEBUG))
|
||||
spa_debugc_format(this->log, 0, NULL, format);
|
||||
if (format)
|
||||
spa_debug_log_format(this->log, SPA_LOG_LEVEL_DEBUG, 0, NULL, format);
|
||||
|
||||
if ((res = spa_node_port_set_param(this->follower,
|
||||
this->direction, 0,
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@
|
|||
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
#include <spa/debug/mem.h>
|
||||
#include <spa/debug/log.h>
|
||||
#include <spa/support/log.h>
|
||||
#include <spa/support/loop.h>
|
||||
#include <spa/support/dbus.h>
|
||||
|
|
@ -563,7 +565,7 @@ static DBusHandlerResult endpoint_select_configuration(DBusConnection *conn, DBu
|
|||
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||
}
|
||||
spa_log_info(monitor->log, "%p: %s select conf %d", monitor, path, size);
|
||||
spa_log_hexdump(monitor->log, SPA_LOG_LEVEL_DEBUG, 2, cap, (size_t)size);
|
||||
spa_debug_log_mem(monitor->log, SPA_LOG_LEVEL_DEBUG, 2, cap, (size_t)size);
|
||||
|
||||
/* For codecs sharing the same endpoint, BlueZ-initiated connections
|
||||
* always pick the default one. The session manager will
|
||||
|
|
@ -592,7 +594,7 @@ static DBusHandlerResult endpoint_select_configuration(DBusConnection *conn, DBu
|
|||
return DBUS_HANDLER_RESULT_NEED_MEMORY;
|
||||
goto exit_send;
|
||||
}
|
||||
spa_log_hexdump(monitor->log, SPA_LOG_LEVEL_DEBUG, 2, pconf, (size_t)size);
|
||||
spa_debug_log_mem(monitor->log, SPA_LOG_LEVEL_DEBUG, 2, pconf, (size_t)size);
|
||||
|
||||
if ((r = dbus_message_new_method_return(m)) == NULL)
|
||||
return DBUS_HANDLER_RESULT_NEED_MEMORY;
|
||||
|
|
@ -696,7 +698,7 @@ static DBusHandlerResult endpoint_select_properties(DBusConnection *conn, DBusMe
|
|||
memcpy(caps, buf, caps_size);
|
||||
|
||||
spa_log_info(monitor->log, "%p: %s %s size:%d", monitor, path, key, caps_size);
|
||||
spa_log_hexdump(monitor->log, SPA_LOG_LEVEL_DEBUG, ' ', caps, (size_t)caps_size);
|
||||
spa_debug_log_mem(monitor->log, SPA_LOG_LEVEL_DEBUG, ' ', caps, (size_t)caps_size);
|
||||
} else if (spa_streq(key, "Endpoint")) {
|
||||
if (type != DBUS_TYPE_OBJECT_PATH) {
|
||||
spa_log_error(monitor->log, "Property %s of wrong type %c", key, (char)type);
|
||||
|
|
@ -776,7 +778,7 @@ static DBusHandlerResult endpoint_select_properties(DBusConnection *conn, DBusMe
|
|||
goto error_invalid;
|
||||
}
|
||||
spa_log_info(monitor->log, "%p: selected conf %d", monitor, conf_size);
|
||||
spa_log_hexdump(monitor->log, SPA_LOG_LEVEL_DEBUG, ' ', (uint8_t *)config, (size_t)conf_size);
|
||||
spa_debug_log_mem(monitor->log, SPA_LOG_LEVEL_DEBUG, ' ', (uint8_t *)config, (size_t)conf_size);
|
||||
|
||||
if ((r = dbus_message_new_method_return(m)) == NULL)
|
||||
return DBUS_HANDLER_RESULT_NEED_MEMORY;
|
||||
|
|
@ -2064,7 +2066,7 @@ static int remote_endpoint_update_props(struct spa_bt_remote_endpoint *remote_en
|
|||
dbus_message_iter_get_fixed_array(&iter, &value, &len);
|
||||
|
||||
spa_log_debug(monitor->log, "remote_endpoint %p: %s=%d", remote_endpoint, key, len);
|
||||
spa_log_hexdump(monitor->log, SPA_LOG_LEVEL_DEBUG, 2, value, (size_t)len);
|
||||
spa_debug_log_mem(monitor->log, SPA_LOG_LEVEL_DEBUG, 2, value, (size_t)len);
|
||||
|
||||
free(remote_endpoint->capabilities);
|
||||
remote_endpoint->capabilities_len = 0;
|
||||
|
|
@ -2616,7 +2618,7 @@ static int transport_update_props(struct spa_bt_transport *transport,
|
|||
dbus_message_iter_get_fixed_array(&iter, &value, &len);
|
||||
|
||||
spa_log_debug(monitor->log, "transport %p: %s=%d", transport, key, len);
|
||||
spa_log_hexdump(monitor->log, SPA_LOG_LEVEL_DEBUG, 2, value, (size_t)len);
|
||||
spa_debug_log_mem(monitor->log, SPA_LOG_LEVEL_DEBUG, 2, value, (size_t)len);
|
||||
|
||||
free(transport->configuration);
|
||||
transport->configuration_len = 0;
|
||||
|
|
|
|||
|
|
@ -48,10 +48,8 @@
|
|||
#include <spa/param/audio/raw.h>
|
||||
#include <spa/param/bluetooth/audio.h>
|
||||
#include <spa/param/bluetooth/type-info.h>
|
||||
|
||||
#undef spa_debugc
|
||||
#define spa_debugc(l,...) spa_log_debug(l, __VA_ARGS__)
|
||||
#include <spa/debug/pod.h>
|
||||
#include <spa/debug/log.h>
|
||||
|
||||
#include "defs.h"
|
||||
#include "media-codecs.h"
|
||||
|
|
@ -2117,7 +2115,7 @@ static int impl_set_param(void *object,
|
|||
SPA_PARAM_PROFILE_index, SPA_POD_Int(&idx),
|
||||
SPA_PARAM_PROFILE_save, SPA_POD_OPT_Bool(&save))) < 0) {
|
||||
spa_log_warn(this->log, "can't parse profile");
|
||||
spa_debugc_pod(this->log, 0, NULL, param);
|
||||
spa_debug_log_pod(this->log, SPA_LOG_LEVEL_DEBUG, 0, NULL, param);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -2145,7 +2143,7 @@ static int impl_set_param(void *object,
|
|||
SPA_PARAM_ROUTE_props, SPA_POD_OPT_Pod(&props),
|
||||
SPA_PARAM_ROUTE_save, SPA_POD_OPT_Bool(&save))) < 0) {
|
||||
spa_log_warn(this->log, "can't parse route");
|
||||
spa_debugc_pod(this->log, 0, NULL, param);
|
||||
spa_debug_log_pod(this->log, SPA_LOG_LEVEL_DEBUG, 0, NULL, param);
|
||||
return res;
|
||||
}
|
||||
if (device > 1 || !this->nodes[device].active)
|
||||
|
|
@ -2176,7 +2174,7 @@ static int impl_set_param(void *object,
|
|||
SPA_PROP_bluetoothAudioCodec, SPA_POD_OPT_Id(&codec_id),
|
||||
SPA_PROP_bluetoothOffloadActive, SPA_POD_OPT_Bool(&offload_active))) < 0) {
|
||||
spa_log_warn(this->log, "can't parse props");
|
||||
spa_debugc_pod(this->log, 0, NULL, param);
|
||||
spa_debug_log_pod(this->log, SPA_LOG_LEVEL_DEBUG, 0, NULL, param);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@
|
|||
#include <spa/param/audio/format.h>
|
||||
#include <spa/param/audio/format-utils.h>
|
||||
#include <spa/pod/filter.h>
|
||||
#include <spa/debug/mem.h>
|
||||
#include <spa/debug/log.h>
|
||||
|
||||
#include <sbc/sbc.h>
|
||||
|
||||
|
|
@ -949,7 +951,7 @@ static int do_start(struct impl *this)
|
|||
size = this->transport->configuration_len;
|
||||
|
||||
spa_log_debug(this->log, "Transport configuration:");
|
||||
spa_log_hexdump(this->log, SPA_LOG_LEVEL_DEBUG, 2, conf, (size_t)size);
|
||||
spa_debug_log_mem(this->log, SPA_LOG_LEVEL_DEBUG, 2, conf, (size_t)size);
|
||||
|
||||
flags = this->is_duplex ? MEDIA_CODEC_FLAG_SINK : 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -43,10 +43,8 @@
|
|||
#include <spa/param/param.h>
|
||||
#include <spa/pod/filter.h>
|
||||
#include <spa/pod/parser.h>
|
||||
|
||||
#undef spa_debugc
|
||||
#define spa_debugc(l,...) spa_log_debug(l, __VA_ARGS__)
|
||||
#include <spa/debug/pod.h>
|
||||
#include <spa/debug/log.h>
|
||||
|
||||
#include "jack-client.h"
|
||||
|
||||
|
|
@ -340,7 +338,7 @@ static int impl_set_param(void *object,
|
|||
SPA_TYPE_OBJECT_ParamProfile, NULL,
|
||||
SPA_PARAM_PROFILE_index, SPA_POD_Int(&idx))) < 0) {
|
||||
spa_log_warn(this->log, "can't parse profile");
|
||||
spa_debugc_pod(this->log, 0, NULL, param);
|
||||
spa_debug_log_pod(this->log, SPA_LOG_LEVEL_DEBUG, 0, NULL, param);
|
||||
return res;
|
||||
}
|
||||
activate_profile(this, idx);
|
||||
|
|
|
|||
|
|
@ -40,16 +40,14 @@
|
|||
#include <spa/param/param.h>
|
||||
#include <spa/param/video/format-utils.h>
|
||||
#include <spa/param/latency-utils.h>
|
||||
#include <spa/debug/format.h>
|
||||
#include <spa/debug/pod.h>
|
||||
#include <spa/debug/log.h>
|
||||
|
||||
#undef SPA_LOG_TOPIC_DEFAULT
|
||||
#define SPA_LOG_TOPIC_DEFAULT log_topic
|
||||
static struct spa_log_topic *log_topic = &SPA_LOG_TOPIC(0, "spa.videoadapter");
|
||||
|
||||
#undef spa_debugc
|
||||
#define spa_debugc(l,...) spa_log_debug(l, __VA_ARGS__)
|
||||
#include <spa/debug/format.h>
|
||||
#include <spa/debug/pod.h>
|
||||
|
||||
#define DEFAULT_ALIGN 16
|
||||
|
||||
#define MAX_PORTS 1
|
||||
|
|
@ -302,7 +300,7 @@ static int debug_params(struct impl *this, struct spa_node *node,
|
|||
|
||||
if (filter) {
|
||||
spa_log_error(this->log, "with this filter:");
|
||||
spa_debugc_pod(this->log, 2, NULL, filter);
|
||||
spa_debug_log_pod(this->log, SPA_LOG_LEVEL_DEBUG, 2, NULL, filter);
|
||||
} else {
|
||||
spa_log_error(this->log, "there was no filter");
|
||||
}
|
||||
|
|
@ -320,7 +318,7 @@ static int debug_params(struct impl *this, struct spa_node *node,
|
|||
break;
|
||||
}
|
||||
spa_log_error(this->log, "unmatched %s %d:", debug, count);
|
||||
spa_debugc_pod(this->log, 2, NULL, param);
|
||||
spa_debug_log_pod(this->log, SPA_LOG_LEVEL_DEBUG, 2, NULL, param);
|
||||
count++;
|
||||
}
|
||||
if (count == 0)
|
||||
|
|
@ -445,8 +443,8 @@ static int configure_format(struct impl *this, uint32_t flags, const struct spa_
|
|||
int res;
|
||||
|
||||
spa_log_debug(this->log, "%p: configure format:", this);
|
||||
if (format && spa_log_level_enabled(this->log, SPA_LOG_LEVEL_DEBUG))
|
||||
spa_debugc_format(this->log, 0, NULL, format);
|
||||
if (format)
|
||||
spa_debug_log_format(this->log, SPA_LOG_LEVEL_DEBUG, 0, NULL, format);
|
||||
|
||||
if ((res = spa_node_port_set_param(this->follower,
|
||||
this->direction, 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue