nghttpx: Use ImmutableString for log file
This commit is contained in:
parent
9055323b67
commit
2b707bff27
|
@ -1121,7 +1121,7 @@ void fill_default_config() {
|
||||||
accessconf.format = parse_log_format(DEFAULT_ACCESSLOG_FORMAT);
|
accessconf.format = parse_log_format(DEFAULT_ACCESSLOG_FORMAT);
|
||||||
|
|
||||||
auto &errorconf = loggingconf.error;
|
auto &errorconf = loggingconf.error;
|
||||||
errorconf.file = strcopy("/dev/stderr");
|
errorconf.file = "/dev/stderr";
|
||||||
}
|
}
|
||||||
|
|
||||||
loggingconf.syslog_facility = LOG_DAEMON;
|
loggingconf.syslog_facility = LOG_DAEMON;
|
||||||
|
@ -1752,7 +1752,7 @@ Logging:
|
||||||
Set path to write error log. To reopen file, send USR1
|
Set path to write error log. To reopen file, send USR1
|
||||||
signal to nghttpx. stderr will be redirected to the
|
signal to nghttpx. stderr will be redirected to the
|
||||||
error log file unless --errorlog-syslog is used.
|
error log file unless --errorlog-syslog is used.
|
||||||
Default: )" << get_config()->logging.error.file.get() << R"(
|
Default: )" << get_config()->logging.error.file << R"(
|
||||||
--errorlog-syslog
|
--errorlog-syslog
|
||||||
Send error log to syslog. If this option is used,
|
Send error log to syslog. If this option is used,
|
||||||
--errorlog-file option is ignored.
|
--errorlog-file option is ignored.
|
||||||
|
|
|
@ -1622,7 +1622,7 @@ int parse_config(const char *opt, const char *optarg,
|
||||||
return parse_duration(&mod_config()->http2.timeout.stream_write, opt,
|
return parse_duration(&mod_config()->http2.timeout.stream_write, opt,
|
||||||
optarg);
|
optarg);
|
||||||
case SHRPX_OPTID_ACCESSLOG_FILE:
|
case SHRPX_OPTID_ACCESSLOG_FILE:
|
||||||
mod_config()->logging.access.file = strcopy(optarg);
|
mod_config()->logging.access.file = optarg;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
case SHRPX_OPTID_ACCESSLOG_SYSLOG:
|
case SHRPX_OPTID_ACCESSLOG_SYSLOG:
|
||||||
|
@ -1634,7 +1634,7 @@ int parse_config(const char *opt, const char *optarg,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
case SHRPX_OPTID_ERRORLOG_FILE:
|
case SHRPX_OPTID_ERRORLOG_FILE:
|
||||||
mod_config()->logging.error.file = strcopy(optarg);
|
mod_config()->logging.error.file = optarg;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
case SHRPX_OPTID_ERRORLOG_SYSLOG:
|
case SHRPX_OPTID_ERRORLOG_SYSLOG:
|
||||||
|
|
|
@ -504,12 +504,12 @@ struct Http2Config {
|
||||||
struct LoggingConfig {
|
struct LoggingConfig {
|
||||||
struct {
|
struct {
|
||||||
std::vector<LogFragment> format;
|
std::vector<LogFragment> format;
|
||||||
std::unique_ptr<char[]> file;
|
ImmutableString file;
|
||||||
// Send accesslog to syslog, ignoring accesslog_file.
|
// Send accesslog to syslog, ignoring accesslog_file.
|
||||||
bool syslog;
|
bool syslog;
|
||||||
} access;
|
} access;
|
||||||
struct {
|
struct {
|
||||||
std::unique_ptr<char[]> file;
|
ImmutableString file;
|
||||||
// Send errorlog to syslog, ignoring errorlog_file.
|
// Send errorlog to syslog, ignoring errorlog_file.
|
||||||
bool syslog;
|
bool syslog;
|
||||||
} error;
|
} error;
|
||||||
|
|
|
@ -393,23 +393,23 @@ int reopen_log_files() {
|
||||||
auto &accessconf = get_config()->logging.access;
|
auto &accessconf = get_config()->logging.access;
|
||||||
auto &errorconf = get_config()->logging.error;
|
auto &errorconf = get_config()->logging.error;
|
||||||
|
|
||||||
if (!accessconf.syslog && accessconf.file) {
|
if (!accessconf.syslog && !accessconf.file.empty()) {
|
||||||
new_accesslog_fd = util::open_log_file(accessconf.file.get());
|
new_accesslog_fd = util::open_log_file(accessconf.file.c_str());
|
||||||
|
|
||||||
if (new_accesslog_fd == -1) {
|
if (new_accesslog_fd == -1) {
|
||||||
LOG(ERROR) << "Failed to open accesslog file " << accessconf.file.get();
|
LOG(ERROR) << "Failed to open accesslog file " << accessconf.file;
|
||||||
res = -1;
|
res = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!errorconf.syslog && errorconf.file) {
|
if (!errorconf.syslog && !errorconf.file.empty()) {
|
||||||
new_errorlog_fd = util::open_log_file(errorconf.file.get());
|
new_errorlog_fd = util::open_log_file(errorconf.file.c_str());
|
||||||
|
|
||||||
if (new_errorlog_fd == -1) {
|
if (new_errorlog_fd == -1) {
|
||||||
if (lgconf->errorlog_fd != -1) {
|
if (lgconf->errorlog_fd != -1) {
|
||||||
LOG(ERROR) << "Failed to open errorlog file " << errorconf.file.get();
|
LOG(ERROR) << "Failed to open errorlog file " << errorconf.file;
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "Failed to open errorlog file " << errorconf.file.get()
|
std::cerr << "Failed to open errorlog file " << errorconf.file
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue