ifcviewer: replace qInfo/qWarning with a Qt-free logger seam

Add Log.h (in IfcViewerCore) — a tiny stream-style logger that backs
fprintf(stderr,...), with overloads for the common primitives + char
strings. Mimics qInfo()/qWarning()'s syntax surface enough that
mass-replacing qInfo()→Log::info() and qWarning()→Log::warn() keeps
existing call sites parsing unchanged; .noquote() / .nospace() exist
as compat no-ops so chained qInfo().noquote()<<x<<y patterns survive.

QString streaming is a transitional concern — the QString → std::string
sweep (#80) hasn't landed yet, so ViewportWindow and friends still
construct QStrings for log payloads. LogQt.h (in IfcViewer, not Core)
adds the QString / QStringView operator<< overloads so those streaming
sites work without source changes during the in-flight Qt removal.
When #80 retires QString, LogQt.h drops out.

ViewportWindow.cpp: 132 qInfo/qWarning callsites converted. The two
printf-style qInfo("fmt %s", ...) callsites get fprintf with explicit
[info]/[warn] prefixes to keep the output discoverable.

Also de-Qt'd:
  AreaMeasurement.cpp  — 1 qInfo("fmt", …) → fprintf
  SceneLoader.cpp      — 4 qDebug + 1 qWarning printf-style → fprintf
  GeometryStreamer.cpp — 2 qDebug printf-style → fprintf
  ifcviewer-minimal/main.cpp — 2 qWarning << → Log::warn

Drops <QDebug> from each. Closes #82.

Builds: desktop / bonsai / web all green. Tests 100/100 pass.
This commit is contained in:
Dion Moult
2026-06-05 08:58:45 +10:00
parent 77cf535b45
commit 6dd3558db9
8 changed files with 348 additions and 161 deletions
+6 -3
View File
@@ -23,6 +23,8 @@
#include <QWidget>
#include <QVBoxLayout>
#include "Log.h"
#include "LogQt.h"
#include "ViewportWindow.h"
// Stage-1 driver: opens a single window with the wgpu viewport embedded,
@@ -85,11 +87,12 @@ int main(int argc, char* argv[]) {
if (ok) {
viewport->setCamera(v[0], v[1], v[2], v[3], v[4], v[5]);
} else {
qWarning() << "--camera: failed to parse" << parser.value("camera");
Log::warn() << "--camera: failed to parse "
<< parser.value("camera");
}
} else {
qWarning() << "--camera: expected 6 comma-separated floats, got"
<< parts.size();
Log::warn() << "--camera: expected 6 comma-separated floats, got "
<< parts.size();
}
}