aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/sessions/httpsessions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenserver/sessions/httpsessions.cpp')
-rw-r--r--src/zenserver/sessions/httpsessions.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/zenserver/sessions/httpsessions.cpp b/src/zenserver/sessions/httpsessions.cpp
index fdf2e1f21..2276cb81a 100644
--- a/src/zenserver/sessions/httpsessions.cpp
+++ b/src/zenserver/sessions/httpsessions.cpp
@@ -377,7 +377,7 @@ HttpSessionsService::SessionLogRequest(HttpRouterRequest& Req)
if (ServerRequest.RequestContentType() == HttpContentType::kText)
{
- // Raw text — split by newlines, one entry per line
+ // Raw text - split by newlines, one entry per line
IoBuffer Payload = ServerRequest.ReadPayload();
std::string_view Text(reinterpret_cast<const char*>(Payload.GetData()), Payload.GetSize());
const DateTime Now = DateTime::Now();
@@ -417,13 +417,26 @@ HttpSessionsService::SessionLogRequest(HttpRouterRequest& Req)
const DateTime Now = DateTime::Now();
auto AppendFromObject = [&](CbObjectView Obj) {
- std::string Level(Obj["level"sv].AsString());
+ CbFieldView LevelField = Obj["level"sv];
+ std::string_view Level;
+ if (LevelField.IsString())
+ {
+ Level = LevelField.AsString();
+ }
+ else if (LevelField.IsInteger())
+ {
+ int32_t LevelInt = LevelField.AsInt32();
+ if (LevelInt >= 0 && LevelInt < logging::LogLevelCount)
+ {
+ Level = logging::ToString(static_cast<logging::LogLevel>(LevelInt));
+ }
+ }
std::string Message(Obj["message"sv].AsString());
CbObjectView DataView = Obj["data"sv].AsObjectView();
Session->AppendLog(SessionsService::LogEntry{
.Timestamp = Now,
- .Level = std::move(Level),
+ .Level = std::string(Level),
.Message = std::move(Message),
.Data = CbObject::Clone(DataView),
});
@@ -512,8 +525,9 @@ HttpSessionsService::SessionLogRequest(HttpRouterRequest& Req)
//
void
-HttpSessionsService::OnWebSocketOpen(Ref<WebSocketConnection> Connection)
+HttpSessionsService::OnWebSocketOpen(Ref<WebSocketConnection> Connection, std::string_view RelativeUri)
{
+ ZEN_UNUSED(RelativeUri);
ZEN_INFO("Sessions WebSocket client connected");
m_WsConnectionsLock.WithExclusiveLock([&] { m_WsConnections.push_back(std::move(Connection)); });
}