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
This commit is contained in:
Jesse Talavera-Greenberg
2023-03-23 13:04:38 -04:00
committed by GitHub
parent 19280cff2d
commit 79dfb8dc8f
50 changed files with 521 additions and 378 deletions

View File

@ -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);