diff --git a/src/daemon/cmdline.c b/src/daemon/cmdline.c index 4854aff..25a9414 100644 --- a/src/daemon/cmdline.c +++ b/src/daemon/cmdline.c @@ -145,7 +145,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 OS_IS_WIN32 + " --log-target={auto,windbg,stderr,file:PATH}\n" +#else " --log-target={auto,syslog,stderr,file: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" @@ -319,7 +323,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 OS_IS_WIN32 + pa_log(_("Invalid log target: use either 'windbg', 'stderr' or 'auto' or a valid file name 'file:'.")); +#else pa_log(_("Invalid log target: use either 'syslog', 'stderr' or 'auto' or a valid file name 'file:'.")); +#endif goto fail; } break; diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c index 67b772a..fca82bb 100644 --- a/src/daemon/daemon-conf.c +++ b/src/daemon/daemon-conf.c @@ -179,11 +179,17 @@ int pa_daemon_conf_set_log_target(pa_daemon_conf *c, const char *string) { pa_assert(c); pa_assert(string); - if (!strcmp(string, "auto")) + if (!strcmp(string, "auto")) { c->auto_log_target = 1; - else if (!strcmp(string, "syslog")) { +#ifdef OS_IS_WIN32 + } else if (!strcmp(string, "windbg")) { + c->auto_log_target = 0; + c->log_target = PA_LOG_WINDBG; +#else + } else if (!strcmp(string, "syslog")) { c->auto_log_target = 0; c->log_target = PA_LOG_SYSLOG; +#endif } else if (!strcmp(string, "stderr")) { c->auto_log_target = 0; c->log_target = PA_LOG_STDERR; diff --git a/src/daemon/main.c b/src/daemon/main.c index 5316656..8ba03b4 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -811,8 +811,13 @@ int main(int argc, char *argv[]) { daemon_pipe[0] = -1; #endif - if (conf->auto_log_target) + if (conf->auto_log_target) { +#ifdef OS_IS_WIN32 + pa_log_set_target(PA_LOG_WINDBG); +#else pa_log_set_target(PA_LOG_SYSLOG); +#endif + } #ifdef HAVE_SETSID if (setsid() < 0) { diff --git a/src/pulse/client-conf.c b/src/pulse/client-conf.c index 18fafe3..1bb9829 100644 --- a/src/pulse/client-conf.c +++ b/src/pulse/client-conf.c @@ -71,7 +71,11 @@ pa_client_conf *pa_client_conf_new(void) { pa_client_conf *c = pa_xmemdup(&default_conf, sizeof(default_conf)); c->daemon_binary = pa_xstrdup(PA_BINARY); +#ifdef OS_IS_WIN32 + c->extra_arguments = pa_xstrdup("--log-target=windbg"); +#else c->extra_arguments = pa_xstrdup("--log-target=syslog"); +#endif c->cookie_file = pa_xstrdup(PA_NATIVE_COOKIE_FILE); return c; diff --git a/src/pulsecore/log.c b/src/pulsecore/log.c index b12cbf0..caa4774 100644 --- a/src/pulsecore/log.c +++ b/src/pulsecore/log.c @@ -426,6 +426,22 @@ void pa_log_levelv_meta( break; } +#ifdef OS_IS_WIN32 + case PA_LOG_WINDBG: { + char *local_t; + char *line; + /* We shouldn't be using dynamic allocation here to + * minimize the hit in RT threads */ + if ((local_t = pa_utf8_to_locale(t))) + t = local_t; + /* No timestamp, as windows debug buffer facility already provides one */ + line = pa_sprintf_malloc("%c %s %s", level_to_char[level], location, t); + OutputDebugStringA(line); + pa_xfree(line); + pa_xfree(local_t); + break; + } +#endif case PA_LOG_NULL: default: break; diff --git a/src/pulsecore/log.h b/src/pulsecore/log.h index ad04e7b..e209ec5 100644 --- a/src/pulsecore/log.h +++ b/src/pulsecore/log.h @@ -37,6 +37,7 @@ typedef enum pa_log_target { PA_LOG_SYSLOG, PA_LOG_NULL, /* to /dev/null */ PA_LOG_FD, /* to a file descriptor, e.g. a char device */ + PA_LOG_WINDBG, /* log to windows debug buffer */ PA_LOG_TARGET_MAX } pa_log_target_t;