All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH btbridge] Add timestamps to output messages
@ 2015-12-08 23:00 OpenBMC Patches
  2015-12-08 23:00 ` OpenBMC Patches
  0 siblings, 1 reply; 3+ messages in thread
From: OpenBMC Patches @ 2015-12-08 23:00 UTC (permalink / raw)
  To: openbmc

There have been some problems with timeouts. This should help narrow down where some of the time is going.

https://github.com/openbmc/btbridge/pull/9

Cyril Bur (1):
  Add timestamps to output messages

 btbridged.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

-- 
2.6.3

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

* [PATCH btbridge] Add timestamps to output messages
  2015-12-08 23:00 [PATCH btbridge] Add timestamps to output messages OpenBMC Patches
@ 2015-12-08 23:00 ` OpenBMC Patches
  2015-12-10  3:15   ` Stewart Smith
  0 siblings, 1 reply; 3+ messages in thread
From: OpenBMC Patches @ 2015-12-08 23:00 UTC (permalink / raw)
  To: openbmc; +Cc: Cyril Bur

From: Cyril Bur <cyril.bur@au1.ibm.com>

---
 btbridged.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/btbridged.c b/btbridged.c
index 115ae63..2fd1e4f 100644
--- a/btbridged.c
+++ b/btbridged.c
@@ -35,7 +35,7 @@
 
 #include <systemd/sd-bus.h>
 
-#define PREFIX "[BTBRIDGED] "
+#define PREFIX "BTBRIDGED"
 
 #define BT_HOST_PATH "/dev/bt-host"
 #define BT_HOST_TIMEOUT_SEC 1
@@ -49,13 +49,8 @@
 #define TIMER_FD 2
 #define TOTAL_FDS 3
 
-#define MSG_OUT(f_, ...) do { if (verbose) { printf(PREFIX); printf((f_), ##__VA_ARGS__); } } while(0)
-#define MSG_ERR(f_, ...) do {  \
-                         	if (verbose) { \
-                         		fprintf(stderr, PREFIX); \
-                         		fprintf(stderr, (f_), ##__VA_ARGS__); \
-                         	} \
-                         } while(0)
+#define MSG_OUT(f_, ...) do { if (verbose) { log(stdout, f_, ##__VA_ARGS__); } } while(0)
+#define MSG_ERR(f_, ...) do { if (verbose) { log(stderr, f_, ##__VA_ARGS__); } } while(0)
 
 struct ipmi_msg {
 	uint8_t netfn;
@@ -86,6 +81,22 @@ static int running = 1;
 static int verbose;
 static int debug;
 
+__attribute__((format(printf, 2, 3)))
+static void log(FILE *s, const char *fmt, ...)
+{
+	va_list args;
+	struct timespec time;
+
+	clock_gettime(CLOCK_REALTIME, &time);
+
+	fprintf(s, "[%s %ld.%ld] ", PREFIX, time.tv_sec, time.tv_nsec);
+
+	va_start(args, fmt);
+	vfprintf(s, fmt, args);
+	va_end(args);
+
+}
+
 static struct bt_queue *bt_q_get_head(struct btbridged_context *context)
 {
 	return context ? context->bt_q : NULL;
-- 
2.6.3

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

* Re: [PATCH btbridge] Add timestamps to output messages
  2015-12-08 23:00 ` OpenBMC Patches
@ 2015-12-10  3:15   ` Stewart Smith
  0 siblings, 0 replies; 3+ messages in thread
From: Stewart Smith @ 2015-12-10  3:15 UTC (permalink / raw)
  To: OpenBMC Patches, openbmc; +Cc: Cyril Bur

OpenBMC Patches <openbmc-patches@stwcx.xyz> writes:
> From: Cyril Bur <cyril.bur@au1.ibm.com>
>
> ---
>  btbridged.c | 27 +++++++++++++++++++--------
>  1 file changed, 19 insertions(+), 8 deletions(-)

Looks like a relatively sane way to do it.

Acked-by: Stewart Smith <stewart@linux.vnet.ibm.com>

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

end of thread, other threads:[~2015-12-10  3:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-08 23:00 [PATCH btbridge] Add timestamps to output messages OpenBMC Patches
2015-12-08 23:00 ` OpenBMC Patches
2015-12-10  3:15   ` Stewart Smith

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.