mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-08 20:00:17 +02:00
Adds a new OutputSocket config option that when set will force all logs to go through a socket. This allows us to avoid polluting the guest application's output through a socket instead of a file. Alleviating the issue of a file output overwriting when multiple applications are ran.
48 lines
1.3 KiB
C++
48 lines
1.3 KiB
C++
#pragma once
|
|
#include <FEXCore/Utils/Event.h>
|
|
#include <FEXCore/Utils/LogManager.h>
|
|
|
|
namespace FEX::SocketLogging {
|
|
// Client side
|
|
namespace Client {
|
|
void MsgHandler(LogMan::DebugLevels Level, char const *Message);
|
|
void AssertHandler(char const *Message);
|
|
|
|
bool ConnectToClient(const std::string &Remote);
|
|
}
|
|
|
|
// Server side
|
|
namespace Server {
|
|
class ServerListener {
|
|
public:
|
|
using MsgHandlerType = std::function<void(int FD, uint64_t Timestamp, uint32_t PID, uint32_t TID, uint32_t Level, const char* Msg)>;
|
|
using FDClosedHandlerType = std::function<void(int FD)>;
|
|
|
|
void SetMsgHandler(MsgHandlerType Handler) {
|
|
MsgHandler = std::move(Handler);
|
|
}
|
|
|
|
void SetFDClosedHandler(FDClosedHandlerType Handler) {
|
|
ClosedHandler = std::move(Handler);
|
|
}
|
|
|
|
void WaitForShutdown() {
|
|
ShutdownEvent.Wait();
|
|
}
|
|
|
|
protected:
|
|
|
|
static void DefaultMsgHandler(int, uint64_t, uint32_t, uint32_t, uint32_t, const char*) {
|
|
}
|
|
|
|
static void DefaultFDClosedHandler(int) {
|
|
}
|
|
|
|
MsgHandlerType MsgHandler {DefaultMsgHandler};
|
|
FDClosedHandlerType ClosedHandler {DefaultFDClosedHandler};
|
|
Event ShutdownEvent{};
|
|
};
|
|
std::unique_ptr<ServerListener> StartListening(std::string_view Socket);
|
|
}
|
|
}
|