libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
OgcLoggerUdp.h
1/****************************************************************************
2 * Platform Abstraction Layer
3 * Daryl Borth 2026
4 * OgcLoggerUdp.h
5 *
6 * Non-blocking UDP log streaming for Wii (HW_RVL)
7 ***************************************************************************/
8#pragma once
9
10#include "../Logger.h"
11
12#ifdef HW_RVL
13#include <network.h>
14#include "wii/WiiNetwork.h"
15#endif
16
20{
21 public:
22#ifdef HW_RVL
23 OgcLoggerUdp() { self = this; }
24 ~OgcLoggerUdp() override { if (self == this) self = nullptr; }
25#endif
26
27 bool init(const LogConfig & config) override;
28 void shutdown() override;
29 void write(LogLevel level, const char * line, size_t len) override;
30 const char * name() const override { return "UDP"; }
31
32 private:
33#ifdef HW_RVL
35 bool activateSocket();
36
38 static void OnNetworkUp();
39
40 static OgcLoggerUdp * self; // exactly one instance is ever registered (see WiiPlatform.cpp) - used so the static callback above can reach it
41
42 s32 sock = -1;
43 struct sockaddr_in serverAddr {};
44 LogConfig pendingConfig {}; // captured in init(), used by activateSocket() whenever it actually runs
45#endif
46};
Abstract backend a Logger fans a formatted line out to.
Definition Logger.h:153
Non-blocking UDP log backend.
void shutdown() override
Releases whatever init() acquired.
const char * name() const override
Short identifier for diagnostics (eg. "UDP", "File").
bool init(const LogConfig &config) override
Opens whatever handle/socket/file this backend needs, using only fields from config (nothing hardcode...
void write(LogLevel level, const char *line, size_t len) override
Writes one already-formatted, newline-terminated line.
LogLevel
Severity of a single log call.
Definition Logger.h:45
Full runtime configuration for the Logger.
Definition Logger.h:101