chiark / gitweb /
log: als turn on debug logging in non-PID1 if /proc/cmdline contains "debug"
authorLennart Poettering <lennart@poettering.net>
Mon, 23 Dec 2013 16:56:44 +0000 (17:56 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 23 Dec 2013 16:56:44 +0000 (17:56 +0100)
src/core/main.c
src/shared/log.c

index 5189833e48bc8a37cea302a426ad86cce0d2253d..064445d17e00f30887240c1b159af3d0fae262df 100644 (file)
@@ -462,7 +462,6 @@ DEFINE_SETTER(config_parse_target, log_set_target_from_string, "target")
 DEFINE_SETTER(config_parse_color, log_show_color_from_string, "color" )
 DEFINE_SETTER(config_parse_location, log_show_location_from_string, "location")
 
-
 static int config_parse_cpu_affinity2(const char *unit,
                                       const char *filename,
                                       unsigned line,
index 268f0340a12416c32cf842c1e0d6d26deed5b0f7..2a075ffebab7953c81c905b6811fb719ed80bb44 100644 (file)
@@ -879,7 +879,24 @@ int log_set_max_level_from_string(const char *e) {
 }
 
 void log_parse_environment(void) {
+        _cleanup_free_ char *line = NULL;
         const char *e;
+        int r;
+
+        r = proc_cmdline(&line);
+        if (r < 0)
+                log_warning("Failed to read /proc/cmdline. Ignoring: %s", strerror(-r));
+        else if (r > 0) {
+                char *w, *state;
+                size_t l;
+
+                FOREACH_WORD_QUOTED(w, l, line, state) {
+                        if (l == 5 && startswith(w, "debug")) {
+                                log_set_max_level(LOG_DEBUG);
+                                break;
+                        }
+                }
+        }
 
         e = secure_getenv("SYSTEMD_LOG_TARGET");
         if (e && log_set_target_from_string(e) < 0)