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);
|
||||
|
||||
auto &errorconf = loggingconf.error;
|
||||
errorconf.file = strcopy("/dev/stderr");
|
||||
errorconf.file = "/dev/stderr";
|
||||
}
|
||||
|
||||
loggingconf.syslog_facility = LOG_DAEMON;
|
||||
|
@ -1752,7 +1752,7 @@ Logging:
|
|||
Set path to write error log. To reopen file, send USR1
|
||||
signal to nghttpx. stderr will be redirected to the
|
||||
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
|
||||
Send error log to syslog. If this option is used,
|
||||
--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,
|
||||
optarg);
|
||||
case SHRPX_OPTID_ACCESSLOG_FILE:
|
||||
mod_config()->logging.access.file = strcopy(optarg);
|
||||
mod_config()->logging.access.file = optarg;
|
||||
|
||||
return 0;
|
||||
case SHRPX_OPTID_ACCESSLOG_SYSLOG:
|
||||
|
@ -1634,7 +1634,7 @@ int parse_config(const char *opt, const char *optarg,
|
|||
|
||||
return 0;
|
||||
case SHRPX_OPTID_ERRORLOG_FILE:
|
||||
mod_config()->logging.error.file = strcopy(optarg);
|
||||
mod_config()->logging.error.file = optarg;
|
||||
|
||||
return 0;
|
||||
case SHRPX_OPTID_ERRORLOG_SYSLOG:
|
||||
|
|
|
@ -504,12 +504,12 @@ struct Http2Config {
|
|||
struct LoggingConfig {
|
||||
struct {
|
||||
std::vector<LogFragment> format;
|
||||
std::unique_ptr<char[]> file;
|
||||
ImmutableString file;
|
||||
// Send accesslog to syslog, ignoring accesslog_file.
|
||||
bool syslog;
|
||||
} access;
|
||||
struct {
|
||||
std::unique_ptr<char[]> file;
|
||||
ImmutableString file;
|
||||
// Send errorlog to syslog, ignoring errorlog_file.
|
||||
bool syslog;
|
||||
} error;
|
||||
|
|
|
@ -393,23 +393,23 @@ int reopen_log_files() {
|
|||
auto &accessconf = get_config()->logging.access;
|
||||
auto &errorconf = get_config()->logging.error;
|
||||
|
||||
if (!accessconf.syslog && accessconf.file) {
|
||||
new_accesslog_fd = util::open_log_file(accessconf.file.get());
|
||||
if (!accessconf.syslog && !accessconf.file.empty()) {
|
||||
new_accesslog_fd = util::open_log_file(accessconf.file.c_str());
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (!errorconf.syslog && errorconf.file) {
|
||||
new_errorlog_fd = util::open_log_file(errorconf.file.get());
|
||||
if (!errorconf.syslog && !errorconf.file.empty()) {
|
||||
new_errorlog_fd = util::open_log_file(errorconf.file.c_str());
|
||||
|
||||
if (new_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 {
|
||||
std::cerr << "Failed to open errorlog file " << errorconf.file.get()
|
||||
std::cerr << "Failed to open errorlog file " << errorconf.file
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue