Add Visione backend foundation
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#include "RequestLogger.h"
|
||||
|
||||
#include <drogon/drogon.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
const auto registeredClassName = RequestLogger::classTypeName();
|
||||
}
|
||||
|
||||
void RequestLogger::initAndStart(const Json::Value &config)
|
||||
{
|
||||
includeQuery_ = config.get("include_query", true).asBool();
|
||||
LOG_INFO << "RequestLogger plugin initialized";
|
||||
|
||||
drogon::app().registerPreSendingAdvice(
|
||||
[this](const drogon::HttpRequestPtr &req,
|
||||
const drogon::HttpResponsePtr &resp) {
|
||||
auto url = req->path();
|
||||
if (includeQuery_ && !req->query().empty())
|
||||
{
|
||||
url += "?";
|
||||
url += req->query();
|
||||
}
|
||||
|
||||
LOG_INFO << req->methodString() << " " << url << " -> "
|
||||
<< static_cast<int>(resp->statusCode()) << " from "
|
||||
<< req->getPeerAddr().toIpPort();
|
||||
});
|
||||
}
|
||||
|
||||
void RequestLogger::shutdown()
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user