[lxc-devel] [PATCH] add file/func/line to debug info

Serge Hallyn serge.hallyn at ubuntu.com
Mon Sep 29 16:14:28 UTC 2014


Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
 src/lxc/log.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/lxc/log.c b/src/lxc/log.c
index e3c64ee..0fe376c 100644
--- a/src/lxc/log.c
+++ b/src/lxc/log.c
@@ -72,6 +72,7 @@ static int log_append_stderr(const struct lxc_log_appender *appender,
 		return 0;
 
 	fprintf(stderr, "%s: ", log_prefix);
+	fprintf(stderr, "%s: %s: %d ", event->locinfo->file, event->locinfo->func, event->locinfo->line);
 	vfprintf(stderr, event->fmt, *event->vap);
 	fprintf(stderr, "\n");
 	return 0;
@@ -90,12 +91,14 @@ static int log_append_logfile(const struct lxc_log_appender *appender,
 
 	ms = event->timestamp.tv_usec / 1000;
 	n = snprintf(buffer, sizeof(buffer),
-		     "%15s %10ld.%03d %-8s %s - ",
+		     "%15s %10ld.%03d %-8s %s - %s:%s:%d - ",
 		     log_prefix,
 		     event->timestamp.tv_sec,
 		     ms,
 		     lxc_log_priority_to_string(event->priority),
-		     event->category);
+		     event->category,
+		     event->locinfo->file, event->locinfo->func,
+		     event->locinfo->line);
 
 	n += vsnprintf(buffer + n, sizeof(buffer) - n, event->fmt,
 		       *event->vap);
-- 
1.7.9.5



More information about the lxc-devel mailing list