Browse Source

remove debugging info messages (change to debug if we want these -- and tell us how to turn off debug locally)

Trent Larson 2 weeks ago
parent
commit
838723c26b
  1. 25
      src/main.common.ts
  2. 5
      src/main.web.ts
  3. 17
      src/services/migrationService.ts
  4. 14
      src/utils/logger.ts

25
src/main.common.ts

@ -10,15 +10,11 @@ import { FontAwesomeIcon } from "./libs/fontawesome";
import Camera from "simple-vue-camera"; import Camera from "simple-vue-camera";
import { logger } from "./utils/logger"; import { logger } from "./utils/logger";
const platform = process.env.VITE_PLATFORM; // const platform = process.env.VITE_PLATFORM;
const pwa_enabled = process.env.VITE_PWA_ENABLED === "true"; // const pwa_enabled = process.env.VITE_PWA_ENABLED === "true";
logger.log("Platform", JSON.stringify({ platform }));
logger.log("PWA enabled", JSON.stringify({ pwa_enabled }));
// Global Error Handler // Global Error Handler
function setupGlobalErrorHandler(app: VueApp) { function setupGlobalErrorHandler(app: VueApp) {
logger.log("[App Init] Setting up global error handler");
app.config.errorHandler = ( app.config.errorHandler = (
err: unknown, err: unknown,
instance: ComponentPublicInstance | null, instance: ComponentPublicInstance | null,
@ -38,30 +34,13 @@ function setupGlobalErrorHandler(app: VueApp) {
// Function to initialize the app // Function to initialize the app
export function initializeApp() { export function initializeApp() {
logger.log("[App Init] Starting app initialization");
logger.log("[App Init] Platform:", process.env.VITE_PLATFORM);
const app = createApp(App); const app = createApp(App);
logger.log("[App Init] Vue app created");
app.component("FontAwesome", FontAwesomeIcon).component("camera", Camera); app.component("FontAwesome", FontAwesomeIcon).component("camera", Camera);
logger.log("[App Init] Components registered");
const pinia = createPinia(); const pinia = createPinia();
app.use(pinia); app.use(pinia);
logger.log("[App Init] Pinia store initialized");
app.use(VueAxios, axios); app.use(VueAxios, axios);
logger.log("[App Init] Axios initialized");
app.use(router); app.use(router);
logger.log("[App Init] Router initialized");
app.use(Notifications); app.use(Notifications);
logger.log("[App Init] Notifications initialized");
setupGlobalErrorHandler(app); setupGlobalErrorHandler(app);
logger.log("[App Init] App initialization complete");
return app; return app;
} }

5
src/main.web.ts

@ -5,9 +5,6 @@ import { logger } from "./utils/logger";
const platform = process.env.VITE_PLATFORM; const platform = process.env.VITE_PLATFORM;
const pwa_enabled = process.env.VITE_PWA_ENABLED === "true"; const pwa_enabled = process.env.VITE_PWA_ENABLED === "true";
logger.info("[Web] PWA enabled", { pwa_enabled });
logger.info("[Web] Platform", { platform });
// Only import service worker for web builds // Only import service worker for web builds
if (platform !== "electron" && pwa_enabled) { if (platform !== "electron" && pwa_enabled) {
import("./registerServiceWorker"); // Web PWA support import("./registerServiceWorker"); // Web PWA support
@ -31,7 +28,7 @@ function sqlInit() {
if (platform === "web" || platform === "development") { if (platform === "web" || platform === "development") {
sqlInit(); sqlInit();
} else { } else {
logger.info("[Web] SQL not initialized for platform", { platform }); logger.warn("[Web] SQL not initialized for platform", { platform });
} }
app.mount("#app"); app.mount("#app");

17
src/services/migrationService.ts

@ -25,7 +25,6 @@ class MigrationRegistry {
*/ */
registerMigration(migration: Migration): void { registerMigration(migration: Migration): void {
this.migrations.push(migration); this.migrations.push(migration);
logger.info(`[MigrationService] Registered migration: ${migration.name}`);
} }
/** /**
@ -42,7 +41,6 @@ class MigrationRegistry {
*/ */
clearMigrations(): void { clearMigrations(): void {
this.migrations = []; this.migrations = [];
logger.info("[MigrationService] Cleared all registered migrations");
} }
} }
@ -94,10 +92,6 @@ export async function runMigrations<T>(
); );
const appliedMigrations = extractMigrationNames(appliedMigrationsResult); const appliedMigrations = extractMigrationNames(appliedMigrationsResult);
logger.info(
`[MigrationService] Found ${appliedMigrations.size} applied migrations`,
);
// Get all registered migrations // Get all registered migrations
const migrations = migrationRegistry.getMigrations(); const migrations = migrationRegistry.getMigrations();
@ -106,21 +100,12 @@ export async function runMigrations<T>(
return; return;
} }
logger.info(
`[MigrationService] Running ${migrations.length} registered migrations`,
);
// Run each migration that hasn't been applied yet // Run each migration that hasn't been applied yet
for (const migration of migrations) { for (const migration of migrations) {
if (appliedMigrations.has(migration.name)) { if (appliedMigrations.has(migration.name)) {
logger.info(
`[MigrationService] Skipping already applied migration: ${migration.name}`,
);
continue; continue;
} }
logger.info(`[MigrationService] Applying migration: ${migration.name}`);
try { try {
// Execute the migration SQL // Execute the migration SQL
await sqlExec(migration.sql); await sqlExec(migration.sql);
@ -141,8 +126,6 @@ export async function runMigrations<T>(
throw new Error(`Migration ${migration.name} failed: ${error}`); throw new Error(`Migration ${migration.name} failed: ${error}`);
} }
} }
logger.info("[MigrationService] All migrations completed successfully");
} catch (error) { } catch (error) {
logger.error("[MigrationService] Migration process failed:", error); logger.error("[MigrationService] Migration process failed:", error);
throw error; throw error;

14
src/utils/logger.ts

@ -52,16 +52,10 @@ export const logger = {
} }
}, },
warn: (message: string, ...args: unknown[]) => { warn: (message: string, ...args: unknown[]) => {
if ( // eslint-disable-next-line no-console
process.env.NODE_ENV !== "production" || console.warn(message, ...args);
process.env.VITE_PLATFORM === "capacitor" || const argsString = args.length > 0 ? " - " + safeStringify(args) : "";
process.env.VITE_PLATFORM === "electron" logToDb(message + argsString);
) {
// eslint-disable-next-line no-console
console.warn(message, ...args);
const argsString = args.length > 0 ? " - " + safeStringify(args) : "";
logToDb(message + argsString);
}
}, },
error: (message: string, ...args: unknown[]) => { error: (message: string, ...args: unknown[]) => {
// Errors will always be logged // Errors will always be logged

Loading…
Cancel
Save