2022-03-24 03:29:37

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [PATCH BlueZ v4 4/9] adapter: Don't use DBG in mgmt_debug

From: Luiz Augusto von Dentz <[email protected]>

mgmt_debug callback is used to print debug strings from mgmt instances
which includes the file and function names so using DBG would add yet
another set of file and function prefixes which makes the logs
confusing.
---
src/adapter.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 97ce26f8e..9f003346d 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -10327,9 +10327,7 @@ static void read_version_complete(uint8_t status, uint16_t length,

static void mgmt_debug(const char *str, void *user_data)
{
- const char *prefix = user_data;
-
- info("%s%s", prefix, str);
+ DBG_IDX(0xffff, "%s", str);
}

int adapter_init(void)
@@ -10342,8 +10340,7 @@ int adapter_init(void)
return -EIO;
}

- if (getenv("MGMT_DEBUG"))
- mgmt_set_debug(mgmt_primary, mgmt_debug, "mgmt: ", NULL);
+ mgmt_set_debug(mgmt_primary, mgmt_debug, NULL, NULL);

DBG("sending read version command");

--
2.35.1


2022-03-25 18:04:57

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH BlueZ v4 4/9] adapter: Don't use DBG in mgmt_debug

Hi Luiz,

> mgmt_debug callback is used to print debug strings from mgmt instances
> which includes the file and function names so using DBG would add yet
> another set of file and function prefixes which makes the logs
> confusing.
> ---
> src/adapter.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index 97ce26f8e..9f003346d 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -10327,9 +10327,7 @@ static void read_version_complete(uint8_t status, uint16_t length,
>
> static void mgmt_debug(const char *str, void *user_data)
> {
> - const char *prefix = user_data;
> -
> - info("%s%s", prefix, str);
> + DBG_IDX(0xffff, "%s", str);
> }
>
> int adapter_init(void)
> @@ -10342,8 +10340,7 @@ int adapter_init(void)
> return -EIO;
> }
>
> - if (getenv("MGMT_DEBUG"))
> - mgmt_set_debug(mgmt_primary, mgmt_debug, "mgmt: ", NULL);
> + mgmt_set_debug(mgmt_primary, mgmt_debug, NULL, NULL);
>
> DBG("sending read version command");

oh what now. If you touch this, then please do it in a way that you print it properly to the btmon traces as well with the correct index.

Look, the MGMT_DEBUG thing is meant for debugging aid. That is why it enabled tracing. If you want to print errors or warning that otherwise are hidden, just print them. And make sure they end up in btmon as well. This is all hacking around the real solution. It is a bandaid for a bandaid.

Regards

Marcel