From 1635f7351db90ba366bf7cb1296ef1bf955dad07 Mon Sep 17 00:00:00 2001 From: Mathias Gug Date: Thu, 19 May 2016 17:30:17 -0700 Subject: [PATCH 1/3] Support environment variable to disable http requests logging. --- docs/http.md | 6 ++++++ src/server/request_handler.cpp | 24 +++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/docs/http.md b/docs/http.md index 4c68bd640..338ab6485 100644 --- a/docs/http.md +++ b/docs/http.md @@ -7,6 +7,12 @@ send the USR1 signal to its parent when it will be running and waiting for requests. This could be used to upgrade osrm-routed to a new binary on the fly without any service downtime - no incoming requests will be lost. +### DISABLE_ACCESS_LOGGING + +If the DISABLE_ACCESS_LOGGING environment variable is set osrm-routed will +**not** log any http requests to standard output. This can be useful in high +traffic setup. + ## HTTP API `osrm-routed` supports only `GET` requests of the form. If you your response size diff --git a/src/server/request_handler.cpp b/src/server/request_handler.cpp index cfe74f257..b710a22c8 100644 --- a/src/server/request_handler.cpp +++ b/src/server/request_handler.cpp @@ -64,17 +64,19 @@ void RequestHandler::HandleRequest(const http::request ¤t_request, http::r ltime = time(nullptr); time_stamp = localtime(<ime); - // log timestamp - util::SimpleLogger().Write() - << (time_stamp->tm_mday < 10 ? "0" : "") << time_stamp->tm_mday << "-" - << (time_stamp->tm_mon + 1 < 10 ? "0" : "") << (time_stamp->tm_mon + 1) << "-" - << 1900 + time_stamp->tm_year << " " << (time_stamp->tm_hour < 10 ? "0" : "") - << time_stamp->tm_hour << ":" << (time_stamp->tm_min < 10 ? "0" : "") - << time_stamp->tm_min << ":" << (time_stamp->tm_sec < 10 ? "0" : "") - << time_stamp->tm_sec << " " << current_request.endpoint.to_string() << " " - << current_request.referrer << (0 == current_request.referrer.length() ? "- " : " ") - << current_request.agent << (0 == current_request.agent.length() ? "- " : " ") - << request_string; + if(!std::getenv("DISABLE_ACCESS_LOGGING")) { + // log timestamp + util::SimpleLogger().Write() + << (time_stamp->tm_mday < 10 ? "0" : "") << time_stamp->tm_mday << "-" + << (time_stamp->tm_mon + 1 < 10 ? "0" : "") << (time_stamp->tm_mon + 1) << "-" + << 1900 + time_stamp->tm_year << " " << (time_stamp->tm_hour < 10 ? "0" : "") + << time_stamp->tm_hour << ":" << (time_stamp->tm_min < 10 ? "0" : "") + << time_stamp->tm_min << ":" << (time_stamp->tm_sec < 10 ? "0" : "") + << time_stamp->tm_sec << " " << current_request.endpoint.to_string() << " " + << current_request.referrer << (0 == current_request.referrer.length() ? "- " : " ") + << current_request.agent << (0 == current_request.agent.length() ? "- " : " ") + << request_string; + } auto api_iterator = request_string.begin(); auto maybe_parsed_url = api::parseURL(api_iterator, request_string.end()); From 3b1b12069f9f58147e1996b49f5f77061e9af23d Mon Sep 17 00:00:00 2001 From: Mathias Gug Date: Thu, 19 May 2016 17:31:50 -0700 Subject: [PATCH 2/3] Add changelog entry. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index acc7c8efa..8bb0ab056 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ - Open sockets with SO_REUSEPORT to allow multiple osrm-routed processes serving requests from the same port. - Add SIGNAL_PARENT_WHEN_READY environment variable to enable osrm-routed signal its parent with USR1 when it's running and waiting for requests. - BREAKING: Intersection Classification adds a new file to the mix (osrm.icd). This breaks the fileformat for older versions. + - Disable http access logging via DISABLE_ACCESS_LOGGING environment + variable. - Guidance: - improved detection of turning streets, not reporting new-name in wrong situations From e5b713841a717339486f0d021db1f14497665dd4 Mon Sep 17 00:00:00 2001 From: Mathias Gug Date: Fri, 20 May 2016 08:39:00 -0700 Subject: [PATCH 3/3] Fix style. --- src/server/request_handler.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/server/request_handler.cpp b/src/server/request_handler.cpp index b710a22c8..026efd999 100644 --- a/src/server/request_handler.cpp +++ b/src/server/request_handler.cpp @@ -64,7 +64,8 @@ void RequestHandler::HandleRequest(const http::request ¤t_request, http::r ltime = time(nullptr); time_stamp = localtime(<ime); - if(!std::getenv("DISABLE_ACCESS_LOGGING")) { + if (!std::getenv("DISABLE_ACCESS_LOGGING")) + { // log timestamp util::SimpleLogger().Write() << (time_stamp->tm_mday < 10 ? "0" : "") << time_stamp->tm_mday << "-"