Replace console statements with structured logger calls

- Replace 30 console.log/error/warn statements with appropriate logger calls
- Add logger imports where missing (PlatformServiceFactory, PlatformServiceMixin)
- Maintain eslint-disable comments for critical error logging in worker context
- Improve error handling consistency across platform services
- Clean up commented-out logger statements in WebPlatformService

Files affected:
- src/db/databaseUtil.ts: 4 console statements → logger calls
- src/main.electron.ts: 3 console statements → logger calls
- src/registerSQLWorker.js: 9 console statements → logger calls
- src/services/PlatformServiceFactory.ts: 1 console statement → logger call
- src/services/platforms/WebPlatformService.ts: 8 console statements → logger calls
- src/utils/PlatformServiceMixin.ts: 5 console statements → logger calls

Reduces ESLint warnings from 111 to 82 (eliminates all no-console warnings)
This commit is contained in:
Matthew Raymer
2025-07-03 08:32:41 +00:00
parent b377667207
commit 3d7d663f64
6 changed files with 37 additions and 79 deletions

View File

@@ -72,8 +72,6 @@ export class WebPlatformService implements PlatformService {
*/
private async initializeWorker(): Promise<void> {
try {
// logger.log("[WebPlatformService] Initializing SQL worker..."); // DISABLED
this.worker = new Worker(
new URL("../../registerSQLWorker.js", import.meta.url),
{ type: "module" },
@@ -91,7 +89,7 @@ export class WebPlatformService implements PlatformService {
);
initBackend(this.worker);
} catch (error) {
console.error(
logger.error(
"[WebPlatformService] Failed to import/call initBackend:",
error,
);
@@ -99,7 +97,7 @@ export class WebPlatformService implements PlatformService {
}
} else {
// We're in a worker context - skip initBackend call
console.log(
logger.log(
"[WebPlatformService] Skipping initBackend call in worker context",
);
}
@@ -109,19 +107,15 @@ export class WebPlatformService implements PlatformService {
};
this.worker.onerror = (error) => {
// logger.error("[WebPlatformService] Worker error:", error); // DISABLED
console.error("[WebPlatformService] Worker error:", error);
logger.error("[WebPlatformService] Worker error:", error);
this.workerReady = false;
};
// Send ping to verify worker is ready
await this.sendWorkerMessage({ type: "ping" });
this.workerReady = true;
// logger.log("[WebPlatformService] SQL worker initialized successfully"); // DISABLED
} catch (error) {
// logger.error("[WebPlatformService] Failed to initialize worker:", error); // DISABLED
console.error("[WebPlatformService] Failed to initialize worker:", error);
logger.error("[WebPlatformService] Failed to initialize worker:", error);
this.workerReady = false;
this.workerInitPromise = null;
throw new Error("Failed to initialize database worker");
@@ -140,21 +134,13 @@ export class WebPlatformService implements PlatformService {
}
if (!id) {
// logger.warn("[WebPlatformService] Received message without ID:", message); // DISABLED
console.warn(
"[WebPlatformService] Received message without ID:",
message,
);
logger.warn("[WebPlatformService] Received message without ID:", message);
return;
}
const pending = this.pendingMessages.get(id);
if (!pending) {
// logger.warn( // DISABLED
// "[WebPlatformService] Received response for unknown message ID:",
// id,
// );
console.warn(
logger.warn(
"[WebPlatformService] Received response for unknown message ID:",
id,
);
@@ -188,8 +174,7 @@ export class WebPlatformService implements PlatformService {
break;
default:
// logger.warn("[WebPlatformService] Unknown response type:", type); // DISABLED
console.warn("[WebPlatformService] Unknown response type:", type);
logger.warn("[WebPlatformService] Unknown response type:", type);
pending.resolve(message);
break;
}
@@ -220,9 +205,6 @@ export class WebPlatformService implements PlatformService {
timeout,
});
// logger.log( // DISABLED
// `[WebPlatformService] Sending message: ${request.type} (${id})`,
// );
this.worker!.postMessage(fullRequest);
});
}
@@ -245,8 +227,7 @@ export class WebPlatformService implements PlatformService {
await this.sendWorkerMessage<boolean>({ type: "ping" });
this.workerReady = true;
} catch (error) {
// logger.error("[WebPlatformService] Worker not ready:", error); // DISABLED
console.error("[WebPlatformService] Worker not ready:", error);
logger.error("[WebPlatformService] Worker not ready:", error);
throw new Error("Database worker not ready");
}
}