Logging improvements

This commit is contained in:
RipleyTom 2024-04-25 21:47:53 +02:00 committed by Megamouse
parent ad4216a3fc
commit 6fc7fa3b13
2 changed files with 31 additions and 14 deletions

View File

@ -1496,7 +1496,7 @@ error_code cellGemGetInertialState(u32 gem_num, u32 state_flag, u64 timestamp, v
error_code cellGemGetInfo(vm::ptr<CellGemInfo> info)
{
cellGem.warning("cellGemGetInfo(info=*0x%x)", info);
cellGem.trace("cellGemGetInfo(info=*0x%x)", info);
auto& gem = g_fxo->get<gem_config>();

View File

@ -4,6 +4,23 @@
LOG_CHANNEL(sys_net);
template <typename T>
struct socket_raw_logging
{
socket_raw_logging() = default;
socket_raw_logging(const socket_raw_logging&) = delete;
socket_raw_logging& operator=(const socket_raw_logging&) = delete;
atomic_t<bool> logged = false;
};
#define LOG_ONCE(raw_var, message) \
if (!g_fxo->get<socket_raw_logging<class raw_var>>().logged.exchange(true)) \
{ \
sys_net.todo(message); \
}
lv2_socket_raw::lv2_socket_raw(lv2_socket_family family, lv2_socket_type type, lv2_ip_protocol protocol)
: lv2_socket(family, type, protocol)
{
@ -39,37 +56,37 @@ s32 lv2_socket_raw::connect_followup()
std::pair<s32, sys_net_sockaddr> lv2_socket_raw::getpeername()
{
sys_net.todo("[RAW] getpeername() called on a RAW socket");
LOG_ONCE(raw_getpeername, "[RAW] getpeername() called on a RAW socket");
return {};
}
s32 lv2_socket_raw::listen([[maybe_unused]] s32 backlog)
{
sys_net.todo("[RAW] listen() called on a RAW socket");
LOG_ONCE(raw_listen, "[RAW] listen() called on a RAW socket");
return {};
}
s32 lv2_socket_raw::bind([[maybe_unused]] const sys_net_sockaddr& addr)
{
sys_net.todo("lv2_socket_raw::bind");
LOG_ONCE(raw_bind, "lv2_socket_raw::bind");
return {};
}
std::pair<s32, sys_net_sockaddr> lv2_socket_raw::getsockname()
{
sys_net.todo("lv2_socket_raw::getsockname");
LOG_ONCE(raw_getsockname, "lv2_socket_raw::getsockname");
return {};
}
std::tuple<s32, lv2_socket::sockopt_data, u32> lv2_socket_raw::getsockopt([[maybe_unused]] s32 level, [[maybe_unused]] s32 optname, [[maybe_unused]] u32 len)
{
sys_net.todo("lv2_socket_raw::getsockopt");
LOG_ONCE(raw_getsockopt, "lv2_socket_raw::getsockopt");
return {};
}
s32 lv2_socket_raw::setsockopt(s32 level, s32 optname, const std::vector<u8>& optval)
{
sys_net.todo("lv2_socket_raw::setsockopt");
LOG_ONCE(raw_setsockopt, "lv2_socket_raw::setsockopt");
// TODO
int native_int = *reinterpret_cast<const be_t<s32>*>(optval.data());
@ -84,7 +101,7 @@ s32 lv2_socket_raw::setsockopt(s32 level, s32 optname, const std::vector<u8>& op
std::optional<std::tuple<s32, std::vector<u8>, sys_net_sockaddr>> lv2_socket_raw::recvfrom(s32 flags, [[maybe_unused]] u32 len, [[maybe_unused]] bool is_lock)
{
sys_net.todo("lv2_socket_raw::recvfrom");
LOG_ONCE(raw_recvfrom, "lv2_socket_raw::recvfrom");
if (so_nbio || (flags & SYS_NET_MSG_DONTWAIT))
{
@ -96,35 +113,35 @@ std::optional<std::tuple<s32, std::vector<u8>, sys_net_sockaddr>> lv2_socket_raw
std::optional<s32> lv2_socket_raw::sendto([[maybe_unused]] s32 flags, [[maybe_unused]] const std::vector<u8>& buf, [[maybe_unused]] std::optional<sys_net_sockaddr> opt_sn_addr, [[maybe_unused]] bool is_lock)
{
sys_net.todo("lv2_socket_raw::sendto");
LOG_ONCE(raw_sendto, "lv2_socket_raw::sendto");
return ::size32(buf);
}
std::optional<s32> lv2_socket_raw::sendmsg([[maybe_unused]] s32 flags, [[maybe_unused]] const sys_net_msghdr& msg, [[maybe_unused]] bool is_lock)
{
sys_net.todo("lv2_socket_raw::sendmsg");
LOG_ONCE(raw_sendmsg, "lv2_socket_raw::sendmsg");
return {};
}
void lv2_socket_raw::close()
{
sys_net.todo("lv2_socket_raw::close");
LOG_ONCE(raw_close, "lv2_socket_raw::close");
}
s32 lv2_socket_raw::shutdown([[maybe_unused]] s32 how)
{
sys_net.todo("lv2_socket_raw::shutdown");
LOG_ONCE(raw_shutdown, "lv2_socket_raw::shutdown");
return {};
}
s32 lv2_socket_raw::poll([[maybe_unused]] sys_net_pollfd& sn_pfd, [[maybe_unused]] pollfd& native_pfd)
{
sys_net.todo("lv2_socket_raw::poll");
LOG_ONCE(raw_poll, "lv2_socket_raw::poll");
return {};
}
std::tuple<bool, bool, bool> lv2_socket_raw::select([[maybe_unused]] bs_t<lv2_socket::poll_t> selected, [[maybe_unused]] pollfd& native_pfd)
{
sys_net.todo("lv2_socket_raw::select");
LOG_ONCE(raw_select, "lv2_socket_raw::select");
return {};
}