linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ] log: Make error and warn log file and function information
@ 2020-04-29 22:16 Luiz Augusto von Dentz
  2020-05-01 22:05 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2020-04-29 22:16 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This makes it a lot simpler to find out where errors/warnings come from
and also remove the possibility of clashes when having multiple places
where the message would be exactly the same.
---
 src/log.c | 26 --------------------------
 src/log.h |  6 ++++--
 2 files changed, 4 insertions(+), 28 deletions(-)

diff --git a/src/log.c b/src/log.c
index 11d26d508..a42c5941d 100644
--- a/src/log.c
+++ b/src/log.c
@@ -53,32 +53,6 @@ static void monitor_log(uint16_t index, int priority,
 	bt_log_vprintf(index, LOG_IDENT, priority, format, ap);
 }
 
-void error(const char *format, ...)
-{
-	va_list ap;
-
-	va_start(ap, format);
-	vsyslog(LOG_ERR, format, ap);
-	va_end(ap);
-
-	va_start(ap, format);
-	monitor_log(HCI_DEV_NONE, LOG_ERR, format, ap);
-	va_end(ap);
-}
-
-void warn(const char *format, ...)
-{
-	va_list ap;
-
-	va_start(ap, format);
-	vsyslog(LOG_WARNING, format, ap);
-	va_end(ap);
-
-	va_start(ap, format);
-	monitor_log(HCI_DEV_NONE, LOG_WARNING, format, ap);
-	va_end(ap);
-}
-
 void info(const char *format, ...)
 {
 	va_list ap;
diff --git a/src/log.h b/src/log.h
index 0d243ceca..e83431151 100644
--- a/src/log.h
+++ b/src/log.h
@@ -23,8 +23,6 @@
 
 #include <stdint.h>
 
-void error(const char *format, ...) __attribute__((format(printf, 1, 2)));
-void warn(const char *format, ...) __attribute__((format(printf, 1, 2)));
 void info(const char *format, ...) __attribute__((format(printf, 1, 2)));
 
 void btd_log(uint16_t index, int priority, const char *format, ...)
@@ -71,3 +69,7 @@ void __btd_enable_debug(struct btd_debug_desc *start,
 } while (0)
 
 #define DBG(fmt, arg...) DBG_IDX(0xffff, fmt, ## arg)
+#define error(fmt, arg...) \
+	btd_error(0xffff, "%s:%s() " fmt, __FILE__, __func__, ## arg)
+#define warn(fmt, arg...) \
+	btd_warn(0xffff, "%s:%s() " fmt, __FILE__, __func__, ## arg)
-- 
2.25.3


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

* Re: [PATCH BlueZ] log: Make error and warn log file and function information
  2020-04-29 22:16 [PATCH BlueZ] log: Make error and warn log file and function information Luiz Augusto von Dentz
@ 2020-05-01 22:05 ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2020-05-01 22:05 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

On Wed, Apr 29, 2020 at 3:16 PM Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This makes it a lot simpler to find out where errors/warnings come from
> and also remove the possibility of clashes when having multiple places
> where the message would be exactly the same.
> ---
>  src/log.c | 26 --------------------------
>  src/log.h |  6 ++++--
>  2 files changed, 4 insertions(+), 28 deletions(-)
>
> diff --git a/src/log.c b/src/log.c
> index 11d26d508..a42c5941d 100644
> --- a/src/log.c
> +++ b/src/log.c
> @@ -53,32 +53,6 @@ static void monitor_log(uint16_t index, int priority,
>         bt_log_vprintf(index, LOG_IDENT, priority, format, ap);
>  }
>
> -void error(const char *format, ...)
> -{
> -       va_list ap;
> -
> -       va_start(ap, format);
> -       vsyslog(LOG_ERR, format, ap);
> -       va_end(ap);
> -
> -       va_start(ap, format);
> -       monitor_log(HCI_DEV_NONE, LOG_ERR, format, ap);
> -       va_end(ap);
> -}
> -
> -void warn(const char *format, ...)
> -{
> -       va_list ap;
> -
> -       va_start(ap, format);
> -       vsyslog(LOG_WARNING, format, ap);
> -       va_end(ap);
> -
> -       va_start(ap, format);
> -       monitor_log(HCI_DEV_NONE, LOG_WARNING, format, ap);
> -       va_end(ap);
> -}
> -
>  void info(const char *format, ...)
>  {
>         va_list ap;
> diff --git a/src/log.h b/src/log.h
> index 0d243ceca..e83431151 100644
> --- a/src/log.h
> +++ b/src/log.h
> @@ -23,8 +23,6 @@
>
>  #include <stdint.h>
>
> -void error(const char *format, ...) __attribute__((format(printf, 1, 2)));
> -void warn(const char *format, ...) __attribute__((format(printf, 1, 2)));
>  void info(const char *format, ...) __attribute__((format(printf, 1, 2)));
>
>  void btd_log(uint16_t index, int priority, const char *format, ...)
> @@ -71,3 +69,7 @@ void __btd_enable_debug(struct btd_debug_desc *start,
>  } while (0)
>
>  #define DBG(fmt, arg...) DBG_IDX(0xffff, fmt, ## arg)
> +#define error(fmt, arg...) \
> +       btd_error(0xffff, "%s:%s() " fmt, __FILE__, __func__, ## arg)
> +#define warn(fmt, arg...) \
> +       btd_warn(0xffff, "%s:%s() " fmt, __FILE__, __func__, ## arg)
> --
> 2.25.3

Pushed.

-- 
Luiz Augusto von Dentz

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

* [PATCH BlueZ] log: Make error and warn log file and function information
@ 2020-04-29 21:04 Luiz Augusto von Dentz
  0 siblings, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2020-04-29 21:04 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This makes it a lot simpler to find out where errors/warnings come from
and also remove the possibility of clashes when having multiple places
where the message would be exactly the same.
---
 src/log.c | 26 --------------------------
 src/log.h |  6 ++++--
 2 files changed, 4 insertions(+), 28 deletions(-)

diff --git a/src/log.c b/src/log.c
index 11d26d508..a42c5941d 100644
--- a/src/log.c
+++ b/src/log.c
@@ -53,32 +53,6 @@ static void monitor_log(uint16_t index, int priority,
 	bt_log_vprintf(index, LOG_IDENT, priority, format, ap);
 }
 
-void error(const char *format, ...)
-{
-	va_list ap;
-
-	va_start(ap, format);
-	vsyslog(LOG_ERR, format, ap);
-	va_end(ap);
-
-	va_start(ap, format);
-	monitor_log(HCI_DEV_NONE, LOG_ERR, format, ap);
-	va_end(ap);
-}
-
-void warn(const char *format, ...)
-{
-	va_list ap;
-
-	va_start(ap, format);
-	vsyslog(LOG_WARNING, format, ap);
-	va_end(ap);
-
-	va_start(ap, format);
-	monitor_log(HCI_DEV_NONE, LOG_WARNING, format, ap);
-	va_end(ap);
-}
-
 void info(const char *format, ...)
 {
 	va_list ap;
diff --git a/src/log.h b/src/log.h
index 0d243ceca..73240e259 100644
--- a/src/log.h
+++ b/src/log.h
@@ -23,8 +23,6 @@
 
 #include <stdint.h>
 
-void error(const char *format, ...) __attribute__((format(printf, 1, 2)));
-void warn(const char *format, ...) __attribute__((format(printf, 1, 2)));
 void info(const char *format, ...) __attribute__((format(printf, 1, 2)));
 
 void btd_log(uint16_t index, int priority, const char *format, ...)
@@ -71,3 +69,7 @@ void __btd_enable_debug(struct btd_debug_desc *start,
 } while (0)
 
 #define DBG(fmt, arg...) DBG_IDX(0xffff, fmt, ## arg)
+#define error(fmt, arg...) \
+	btd_error(0xffff, "%s:%s() " fmt, __FILE__, __func__ , ## arg)
+#define warn(fmt, arg...) \
+	btd_warn(0xffff, "%s:%s() " fmt, __FILE__, __func__ , ## arg)
-- 
2.25.3


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

end of thread, other threads:[~2020-05-01 22:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-29 22:16 [PATCH BlueZ] log: Make error and warn log file and function information Luiz Augusto von Dentz
2020-05-01 22:05 ` Luiz Augusto von Dentz
  -- strict thread matches above, loose matches on Subject: below --
2020-04-29 21:04 Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).