From f50af7f4851dfb6f440571569eca0b21c9d913ef Mon Sep 17 00:00:00 2001 From: Huaqiang Geng Date: Tue, 21 Jan 2014 10:50:25 +0800 Subject: [PATCH] Fix log-target=dlog/dlog-color Change-Id: Idf96588e5992003f4abe7e447044891f855b7a14 Signed-off-by: Huaqiang Geng --- src/daemon/cmdline.c | 8 ++++++++ src/daemon/daemon-conf.c | 9 +-------- src/pulsecore/cli-command.c | 8 ++++++++ src/pulsecore/log.c | 6 ++++++ 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/daemon/cmdline.c b/src/daemon/cmdline.c index 6361a3d..ab5b27c 100644 --- a/src/daemon/cmdline.c +++ b/src/daemon/cmdline.c @@ -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:', 'newfile:' or 'dlog' or 'dlog-color'.")); +#else pa_log(_("Invalid log target: use either 'syslog', 'stderr' or 'auto' or a valid file name 'file:', 'newfile:'.")); +#endif goto fail; } break; diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c index 3ac02e2..7360019 100644 --- a/src/daemon/daemon-conf.c +++ b/src/daemon/daemon-conf.c @@ -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; } diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c index d2cc38a..73fb7aa 100644 --- a/src/pulsecore/cli-command.c +++ b/src/pulsecore/cli-command.c @@ -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; } diff --git a/src/pulsecore/log.c b/src/pulsecore/log.c index 9962dd1..6b807dd 100644 --- a/src/pulsecore/log.c +++ b/src/pulsecore/log.c @@ -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.")); -- 2.7.4