]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
main: allow log output to be redirected
authorRay Strode <rstrode@redhat.com>
Tue, 10 May 2011 19:42:29 +0000 (15:42 -0400)
committerRay Strode <rstrode@redhat.com>
Tue, 10 May 2011 20:27:57 +0000 (16:27 -0400)
Sometimes putting debug output on the screen has strange side
effects.  This commit adds a new kernel command line option,
e.g:

plymouth.debug=stream:/dev/null

that moves the output "out of the way"

src/main.c

index 84f4e5dcf91da8b7bf042e0b34b868627f5fe7b3..8ec67c7f032837585505227266399b44141d313c 100644 (file)
@@ -1717,18 +1717,20 @@ get_kernel_command_line (state_t *state)
 static void
 check_verbosity (state_t *state)
 {
+  const char *stream;
   const char *path;
 
   ply_trace ("checking if tracing should be enabled");
 
+  stream = command_line_get_string_after_prefix (state->kernel_command_line,
+                                                 "plymouth.debug=stream:");
+
   path = command_line_get_string_after_prefix (state->kernel_command_line,
                                                "plymouth.debug=file:");
-  if (path != NULL ||
+  if (stream != NULL || path != NULL ||
       command_line_has_argument (state->kernel_command_line, "plymouth.debug"))
     {
-#ifdef LOG_TO_DEBUG_FILE
       int fd;
-#endif
 
       ply_trace ("tracing should be enabled!");
       if (!ply_is_tracing ())
@@ -1746,10 +1748,20 @@ check_verbosity (state_t *state)
         if (debug_buffer == NULL)
           debug_buffer = ply_buffer_new ();
 
-#ifdef LOG_TO_DEBUG_FILE
-      fd = open ("/dev/console", O_RDWR);
-      ply_logger_set_output_fd (ply_logger_get_error_default (), fd);
-#endif
+      if (stream != NULL)
+        {
+          ply_trace ("streaming debug output to %s instead of screen", stream);
+          fd = open (stream, O_RDWR | O_NOCTTY | O_CREAT, 0600);
+
+          if (fd < 0)
+            {
+              ply_trace ("could not stream output to %s: %m", stream);
+            }
+          else
+            {
+              ply_logger_set_output_fd (ply_logger_get_error_default (), fd);
+            }
+        }
     }
   else
     ply_trace ("tracing shouldn't be enabled!");