[CRIU] [PATCH] log: Introduce LOG_PREFIX

Cyrill Gorcunov gorcunov at openvz.org
Mon Jul 30 13:10:03 EDT 2012


Useful if one need a prefix over module messages.
I use it in tty c/r, thus having something like

 | TTY: master 0x31 index 2 fd 6 pid 5079 (create 1)
 | TTY:     `- slave 0x5c index 2 fd 255 pid 5080 (create 0 send 0)
 | TTY: standalone slave 0x2e index 1 fd 3 pid 5079 (create 1)

in log. Which helps filtering messages.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 include/log.h |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/include/log.h b/include/log.h
index e4bb73a..282711d 100644
--- a/include/log.h
+++ b/include/log.h
@@ -18,20 +18,24 @@ extern void print_on_level(unsigned int loglevel, const char *format, ...)
 #define LOG_INFO	(3) /* Informative, everything is fine */
 #define LOG_DEBUG	(4) /* Debug only */
 
+#ifndef LOG_PREFIX
+# define LOG_PREFIX
+#endif
+
 #define pr_msg(fmt, ...)	\
 	print_on_level(LOG_MSG,		fmt, ##__VA_ARGS__)
 
 #define pr_info(fmt, ...)	\
-	print_on_level(LOG_INFO,	fmt, ##__VA_ARGS__)
+	print_on_level(LOG_INFO,	LOG_PREFIX fmt, ##__VA_ARGS__)
 
 #define pr_err(fmt, ...)	\
-	print_on_level(LOG_ERROR,	"Error (%s:%d): " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
+	print_on_level(LOG_ERROR,	"Error (%s:%d): " LOG_PREFIX fmt, __FILE__, __LINE__, ##__VA_ARGS__)
 
 #define pr_warn(fmt, ...)	\
-	print_on_level(LOG_WARN,	"Warn  (%s:%d): " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
+	print_on_level(LOG_WARN,	"Warn  (%s:%d): " LOG_PREFIX fmt, __FILE__, __LINE__, ##__VA_ARGS__)
 
 #define pr_debug(fmt, ...)	\
-	print_on_level(LOG_DEBUG,	fmt, ##__VA_ARGS__)
+	print_on_level(LOG_DEBUG,	LOG_PREFIX fmt, ##__VA_ARGS__)
 
 #define pr_perror(fmt, ...)	\
 	pr_err(fmt ": %m\n", ##__VA_ARGS__)
-- 
1.7.7.6



More information about the CRIU mailing list