[PATCH 2/2] Log: Set log target improvement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/pulsecore/cli-command.c | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c
index 3f57101..0d0c75d 100644
--- a/src/pulsecore/cli-command.c
+++ b/src/pulsecore/cli-command.c
@@ -1513,26 +1513,24 @@ static int pa_cli_command_log_target(pa_core *c, pa_tokenizer *t, pa_strbuf *buf
         return -1;
     }
 
-    log_target = pa_log_parse_target(m);
-
-    switch (log_target->type) {
-        case PA_LOG_STDERR:
-        case PA_LOG_SYSLOG:
-        case PA_LOG_NULL:
-            pa_log_set_target(log_target);
-            break;
-        case PA_LOG_FILE:
-        case PA_LOG_NEWFILE:
-            if (pa_log_set_target(log_target) < 0) {
-                pa_strbuf_puts(buf, "Failed to set log target.");
-                return -1;
-            }
-            break;
-        default:
-            pa_strbuf_puts(buf, "You need to specify a log target (null,auto,syslog,stderr,file:PATH,newfile:PATH).\n");
+    if (pa_streq(m, "auto"))
+        log_target = pa_log_target_new(PA_LOG_STDERR, NULL);
+    else {
+        log_target = pa_log_parse_target(m);
+
+        if (!log_target) {
+            pa_strbuf_puts(buf, "Invalid log target.\n");
             return -1;
+        }
     }
 
+    if (pa_log_set_target(log_target) < 0) {
+        pa_strbuf_puts(buf, "Failed to set log target.\n");
+        return -1;
+    }
+
+    pa_log_target_free(log_target);
+
     return 0;
 }
 
-- 
1.8.1.3




[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux