X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=server.cpp;h=24aa84e357a129db9fcea63b43cec986b114407a;hp=46bda5b21935ff36d0aca3be838885c5e4b7b7ba;hb=9abaf929b9da3158e9b7f799775ac56e88d28740;hpb=4856c49f1b63753ce86ad759ee649a1117628a8e diff --git a/server.cpp b/server.cpp index 46bda5b..24aa84e 100644 --- a/server.cpp +++ b/server.cpp @@ -14,6 +14,7 @@ #include #include +#include "accesslog.h" #include "log.h" #include "markpool.h" #include "mutexlock.h" @@ -24,6 +25,8 @@ using namespace std; +extern AccessLogThread *access_log; + Server::Server() { pthread_mutex_init(&mutex, NULL); @@ -268,7 +271,7 @@ read_request_again: switch (status) { case RP_OUT_OF_SPACE: - log(WARNING, "fd %d sent overlong request!", client->sock); + log(WARNING, "[%s] Client sent overlong request!", client->remote_addr.c_str()); close_client(client); return; case RP_NOT_FINISHED_YET: @@ -276,7 +279,7 @@ read_request_again: // See if there's more data for us. goto read_request_again; case RP_EXTRA_DATA: - log(WARNING, "fd %d had junk data after request!", client->sock); + log(WARNING, "[%s] Junk data after request!", client->remote_addr.c_str()); close_client(client); return; case RP_FINISHED: @@ -357,8 +360,8 @@ sending_data_again: return; } if (bytes_to_send > stream->backlog_size) { - log(WARNING, "fd %d lost %lld bytes, maybe too slow connection", - client->sock, + log(WARNING, "[%s] Client lost %lld bytes, maybe too slow connection", + client->remote_addr.c_str(), (long long int)(bytes_to_send - stream->backlog_size)); client->stream_pos = stream->bytes_received - stream->backlog_size; client->bytes_lost += bytes_to_send - stream->backlog_size; @@ -504,6 +507,9 @@ void Server::close_client(Client *client) } } + // Log to access_log. + access_log->write(client->get_stats()); + // Bye-bye! int ret; do {