[CRIU] [PATCH cr 1/8] restorer: unify log functions

Andrey Vagin avagin at openvz.org
Fri Sep 14 06:25:25 EDT 2012


Add ability to use the same macros in restorer code.
In the future we will add ability to show arguments like printf.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 include/restorer-log.h |    5 ++---
 restorer-log.c         |    4 ++--
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/include/restorer-log.h b/include/restorer-log.h
index eb0e726..a48cbb0 100644
--- a/include/restorer-log.h
+++ b/include/restorer-log.h
@@ -9,18 +9,17 @@ extern void write_hex_n_on_level(unsigned int loglevel, unsigned long num);
 extern void write_num_n_on_level(unsigned int loglevel, long num);
 extern void write_num_on_level(unsigned int loglevel, long num);
 extern void write_str_n_on_level(unsigned int loglevel, char *str);
-extern void write_str_on_level(unsigned int loglevel, char *str);
 
 extern void restorer_set_logfd(int fd);
 extern void restorer_set_loglevel(unsigned int loglevel);
 
-#define write_str_err(str)	write_str_on_level(LOG_ERROR, str)
+#define write_str_err(str)	print_on_level(LOG_ERROR, str)
 #define write_str_n_err(str)	write_str_n_on_level(LOG_ERROR, str)
 
 #define	write_num_err(num)	write_num_on_level(LOG_ERROR, num)
 #define write_num_n_err(num)	write_num_n_on_level(LOG_ERROR, num)
 
-#define write_str_info(str)	write_str_on_level(LOG_INFO, str)
+#define write_str_info(str)	print_on_level(LOG_INFO, str)
 #define write_str_n_info(str)	write_str_n_on_level(LOG_INFO, str)
 
 #define write_num_info(num)	write_num_on_level(LOG_INFO, num)
diff --git a/restorer-log.c b/restorer-log.c
index 2580680..3331232 100644
--- a/restorer-log.c
+++ b/restorer-log.c
@@ -22,7 +22,7 @@ void restorer_set_loglevel(unsigned int loglevel)
 	current_loglevel = loglevel;
 }
 
-static void write_str(char *str)
+static void write_str(const char *str)
 {
 	int len = 0;
 
@@ -32,7 +32,7 @@ static void write_str(char *str)
 	sys_write(current_logfd, str, len);
 }
 
-void write_str_on_level(unsigned int loglevel, char *str)
+void print_on_level(unsigned int loglevel, const char *str, ...)
 {
 	if (loglevel > current_loglevel)
 		return;
-- 
1.7.1



More information about the CRIU mailing list