From cd6ec641deaf94e2eb2fcaf87b9236f65479ef3f Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Sat, 6 Jan 2024 03:27:07 +0900
Subject: [PATCH] udevadm: allow to override the default log level by
 environment variable

Previously, there was no way to override the log level for test and
test-builtin commands. Let's re-parse environment after setting the log
level to debug. Then, we can control the log level through environment
variable.

(cherry picked from commit 7ba3e44651d43d8bc3644b991a060842649a34a7)
---
 src/udev/udevadm-test-builtin.c | 1 +
 src/udev/udevadm-test.c         | 1 +
 2 files changed, 2 insertions(+)

diff --git a/src/udev/udevadm-test-builtin.c b/src/udev/udevadm-test-builtin.c
index f5498a1e5b1..088b4da3c1a 100644
--- a/src/udev/udevadm-test-builtin.c
+++ b/src/udev/udevadm-test-builtin.c
@@ -78,6 +78,7 @@ int builtin_main(int argc, char *argv[], void *userdata) {
         int r;
 
         log_set_max_level(LOG_DEBUG);
+        log_parse_environment();
 
         r = parse_argv(argc, argv);
         if (r <= 0)
diff --git a/src/udev/udevadm-test.c b/src/udev/udevadm-test.c
index 809143ede0b..e1afd7d29e6 100644
--- a/src/udev/udevadm-test.c
+++ b/src/udev/udevadm-test.c
@@ -95,6 +95,7 @@ int test_main(int argc, char *argv[], void *userdata) {
         int r;
 
         log_set_max_level(LOG_DEBUG);
+        log_parse_environment();
 
         r = parse_argv(argc, argv);
         if (r <= 0)
