[Feat] (MG_Remote): P9 W3 - the server's log forward carries each line's level and never blocks a logging thread (<=WARN dropped and counted, >=ERROR lossless and paced, FATAL a bounded flush), fault injection F2, and the producerless OnLog callback deleted (9 -> 8)

This commit is contained in:
2026-09-29 02:42:20 -04:00
parent 362daafeed
commit 6bcfb1fba1
19 changed files with 1775 additions and 52 deletions
+15 -2
View File
@@ -1,5 +1,6 @@
#include "ControlInbox.h"
#include "Doorbell.h"
#include "LogForward.h"
#include "../Protocol/SurfaceOpCodec.h"
#include <MG_Util/Debug/Log.h>
#include <chrono>
@@ -18,11 +19,21 @@ namespace MobileGL::MG_Remote::Transport {
if (m_reader.joinable()) m_reader.join();
}
void ControlInbox::PauseReadingForTest(bool paused) {
std::lock_guard<std::mutex> lock(m_mutex);
m_pausedForTest = paused;
m_cv.notify_all();
}
void ControlInbox::Read() {
for (;;) {
{
std::lock_guard<std::mutex> lock(m_mutex);
std::unique_lock<std::mutex> lock(m_mutex);
if (m_stop) return;
if (m_pausedForTest) {
m_cv.wait(lock, [&] { return m_stop || !m_pausedForTest; });
continue;
}
}
std::uint64_t size = 0;
auto result = m_transport.ReceiveFrame({nullptr, 0}, &size, 100);
@@ -38,7 +49,9 @@ namespace MobileGL::MG_Remote::Transport {
else {
const auto* envelope = ::MobileGL::Wire::GetCtrlEnvelope(frame.data());
if (const auto* log = envelope->msg_as_LogLine()) {
if (log->text()) MG_Util::Debug::WritePeerLog(log->text()->c_str());
// P9 W3: filed with the severity the server sent (LogForward.h's mapping).
if (log->text())
MG_Util::Debug::WritePeerLog(LogLevelFromWire(log->level()), log->text()->c_str());
continue;
}
}