libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
LoggerFile.h
1/****************************************************************************
2 * Platform Abstraction Layer
3 * Daryl Borth 2026
4 * LoggerFile.h
5 *
6 * Generic - works unmodified on GC, Wii, and Wii U. All three platforms
7 * expose their mounted storage through a standard devoptab path (eg.
8 * "sd:/debug.log" on GC/Wii, "/vol/external01/debug.log" on Wii U, or
9 * whatever a caller passes in LogConfig::filePath), so a single stdio-
10 * based implementation covers every platform. There is nothing
11 * platform-specific left to put behind an interface here.
12 *
13 * Register this only after FileSystemDriver::init() (and, if the target
14 * device is removable, a successful mountStorageDevice() call) has run -
15 * Logger::init()/reconfigure() can be called again later once storage
16 * becomes available if it wasn't at platform startup.
17 ***************************************************************************/
18#pragma once
19
20#include <cstdio>
21#include "Logger.h"
22
25class LoggerFile : public LoggingDriver
26{
27 public:
28 LoggerFile() = default;
29 ~LoggerFile() override { shutdown(); }
30
31 bool init(const LogConfig & config) override;
32 void shutdown() override;
33 void write(LogLevel level, const char * line, size_t len) override;
34 const char * name() const override { return "File"; }
35
36 private:
37 FILE * file = nullptr;
39 uint32_t flushEveryNWrites = 16;
40 uint32_t writesSinceFlush = 0;
41};
void shutdown() override
Releases whatever init() acquired.
const char * name() const override
Short identifier for diagnostics (eg. "UDP", "File").
Definition LoggerFile.h:34
void write(LogLevel level, const char *line, size_t len) override
Writes one already-formatted, newline-terminated line.
bool init(const LogConfig &config) override
Opens whatever handle/socket/file this backend needs, using only fields from config (nothing hardcode...
Definition LoggerFile.cpp:8
Abstract backend a Logger fans a formatted line out to.
Definition Logger.h:153
LogLevel
Severity of a single log call.
Definition Logger.h:45
LogFlushPolicy
How LoggerFile flushes writes to storage.
Definition Logger.h:88
@ Immediate
fflush() after every write - safest against a crash/power loss, slowest
Definition Logger.h:89
Full runtime configuration for the Logger.
Definition Logger.h:101