criu: remap soccr log levels to criu levels

Submitted by Andrei Vagin on Nov. 22, 2017, 12:18 a.m.

Details

Message ID 20171122001852.26939-1-avagin@openvz.org
State New
Series "criu: remap soccr log levels to criu levels"
Headers show

Commit Message

Andrei Vagin Nov. 22, 2017, 12:18 a.m.
criu and soccr has different values for log levels, so
someone has to remap them.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Reported-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrei Vagin <avagin@openvz.org>
---
 criu/crtools.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/criu/crtools.c b/criu/crtools.c
index ebfd1d6a7..741b7b2eb 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -208,6 +208,28 @@  bool deprecated_ok(char *what)
 	return false;
 }
 
+static void soccr_print_on_level(unsigned int loglevel, const char *format, ...)
+{
+	va_list args;
+	int lv;
+
+	switch (loglevel) {
+	case SOCCR_LOG_DBG:
+		lv = LOG_DEBUG;
+		break;
+	case SOCCR_LOG_ERR:
+		lv = LOG_ERROR;
+		break;
+	default:
+		lv = LOG_INFO;
+		break;
+	}
+
+	va_start(args, format);
+	vprint_on_level(lv, format, args);
+	va_end(args);
+}
+
 int main(int argc, char *argv[], char *envp[])
 {
 
@@ -688,7 +710,7 @@  int main(int argc, char *argv[], char *envp[])
 
 	if (log_init(opts.output))
 		return 1;
-	libsoccr_set_log(log_level, print_on_level);
+	libsoccr_set_log(log_level, soccr_print_on_level);
 	compel_log_init(vprint_on_level, log_get_loglevel());
 
 	pr_debug("Version: %s (gitid %s)\n", CRIU_VERSION, CRIU_GITID);

Comments

Cyrill Gorcunov Nov. 22, 2017, 6:19 a.m.
On Tue, Nov 21, 2017 at 04:18:52PM -0800, Andrei Vagin wrote:
> criu and soccr has different values for log levels, so
> someone has to remap them.
> 
> Cc: Cyrill Gorcunov <gorcunov@openvz.org>
> Reported-by: Cyrill Gorcunov <gorcunov@openvz.org>
> Signed-off-by: Andrei Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>