1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-11-09 10:00:57 +03:00
Files
mvfst/quic/logging/FileQLogger.cpp
Bonnie Xu 685ff77e22 s/size_t/uint64_t/g in qlogger
Reviewed By: vchynarov

Differential Revision: D15983098

fbshipit-source-id: 34f9c4f7c6256add6eb51888d55d7e8c953e92a0
2019-06-25 21:16:04 -07:00

53 lines
1.4 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
#include <quic/logging/FileQLogger.h>
#include <folly/json.h>
#include <quic/logging/QLogger.h>
namespace quic {
void FileQLogger::add(
const RegularQuicPacket& regularPacket,
uint64_t packetSize) {
logs.push_back(createPacketEvent(regularPacket, packetSize));
}
void FileQLogger::add(
const RegularQuicWritePacket& writePacket,
uint64_t packetSize) {
logs.push_back(createPacketEvent(writePacket, packetSize));
}
void FileQLogger::add(
const VersionNegotiationPacket& versionPacket,
uint64_t packetSize,
bool isPacketRecvd) {
logs.push_back(createPacketEvent(versionPacket, packetSize, isPacketRecvd));
}
folly::dynamic FileQLogger::toDynamic() const {
folly::dynamic d = folly::dynamic::object;
d["traces"] = folly::dynamic::array();
folly::dynamic dTrace = folly::dynamic::object;
// convert stored logs into folly::Dynamic event array
auto events = folly::dynamic::array();
for (auto& event : logs) {
events.push_back(event->toDynamic());
}
dTrace["events"] = events;
dTrace["event_fields"] =
folly::dynamic::array("CATEGORY", "EVENT_TYPE", "TRIGGER", "DATA");
d["traces"].push_back(dTrace);
return d;
}
} // namespace quic