[lxc-devel] [PATCH RFC] add file and line to debug output

Serge Hallyn serge.hallyn at ubuntu.com
Thu Sep 25 19:46:58 UTC 2014


Seems like this might be helpful with remote debugging.

Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
 src/lxc/log.h | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/src/lxc/log.h b/src/lxc/log.h
index b47f120..b550e6b 100644
--- a/src/lxc/log.h
+++ b/src/lxc/log.h
@@ -245,53 +245,63 @@ ATTR_UNUSED static inline void LXC_##PRIORITY(struct lxc_log_locinfo* locinfo,	\
  */
 #define TRACE(format, ...) do {						\
 	struct lxc_log_locinfo locinfo = LXC_LOG_LOCINFO_INIT;		\
-	LXC_TRACE(&locinfo, format, ##__VA_ARGS__);			\
+	LXC_TRACE(&locinfo, "%s:%d: " format, __FILE__, __LINE__,	\
+				##__VA_ARGS__);				\
 } while (0)
 
 #define DEBUG(format, ...) do {						\
 	struct lxc_log_locinfo locinfo = LXC_LOG_LOCINFO_INIT;		\
-	LXC_DEBUG(&locinfo, format, ##__VA_ARGS__);			\
+	LXC_DEBUG(&locinfo, "%s:%d: " format, __FILE__, __LINE__,	\
+				##__VA_ARGS__);				\
 } while (0)
 
 #define INFO(format, ...) do {						\
 	struct lxc_log_locinfo locinfo = LXC_LOG_LOCINFO_INIT;		\
-	LXC_INFO(&locinfo, format, ##__VA_ARGS__);			\
+	LXC_INFO(&locinfo, "%s:%d: " format, __FILE__, __LINE__,	\
+				##__VA_ARGS__);				\
 } while (0)
 
 #define NOTICE(format, ...) do {					\
 	struct lxc_log_locinfo locinfo = LXC_LOG_LOCINFO_INIT;		\
-	LXC_NOTICE(&locinfo, format, ##__VA_ARGS__);			\
+	LXC_NOTICE(&locinfo, "%s:%d: " format, __FILE__, __LINE__,	\
+				##__VA_ARGS__);				\
 } while (0)
 
 #define WARN(format, ...) do {						\
 	struct lxc_log_locinfo locinfo = LXC_LOG_LOCINFO_INIT;		\
-	LXC_WARN(&locinfo, format, ##__VA_ARGS__);			\
+	LXC_WARN(&locinfo, "%s:%d: " format, __FILE__, __LINE__,	\
+				##__VA_ARGS__);				\
 } while (0)
 
 #define ERROR(format, ...) do {						\
 	struct lxc_log_locinfo locinfo = LXC_LOG_LOCINFO_INIT;		\
-	LXC_ERROR(&locinfo, format, ##__VA_ARGS__);			\
+	LXC_ERROR(&locinfo, "%s:%d: " format, __FILE__, __LINE__,	\
+				##__VA_ARGS__);				\
 } while (0)
 
 #define CRIT(format, ...) do {						\
 	struct lxc_log_locinfo locinfo = LXC_LOG_LOCINFO_INIT;		\
-	LXC_CRIT(&locinfo, format, ##__VA_ARGS__);			\
+	LXC_CRIT(&locinfo, "%s:%d: " format, __FILE__, __LINE__,	\
+				##__VA_ARGS__);				\
 } while (0)
 
 #define ALERT(format, ...) do {						\
 	struct lxc_log_locinfo locinfo = LXC_LOG_LOCINFO_INIT;		\
-	LXC_ALERT(&locinfo, format, ##__VA_ARGS__);			\
+	LXC_ALERT(&locinfo, "%s:%d: " format, __FILE__, __LINE__,	\
+				##__VA_ARGS__);				\
 } while (0)
 
 #define FATAL(format, ...) do {						\
 	struct lxc_log_locinfo locinfo = LXC_LOG_LOCINFO_INIT;		\
-	LXC_FATAL(&locinfo, format, ##__VA_ARGS__);			\
+	LXC_FATAL(&locinfo, "%s:%d: " format, __FILE__, __LINE__,	\
+				##__VA_ARGS__);				\
 } while (0)
 
 
 
 #define SYSERROR(format, ...) do {				    	\
-	ERROR("%s - " format, strerror(errno), ##__VA_ARGS__);		\
+	ERROR("%s:%d: %s - " format, __FILE__, __LINE__,		\
+			strerror(errno), ##__VA_ARGS__);		\
 } while (0)
 
 #ifdef HAVE_TLS
-- 
2.1.0



More information about the lxc-devel mailing list