daemon: move syslog facility and syslog tag into log_params
Since struct log_params already contains logging-related varaiables, including syslog-related, move remaining syslog-related variables into struct log_params as well Reviewed by: kevans Pull Request: https://github.com/freebsd/freebsd-src/pull/669
This commit is contained in:
parent
e70444c622
commit
6f0636728b
@ -61,7 +61,9 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
struct log_params {
|
struct log_params {
|
||||||
const char *output_filename;
|
const char *output_filename;
|
||||||
|
const char *syslog_tag;
|
||||||
int syslog_priority;
|
int syslog_priority;
|
||||||
|
int syslog_facility;
|
||||||
int noclose;
|
int noclose;
|
||||||
int output_fd;
|
int output_fd;
|
||||||
bool syslog_enabled;
|
bool syslog_enabled;
|
||||||
@ -146,13 +148,11 @@ main(int argc, char *argv[])
|
|||||||
bool log_reopen = false;
|
bool log_reopen = false;
|
||||||
char *p = NULL;
|
char *p = NULL;
|
||||||
const char *pidfile = NULL;
|
const char *pidfile = NULL;
|
||||||
const char *syslog_tag = "daemon";
|
|
||||||
const char *ppidfile = NULL;
|
const char *ppidfile = NULL;
|
||||||
const char *title = NULL;
|
const char *title = NULL;
|
||||||
const char *user = NULL;
|
const char *user = NULL;
|
||||||
int ch = 0;
|
int ch = 0;
|
||||||
int child_eof = 0;
|
int child_eof = 0;
|
||||||
int syslog_facility = LOG_DAEMON;
|
|
||||||
int nochdir = 1;
|
int nochdir = 1;
|
||||||
int pfd[2] = { -1, -1 };
|
int pfd[2] = { -1, -1 };
|
||||||
int restart = 0;
|
int restart = 0;
|
||||||
@ -160,6 +160,8 @@ main(int argc, char *argv[])
|
|||||||
struct log_params logpar = {
|
struct log_params logpar = {
|
||||||
.syslog_enabled = false,
|
.syslog_enabled = false,
|
||||||
.syslog_priority = LOG_NOTICE,
|
.syslog_priority = LOG_NOTICE,
|
||||||
|
.syslog_tag = "daemon",
|
||||||
|
.syslog_facility = LOG_DAEMON,
|
||||||
.noclose = 1,
|
.noclose = 1,
|
||||||
.output_fd = -1,
|
.output_fd = -1,
|
||||||
.output_filename = NULL
|
.output_filename = NULL
|
||||||
@ -188,8 +190,8 @@ main(int argc, char *argv[])
|
|||||||
log_reopen = true;
|
log_reopen = true;
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
syslog_facility = get_log_mapping(optarg, facilitynames);
|
logpar.syslog_facility = get_log_mapping(optarg, facilitynames);
|
||||||
if (syslog_facility == -1) {
|
if (logpar.syslog_facility == -1) {
|
||||||
errx(5, "unrecognized syslog facility");
|
errx(5, "unrecognized syslog facility");
|
||||||
}
|
}
|
||||||
logpar.syslog_enabled = true;
|
logpar.syslog_enabled = true;
|
||||||
@ -232,7 +234,7 @@ main(int argc, char *argv[])
|
|||||||
title = optarg;
|
title = optarg;
|
||||||
break;
|
break;
|
||||||
case 'T':
|
case 'T':
|
||||||
syslog_tag = optarg;
|
logpar.syslog_tag = optarg;
|
||||||
logpar.syslog_enabled = true;
|
logpar.syslog_enabled = true;
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
@ -264,7 +266,7 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (logpar.syslog_enabled) {
|
if (logpar.syslog_enabled) {
|
||||||
openlog(syslog_tag, LOG_PID | LOG_NDELAY, syslog_facility);
|
openlog(logpar.syslog_tag, LOG_PID | LOG_NDELAY, logpar.syslog_facility);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user