diff options
Diffstat (limited to 'src/daemon/daemon-conf.c')
-rw-r--r-- | src/daemon/daemon-conf.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c index f640b039..9b530a80 100644 --- a/src/daemon/daemon-conf.c +++ b/src/daemon/daemon-conf.c @@ -28,6 +28,7 @@ #include <stdio.h> #include <string.h> #include <unistd.h> +#include <fcntl.h> #ifdef HAVE_SCHED_H #include <sched.h> @@ -180,6 +181,9 @@ pa_daemon_conf* pa_daemon_conf_new(void) { void pa_daemon_conf_free(pa_daemon_conf *c) { pa_assert(c); + + pa_log_set_fd(-1); + pa_xfree(c->script_commands); pa_xfree(c->dl_search_path); pa_xfree(c->default_script_file); @@ -225,6 +229,23 @@ int pa_daemon_conf_set_log_level(pa_daemon_conf *c, const char *string) { c->log_level = PA_LOG_WARN; else if (pa_startswith(string, "err")) c->log_level = PA_LOG_ERROR; + else if (pa_startswith(string, "file:")) { + char file_path[512]; + int log_fd; + + pa_strlcpy(file_path, string + 5, sizeof(file_path)); + + /* Open target file with user rights */ + if ((log_fd = open(file_path, O_RDWR|O_TRUNC|O_CREAT, S_IRWXU)) >= 0) { + c->auto_log_target = 0; + c->log_target = PA_LOG_FD; + pa_log_set_fd(log_fd); + } + else { + printf("Failed to open target file %s, error : %s\n", file_path, pa_cstrerror(errno)); + return -1; + } + } else return -1; @@ -307,8 +328,8 @@ static int parse_resample_method(const char *filename, unsigned line, const char return 0; } -static int parse_rlimit(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata) { #ifdef HAVE_SYS_RESOURCE_H +static int parse_rlimit(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata) { struct pa_rlimit *r = data; pa_assert(filename); @@ -329,12 +350,10 @@ static int parse_rlimit(const char *filename, unsigned line, const char *section r->is_set = k >= 0; r->value = k >= 0 ? (rlim_t) k : 0; } -#else - pa_log_warn(_("[%s:%u] rlimit not supported on this platform."), filename, line); -#endif return 0; } +#endif static int parse_sample_format(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata) { pa_daemon_conf *c = data; |