aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp/servers/httptracer.cpp
blob: 483307fb1b297b46408abe47e65906906247f0d3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright Epic Games, Inc. All Rights Reserved.

#include "httptracer.h"

#include <zencore/fmtutils.h>
#include <zencore/logging.h>
#include <zencore/session.h>

namespace zen {

void
HttpServerTracer::Initialize(std::filesystem::path DataDir)
{
	m_DataDir	 = DataDir;
	m_PayloadDir = DataDir / "debug" / GetSessionIdString();

	ZEN_INFO("any debug payloads will be written to '{}'", m_PayloadDir);
}

void
HttpServerTracer::WriteDebugPayload(std::string_view Filename, const std::span<const IoBuffer> Payload)
{
	uint64_t					 PayloadSize = 0;
	std::vector<const IoBuffer*> Buffers;
	for (auto& Io : Payload)
	{
		Buffers.push_back(&Io);
		PayloadSize += Io.GetSize();
	}

	if (PayloadSize)
	{
		WriteFile(m_PayloadDir / Filename, Buffers.data(), Buffers.size());
	}
}

}  // namespace zen