adds timestamps to error/access logs and boost date_time dependency

This commit is contained in:
Peter Thorson
2011-09-22 23:56:13 -05:00
parent dfea349ff4
commit 7afe536ca8
2 changed files with 12 additions and 5 deletions

View File

@@ -5,9 +5,9 @@ CXX ?= c++
SHARED ?= "1"
ifeq ($(SHARED), 1)
LDFLAGS := $(LDFLAGS) -lboost_system -lwebsocketpp
LDFLAGS := $(LDFLAGS) -lboost_system -lboost_date_time -lwebsocketpp
else
LDFLAGS := $(LDFLAGS) -lboost_system ../../libwebsocketpp.a
LDFLAGS := $(LDFLAGS) -lboost_system -lboost_date_time ../../libwebsocketpp.a
endif
echo_server: echo_server.o echo.o

View File

@@ -28,6 +28,7 @@
#include "websocket_server.hpp"
#include <boost/bind.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <iostream>
@@ -80,10 +81,16 @@ bool server::validate_message_size(uint64_t val) {
}
void server::error_log(std::string msg) {
std::cerr << "[Error Log] " << msg << std::endl;
std::cerr << "[Error Log] "
<< boost::posix_time::to_iso_extended_string(
boost::posix_time::second_clock::local_time())
<< " " << msg << std::endl;
}
void server::access_log(std::string msg) {
std::cout << "[Access Log] " << msg << std::endl;
std::cout << "[Access Log] "
<< boost::posix_time::to_iso_extended_string(
boost::posix_time::second_clock::local_time())
<< " " << msg << std::endl;
}
void server::start_accept() {
@@ -116,4 +123,4 @@ void server::handle_accept(session_ptr session,
}
this->start_accept();
}
}