Fix log-target=dlog/dlog-color 26/15426/1
authorHuaqiang Geng <huaqiangx.geng@intel.com>
Tue, 21 Jan 2014 02:50:25 +0000 (10:50 +0800)
committerHuaqiang Geng <huaqiangx.geng@intel.com>
Tue, 21 Jan 2014 04:32:21 +0000 (12:32 +0800)
Change-Id: Idf96588e5992003f4abe7e447044891f855b7a14
Signed-off-by: Huaqiang Geng <huaqiangx.geng@intel.com>
src/daemon/cmdline.c
src/daemon/daemon-conf.c
src/pulsecore/cli-command.c
src/pulsecore/log.c

index 6361a3d..ab5b27c 100644 (file)
@@ -141,7 +141,11 @@ void pa_cmdline_help(const char *argv0) {
            "                                        this time passed\n"
            "      --log-level[=LEVEL]               Increase or set verbosity level\n"
            "  -v                                    Increase the verbosity level\n"
+#ifdef USE_DLOG
+           "      --log-target={auto,syslog,stderr,file:PATH,newfile:PATH,dlog,dlog-color}\n"
+#else
            "      --log-target={auto,syslog,stderr,file:PATH,newfile:PATH}\n"
+#endif
            "                                        Specify the log target\n"
            "      --log-meta[=BOOL]                 Include code location in log messages\n"
            "      --log-time[=BOOL]                 Include timestamps in log messages\n"
@@ -323,7 +327,11 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
 
             case ARG_LOG_TARGET:
                 if (pa_daemon_conf_set_log_target(conf, optarg) < 0) {
+#ifdef USE_DLOG
+                    pa_log(_("Invalid log target: use either 'syslog', 'stderr' or 'auto' or a valid file name 'file:<path>', 'newfile:<path>' or 'dlog' or 'dlog-color'."));
+#else
                     pa_log(_("Invalid log target: use either 'syslog', 'stderr' or 'auto' or a valid file name 'file:<path>', 'newfile:<path>'."));
+#endif
                     goto fail;
                 }
                 break;
index 3ac02e2..7360019 100644 (file)
@@ -189,15 +189,8 @@ int pa_daemon_conf_set_log_target(pa_daemon_conf *c, const char *string) {
         if (!log_target)
             return -1;
 
-       c->log_target = log_target;
+        c->log_target = log_target;
     }
-#ifdef USE_DLOG
-    else if (!strcmp(string, "dlog")) {
-        c->log_target = PA_LOG_DLOG;
-    } else if (!strcmp(string, "dlog-color")) {
-        c->log_target = PA_LOG_DLOG_COLOR;
-    }
-#endif
 
     return 0;
 }
index d2cc38a..73fb7aa 100644 (file)
@@ -188,7 +188,11 @@ static const struct command commands[] = {
     { "kill-client",             pa_cli_command_kill_client,        "Kill a client (args: index)", 2},
     { "kill-sink-input",         pa_cli_command_kill_sink_input,    "Kill a sink input (args: index)", 2},
     { "kill-source-output",      pa_cli_command_kill_source_output, "Kill a source output (args: index)", 2},
+#ifdef USE_DLOG
+    { "set-log-target",          pa_cli_command_log_target,         "Change the log target (args: null|auto|syslog|stderr|file:PATH|newfile:PATH|dlog|dlog-color)", 2},
+#else
     { "set-log-target",          pa_cli_command_log_target,         "Change the log target (args: null|auto|syslog|stderr|file:PATH|newfile:PATH)", 2},
+#endif
     { "set-log-level",           pa_cli_command_log_level,          "Change the log level (args: numeric level)", 2},
     { "set-log-meta",            pa_cli_command_log_meta,           "Show source code location in log messages (args: bool)", 2},
     { "set-log-time",            pa_cli_command_log_time,           "Show timestamps in log messages (args: bool)", 2},
@@ -1508,7 +1512,11 @@ static int pa_cli_command_log_target(pa_core *c, pa_tokenizer *t, pa_strbuf *buf
     pa_assert(fail);
 
     if (!(m = pa_tokenizer_get(t, 1))) {
+#ifdef USE_DLOG
+        pa_strbuf_puts(buf, "You need to specify a log target (null|auto|syslog|stderr|file:PATH|newfile:PATH|dlog|dlog-color).\n");
+#else
         pa_strbuf_puts(buf, "You need to specify a log target (null|auto|syslog|stderr|file:PATH|newfile:PATH).\n");
+#endif
         return -1;
     }
 
index 9962dd1..6b807dd 100644 (file)
@@ -665,6 +665,12 @@ pa_log_target *pa_log_parse_target(const char *string) {
         t = pa_log_target_new(PA_LOG_FILE, string + 5);
     else if (pa_startswith(string, "newfile:"))
         t = pa_log_target_new(PA_LOG_NEWFILE, string + 8);
+#ifdef USE_DLOG
+    else if (pa_streq(string, "dlog"))
+        t = pa_log_target_new(PA_LOG_DLOG, NULL);
+    else if (pa_streq(string, "dlog-color"))
+        t = pa_log_target_new(PA_LOG_DLOG_COLOR, NULL);
+#endif
     else
         pa_log(_("Invalid log target."));