All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: include file and function names in logs
@ 2020-03-10 17:00 Manish Mandlik
  2020-03-11 14:32 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Manish Mandlik @ 2020-03-10 17:00 UTC (permalink / raw)
  To: marcel
  Cc: Joseph Hwang, Yoni Shavit, Miao-chen Chou, Alain Michaud,
	linux-bluetooth, Manish Mandlik, David S. Miller, Johan Hedberg,
	netdev, linux-kernel, Jakub Kicinski

From: Joseph Hwang <josephsih@chromium.org>

Include file and function names in bluetooth kernel logs to
help debugging.

Signed-off-by: Joseph Hwang <josephsih@chromium.org>
Signed-off-by: Manish Mandlik <mmandlik@google.com>
---

 include/net/bluetooth/bluetooth.h | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 1576353a27732..2024d9c53d687 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -150,10 +150,21 @@ void bt_warn_ratelimited(const char *fmt, ...);
 __printf(1, 2)
 void bt_err_ratelimited(const char *fmt, ...);
 
-#define BT_INFO(fmt, ...)	bt_info(fmt "\n", ##__VA_ARGS__)
-#define BT_WARN(fmt, ...)	bt_warn(fmt "\n", ##__VA_ARGS__)
-#define BT_ERR(fmt, ...)	bt_err(fmt "\n", ##__VA_ARGS__)
-#define BT_DBG(fmt, ...)	pr_debug(fmt "\n", ##__VA_ARGS__)
+static inline const char *basename(const char *path)
+{
+	const char *str = strrchr(path, '/');
+
+	return str ? (str + 1) : path;
+}
+
+#define BT_INFO(fmt, ...)	bt_info("%s:%s() " fmt "\n",		\
+				basename(__FILE__), __func__, ##__VA_ARGS__)
+#define BT_WARN(fmt, ...)	bt_warn("%s:%s() " fmt "\n",		\
+				basename(__FILE__), __func__, ##__VA_ARGS__)
+#define BT_ERR(fmt, ...)	bt_err("%s:%s() " fmt "\n",		\
+				basename(__FILE__), __func__, ##__VA_ARGS__)
+#define BT_DBG(fmt, ...)	pr_debug("%s:%s() " fmt "\n",		\
+				basename(__FILE__), __func__, ##__VA_ARGS__)
 
 #define bt_dev_info(hdev, fmt, ...)				\
 	BT_INFO("%s: " fmt, (hdev)->name, ##__VA_ARGS__)
-- 
2.25.1.481.gfbce0eb801-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Bluetooth: include file and function names in logs
  2020-03-10 17:00 [PATCH] Bluetooth: include file and function names in logs Manish Mandlik
@ 2020-03-11 14:32 ` Marcel Holtmann
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2020-03-11 14:32 UTC (permalink / raw)
  To: Manish Mandlik
  Cc: Joseph Hwang, Yoni Shavit, Miao-chen Chou, Alain Michaud,
	linux-bluetooth, David S. Miller, Johan Hedberg, netdev,
	linux-kernel, Jakub Kicinski

Hi Manish,

> Include file and function names in bluetooth kernel logs to
> help debugging.
> 
> Signed-off-by: Joseph Hwang <josephsih@chromium.org>
> Signed-off-by: Manish Mandlik <mmandlik@google.com>
> ---
> 
> include/net/bluetooth/bluetooth.h | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
> index 1576353a27732..2024d9c53d687 100644
> --- a/include/net/bluetooth/bluetooth.h
> +++ b/include/net/bluetooth/bluetooth.h
> @@ -150,10 +150,21 @@ void bt_warn_ratelimited(const char *fmt, ...);
> __printf(1, 2)
> void bt_err_ratelimited(const char *fmt, ...);
> 
> -#define BT_INFO(fmt, ...)	bt_info(fmt "\n", ##__VA_ARGS__)
> -#define BT_WARN(fmt, ...)	bt_warn(fmt "\n", ##__VA_ARGS__)
> -#define BT_ERR(fmt, ...)	bt_err(fmt "\n", ##__VA_ARGS__)
> -#define BT_DBG(fmt, ...)	pr_debug(fmt "\n", ##__VA_ARGS__)
> +static inline const char *basename(const char *path)
> +{
> +	const char *str = strrchr(path, '/');
> +
> +	return str ? (str + 1) : path;
> +}
> +
> +#define BT_INFO(fmt, ...)	bt_info("%s:%s() " fmt "\n",		\
> +				basename(__FILE__), __func__, ##__VA_ARGS__)
> +#define BT_WARN(fmt, ...)	bt_warn("%s:%s() " fmt "\n",		\
> +				basename(__FILE__), __func__, ##__VA_ARGS__)
> +#define BT_ERR(fmt, ...)	bt_err("%s:%s() " fmt "\n",		\
> +				basename(__FILE__), __func__, ##__VA_ARGS__)
> +#define BT_DBG(fmt, ...)	pr_debug("%s:%s() " fmt "\n",		\
> +				basename(__FILE__), __func__, ##__VA_ARGS__)
> 
> #define bt_dev_info(hdev, fmt, ...)				\
> 	BT_INFO("%s: " fmt, (hdev)->name, ##__VA_ARGS__)

this is NAK from my side. We don’t want to include __FILE__ and __func__ names in the standard messages. I am however working in revamping the whole printk and debug of the Bluetooth subsystem. I will send around the initial pieces of my work as a RFC soon.

Regards

Marcel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-11 14:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-10 17:00 [PATCH] Bluetooth: include file and function names in logs Manish Mandlik
2020-03-11 14:32 ` Marcel Holtmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.