diff --git a/src/shrpx.cc b/src/shrpx.cc index 1d6166d1..1d60782b 100644 --- a/src/shrpx.cc +++ b/src/shrpx.cc @@ -421,19 +421,11 @@ void graceful_shutdown_signal_cb(struct ev_loop *loop, ev_signal *w, } } // namespace -namespace { -std::unique_ptr generate_time() { - return util::make_unique( - util::format_common_log(std::chrono::system_clock::now())); -} -} // namespace - namespace { void refresh_cb(struct ev_loop *loop, ev_timer *w, int revents) { auto listener_handler = static_cast(w->data); auto worker_stat = listener_handler->get_worker_stat(); - mod_config()->cached_time = generate_time(); // In multi threaded mode (get_config()->num_worker > 1), we have to // wait for event notification to workers to finish. if (get_config()->num_worker == 1 && worker_config->graceful_shutdown && @@ -698,7 +690,6 @@ void fill_default_config() { nghttp2_option_set_no_auto_window_update(mod_config()->http2_option, 1); mod_config()->tls_proto_mask = 0; - mod_config()->cached_time = generate_time(); mod_config()->no_location_rewrite = false; mod_config()->argc = 0; mod_config()->argv = nullptr; diff --git a/src/shrpx_config.h b/src/shrpx_config.h index 3ab7dcd1..bce05092 100644 --- a/src/shrpx_config.h +++ b/src/shrpx_config.h @@ -169,7 +169,6 @@ struct Config { std::vector> add_response_headers; std::vector alpn_prefs; std::vector accesslog_format; - std::shared_ptr cached_time; std::vector downstream_addrs; // binary form of http proxy host and port sockaddr_union downstream_http_proxy_addr; diff --git a/src/shrpx_log.cc b/src/shrpx_log.cc index a7b517f7..918bad50 100644 --- a/src/shrpx_log.cc +++ b/src/shrpx_log.cc @@ -122,16 +122,16 @@ Log::~Log() { char buf[4096]; auto tty = wconf->errorlog_tty; - auto cached_time = get_config()->cached_time; + auto time_now = util::format_common_log(std::chrono::system_clock::now()); if (severity_ == NOTICE) { - rv = snprintf(buf, sizeof(buf), "%s PID%d [%s%s%s] %s\n", - cached_time->c_str(), get_config()->pid, - tty ? SEVERITY_COLOR[severity_] : "", SEVERITY_STR[severity_], - tty ? "\033[0m" : "", stream_.str().c_str()); + rv = snprintf(buf, sizeof(buf), "%s PID%d [%s%s%s] %s\n", time_now.c_str(), + get_config()->pid, tty ? SEVERITY_COLOR[severity_] : "", + SEVERITY_STR[severity_], tty ? "\033[0m" : "", + stream_.str().c_str()); } else { rv = snprintf(buf, sizeof(buf), "%s PID%d [%s%s%s] %s%s:%d%s %s\n", - cached_time->c_str(), get_config()->pid, + time_now.c_str(), get_config()->pid, tty ? SEVERITY_COLOR[severity_] : "", SEVERITY_STR[severity_], tty ? "\033[0m" : "", tty ? "\033[1;30m" : "", filename_, linenum_, tty ? "\033[0m" : "", stream_.str().c_str());