c2dfb7
From 05e184dea3f0182e5787812adfd52b68cff9418d Mon Sep 17 00:00:00 2001
c2dfb7
From: Jan Janssen <medhefgo@web.de>
c2dfb7
Date: Mon, 25 Jun 2018 20:33:31 +0200
c2dfb7
Subject: [PATCH] crypt-util: Translate libcryptsetup log level instead of
c2dfb7
 using log_debug()
c2dfb7
c2dfb7
This makes sure that errors reported by libcryptsetup are shown to the
c2dfb7
user instead of getting swallowed up by log_debug().
c2dfb7
c2dfb7
(cherry picked from commit aa2cc005d77890b07e8c579f25e1333ff8ba8dac)
c2dfb7
c2dfb7
Resolves: #1776408
c2dfb7
---
c2dfb7
 src/basic/crypt-util.c | 20 +++++++++++++++++++-
c2dfb7
 1 file changed, 19 insertions(+), 1 deletion(-)
c2dfb7
c2dfb7
diff --git a/src/basic/crypt-util.c b/src/basic/crypt-util.c
c2dfb7
index b181ba3ba0..20bdc5489e 100644
c2dfb7
--- a/src/basic/crypt-util.c
c2dfb7
+++ b/src/basic/crypt-util.c
c2dfb7
@@ -5,6 +5,24 @@
c2dfb7
 #include "log.h"
c2dfb7
 
c2dfb7
 void cryptsetup_log_glue(int level, const char *msg, void *usrptr) {
c2dfb7
-        log_debug("%s", msg);
c2dfb7
+        switch (level) {
c2dfb7
+        case CRYPT_LOG_NORMAL:
c2dfb7
+                level = LOG_NOTICE;
c2dfb7
+                break;
c2dfb7
+        case CRYPT_LOG_ERROR:
c2dfb7
+                level = LOG_ERR;
c2dfb7
+                break;
c2dfb7
+        case CRYPT_LOG_VERBOSE:
c2dfb7
+                level = LOG_INFO;
c2dfb7
+                break;
c2dfb7
+        case CRYPT_LOG_DEBUG:
c2dfb7
+                level = LOG_DEBUG;
c2dfb7
+                break;
c2dfb7
+        default:
c2dfb7
+                log_error("Unknown libcryptsetup log level: %d", level);
c2dfb7
+                level = LOG_ERR;
c2dfb7
+        }
c2dfb7
+
c2dfb7
+        log_full(level, "%s", msg);
c2dfb7
 }
c2dfb7
 #endif