diff options
author | Jesse Talavera-Greenberg <jesse@jesse.tg> | 2023-03-23 13:04:38 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-23 18:04:38 +0100 |
commit | 79dfb8dc8f356834f0b6cf7baf73f77552b08923 (patch) | |
tree | 9a2a139617b8e178edd153ac68d56f2d0e48e3ed /src/frontend/qt_sdl/Platform.cpp | |
parent | 19280cff2d3d618f032d0e6ef4b1d4414fa02f58 (diff) |
Introduce `Platform::Log` (#1640)
* Add Platform::Log and Platform::LogLevel
* Replace most printf calls with Platform::Log calls
* Move a brace down
* Move some log entries to one Log call
- Some implementations of Log may assume a full line
* Log the MAC address as LogLevel::Info
Diffstat (limited to 'src/frontend/qt_sdl/Platform.cpp')
-rw-r--r-- | src/frontend/qt_sdl/Platform.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/frontend/qt_sdl/Platform.cpp b/src/frontend/qt_sdl/Platform.cpp index f9eaf42..6b48335 100644 --- a/src/frontend/qt_sdl/Platform.cpp +++ b/src/frontend/qt_sdl/Platform.cpp @@ -60,10 +60,10 @@ void IPCInit() if (!IPCBuffer->attach()) { - printf("IPC sharedmem doesn't exist. creating\n"); + Log(LogLevel::Info, "IPC sharedmem doesn't exist. creating\n"); if (!IPCBuffer->create(1024)) { - printf("IPC sharedmem create failed :(\n"); + Log(LogLevel::Error, "IPC sharedmem create failed :(\n"); delete IPCBuffer; IPCBuffer = nullptr; return; @@ -88,7 +88,7 @@ void IPCInit() } IPCBuffer->unlock(); - printf("IPC: instance ID %d\n", IPCInstanceID); + Log(LogLevel::Info, "IPC: instance ID %d\n", IPCInstanceID); } void IPCDeInit() @@ -349,6 +349,17 @@ FILE* OpenLocalFile(std::string path, std::string mode) return OpenFile(fullpath.toStdString(), mode, mode[0] != 'w'); } +void Log(LogLevel level, const char* fmt, ...) +{ + if (fmt == nullptr) + return; + + va_list args; + va_start(args, fmt); + vprintf(fmt, args); + va_end(args); +} + Thread* Thread_Create(std::function<void()> func) { QThread* t = QThread::create(func); |