]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/shared/cryptsetup-util.c
shared: rename crypt-util.c → cryptsetup-util.c
[thirdparty/systemd.git] / src / shared / cryptsetup-util.c
CommitLineData
58f21e63 1/* SPDX-License-Identifier: LGPL-2.1+ */
691c2e2e
ZJS
2
3#if HAVE_LIBCRYPTSETUP
1e2f3230 4#include "cryptsetup-util.h"
691c2e2e
ZJS
5#include "log.h"
6
efc3b12f 7static void cryptsetup_log_glue(int level, const char *msg, void *usrptr) {
aa2cc005
JJ
8 switch (level) {
9 case CRYPT_LOG_NORMAL:
10 level = LOG_NOTICE;
11 break;
12 case CRYPT_LOG_ERROR:
13 level = LOG_ERR;
14 break;
15 case CRYPT_LOG_VERBOSE:
16 level = LOG_INFO;
17 break;
18 case CRYPT_LOG_DEBUG:
19 level = LOG_DEBUG;
20 break;
21 default:
22 log_error("Unknown libcryptsetup log level: %d", level);
23 level = LOG_ERR;
24 }
25
26 log_full(level, "%s", msg);
691c2e2e 27}
efc3b12f
LB
28
29void cryptsetup_enable_logging(struct crypt_device *cd) {
30 crypt_set_log_callback(cd, cryptsetup_log_glue, NULL);
31 crypt_set_debug_level(DEBUG_LOGGING ? CRYPT_DEBUG_ALL : CRYPT_DEBUG_NONE);
32}
33
691c2e2e 34#endif