Fawkes API
Fawkes Development Version
|
22 #include <core/exception.h>
23 #include <core/threading/mutex.h>
24 #include <core/threading/mutex_locker.h>
25 #include <webview/access_log.h>
26 #include <webview/request.h>
29 #include <microhttpd.h>
47 logfile_ = fopen(filename,
"a");
49 throw Exception(errno,
"Failed to open access log %s", filename);
72 localtime_r(×ec, <ime);
75 strftime(timestr,
sizeof(timestr),
"[%d/%b/%Y:%H:%M:%S %z]", <ime);
77 "%s - %s %s \"%s %s %s\" %i %zu \"%s\" \"%s\"\n",
79 request->
user().length() == 0 ?
"-" : request->
user().c_str(),
82 request->
uri().c_str(),
87 ? 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()
WebviewAccessLog(const char *filename)
Constructor.
WebReply::Code reply_code() const
Get HTTP code of reply.
const char * method_str() const
Get method as string.
~WebviewAccessLog()
Destructor.
bool has_header(std::string key) const
Check if the named header value has been received.
const std::string & client_addr() const
Get client address as string.
const Time & time() const
Get request time.
const std::string & user() const
Get name of authenticated user (basic auth).
const char * http_version_str() const
Get HTTP version as string.
void log(const WebRequest *request)
Log a request.
const std::string & uri() const
Get URI.
std::string header(std::string &key) const
Header specific header value.
size_t reply_size() const
Get number of bytes actually sent out so far.