mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
log: Correct bad function implementation
Replace wrong implementation of log to file in pa_daemon_conf_set_log_level to pa_daemon_conf_set_log_target
This commit is contained in:
parent
99e37b6003
commit
a9c8f904b0
1 changed files with 15 additions and 17 deletions
|
|
@ -187,6 +187,21 @@ int pa_daemon_conf_set_log_target(pa_daemon_conf *c, const char *string) {
|
||||||
} else if (!strcmp(string, "stderr")) {
|
} else if (!strcmp(string, "stderr")) {
|
||||||
c->auto_log_target = 0;
|
c->auto_log_target = 0;
|
||||||
c->log_target = PA_LOG_STDERR;
|
c->log_target = PA_LOG_STDERR;
|
||||||
|
} 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
|
} else
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
@ -213,23 +228,6 @@ int pa_daemon_conf_set_log_level(pa_daemon_conf *c, const char *string) {
|
||||||
c->log_level = PA_LOG_WARN;
|
c->log_level = PA_LOG_WARN;
|
||||||
else if (pa_startswith(string, "err"))
|
else if (pa_startswith(string, "err"))
|
||||||
c->log_level = PA_LOG_ERROR;
|
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
|
else
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue