use C++11's put time to put the timestamp
This commit is contained in:
parent
700747801c
commit
7b9b2fd23a
@ -37,7 +37,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <osrm/Reply.h>
|
#include <osrm/Reply.h>
|
||||||
#include <osrm/RouteParameters.h>
|
#include <osrm/RouteParameters.h>
|
||||||
|
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
RequestHandler::RequestHandler() : routing_machine(NULL) { }
|
RequestHandler::RequestHandler() : routing_machine(NULL) { }
|
||||||
@ -48,19 +51,10 @@ void RequestHandler::handle_request(const http::Request& req, http::Reply& rep){
|
|||||||
std::string request;
|
std::string request;
|
||||||
URIDecode(req.uri, request);
|
URIDecode(req.uri, request);
|
||||||
|
|
||||||
time_t ltime;
|
std::time_t t = std::time(nullptr);
|
||||||
struct tm *Tm;
|
|
||||||
|
|
||||||
ltime=time(NULL);
|
SimpleLogger().Write() << std::put_time(std::localtime(&t), "%m-%d-%Y %H:%M:%S") <<
|
||||||
Tm=localtime(<ime);
|
" " << req.endpoint.to_string() << " " <<
|
||||||
|
|
||||||
SimpleLogger().Write() <<
|
|
||||||
(Tm->tm_mday < 10 ? "0" : "" ) << Tm->tm_mday << "-" <<
|
|
||||||
(Tm->tm_mon+1 < 10 ? "0" : "" ) << (Tm->tm_mon+1) << "-" <<
|
|
||||||
1900+Tm->tm_year << " " << (Tm->tm_hour < 10 ? "0" : "" ) <<
|
|
||||||
Tm->tm_hour << ":" << (Tm->tm_min < 10 ? "0" : "" ) <<
|
|
||||||
Tm->tm_min << ":" << (Tm->tm_sec < 10 ? "0" : "" ) <<
|
|
||||||
Tm->tm_sec << " " << req.endpoint.to_string() << " " <<
|
|
||||||
req.referrer << ( 0 == req.referrer.length() ? "- " :" ") <<
|
req.referrer << ( 0 == req.referrer.length() ? "- " :" ") <<
|
||||||
req.agent << ( 0 == req.agent.length() ? "- " :" ") << request;
|
req.agent << ( 0 == req.agent.length() ? "- " :" ") << request;
|
||||||
|
|
||||||
|
@ -28,8 +28,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#ifndef REQUEST_HANDLER_H
|
#ifndef REQUEST_HANDLER_H
|
||||||
#define REQUEST_HANDLER_H
|
#define REQUEST_HANDLER_H
|
||||||
|
|
||||||
#include <boost/noncopyable.hpp>
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
template <typename Iterator, class HandlerT>
|
template <typename Iterator, class HandlerT>
|
||||||
@ -42,12 +40,14 @@ namespace http {
|
|||||||
struct Request;
|
struct Request;
|
||||||
}
|
}
|
||||||
|
|
||||||
class RequestHandler : private boost::noncopyable {
|
class RequestHandler
|
||||||
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef APIGrammar<std::string::iterator, RouteParameters> APIGrammarParser;
|
typedef APIGrammar<std::string::iterator, RouteParameters> APIGrammarParser;
|
||||||
|
|
||||||
RequestHandler();
|
RequestHandler();
|
||||||
|
RequestHandler(const RequestHandler &) = delete;
|
||||||
|
|
||||||
void handle_request(const http::Request& req, http::Reply& rep);
|
void handle_request(const http::Request& req, http::Reply& rep);
|
||||||
void RegisterRoutingMachine(OSRM * osrm);
|
void RegisterRoutingMachine(OSRM * osrm);
|
||||||
|
Loading…
Reference in New Issue
Block a user