22 #include <webview/access_log.h> 23 #include <webview/request.h> 25 #include <core/exception.h> 26 #include <core/threading/mutex.h> 27 #include <core/threading/mutex_locker.h> 32 #include <microhttpd.h> 51 logfile_ = fopen(filename,
"a");
53 throw Exception(errno,
"Failed to open access log %s", filename);
77 localtime_r(×ec, <ime);
80 strftime(timestr,
sizeof(timestr),
"[%d/%b/%Y:%H:%M:%S %z]", <ime);
81 fprintf(logfile_,
"%s - %s %s \"%s %s %s\" %i %zu \"%s\" \"%s\"\n",
83 request->
user().length() == 0 ?
"-" : request->
user().c_str(),
88 ? request->
header(MHD_HTTP_HEADER_REFERER).c_str() :
"",
89 request->
has_header(MHD_HTTP_HEADER_USER_AGENT)
90 ? request->
header(MHD_HTTP_HEADER_USER_AGENT).c_str() :
"");
std::string header(std::string &key) const
Header specific header value.
const std::string & client_addr() const
Get client address as string.
Fawkes library namespace.
~WebviewAccessLog()
Destructor.
const Time & time() const
Get request time.
WebviewAccessLog(const char *filename)
Constructor.
size_t reply_size() const
Get number of bytes actually sent out so far.
const std::string & uri() const
Get URI.
bool has_header(std::string key) const
Check if the named header value has been received.
Base class for exceptions in Fawkes.
WebReply::Code reply_code() const
Get HTTP code of reply.
const char * http_version_str() const
Get HTTP version as string.
Web request meta data carrier.
const char * method_str() const
Get method as string.
long get_sec() const
Get seconds.
Mutex mutual exclusion lock.
const std::string & user() const
Get name of authenticated user (basic auth).
void log(const WebRequest *request)
Log a request.