From 30da625fdd0df49071291354e0a87d071b5981a1 Mon Sep 17 00:00:00 2001
From: "google-labs-jules[bot]"
<161369871+google-labs-jules[bot]@users.noreply.github.com>
Date: Fri, 25 Jul 2025 14:52:48 +0000
Subject: [PATCH] feat(frontend): replace console with custom logger
I replaced all instances of console.log, console.warn, and console.error with the custom logger @hatchgrid/logger throughout the frontend applications and packages.
- I added @hatchgrid/logger as a dependency to client/packages/utilities, client/apps/web, and client/apps/landing-page.
- I replaced all console.* calls with the appropriate logger method (e.g., logger.info, logger.warn, logger.error).
- I updated tests in useLocalStorage.spec.ts to mock the logger instead of console.warn.
---
client/apps/landing-page/package.json | 1 +
.../src/components/cta-email/CTAEmail.vue | 6 ++--
.../src/components/ui/cta-email/CTAEmail.vue | 5 ++-
client/apps/landing-page/src/i18n/ui.ts | 6 ++--
.../src/models/category/category.service.ts | 5 ++-
.../src/models/tag/tag.service.ts | 6 ++--
.../src/utils/test/mockEmailApi.ts | 5 ++-
client/apps/web/package.json | 1 +
client/apps/web/src/App.vue | 19 +++++-------
.../web/src/account/register/register.vue | 6 ++--
.../apps/web/src/components/UserProfile.vue | 6 ++--
.../__tests__/useLocalStorage.spec.ts | 22 +++++++------
.../web/src/composables/useLocalStorage.ts | 10 ++++--
.../apps/web/src/config/axios-interceptor.ts | 5 ++-
client/apps/web/src/i18n/index.ts | 11 ++++---
client/apps/web/src/i18n/load.locales.ts | 8 +++--
.../web/src/layouts/components/AppHeader.vue | 4 ++-
.../router/middleware/loadLayoutMiddleware.ts | 6 ++--
.../apps/web/src/services/account.service.ts | 31 ++++++++-----------
client/apps/web/src/stores/auth.ts | 7 +++--
client/packages/utilities/package.json | 1 +
.../utilities/src/theme/color-theme.ts | 5 ++-
pnpm-lock.yaml | 11 ++++++-
23 files changed, 115 insertions(+), 72 deletions(-)
diff --git a/client/apps/landing-page/package.json b/client/apps/landing-page/package.json
index c4b7f127..97cb625b 100644
--- a/client/apps/landing-page/package.json
+++ b/client/apps/landing-page/package.json
@@ -43,6 +43,7 @@
"dependencies": {
"@astrojs/check": "^0.9.4",
"@astrojs/mdx": "^4.3.1",
+ "@hatchgrid/logger": "workspace:*",
"@astrojs/rss": "^4.0.12",
"@astrojs/sitemap": "^3.4.1",
"@astrojs/vue": "^5.1.0",
diff --git a/client/apps/landing-page/src/components/cta-email/CTAEmail.vue b/client/apps/landing-page/src/components/cta-email/CTAEmail.vue
index bda1e06b..966bfe03 100644
--- a/client/apps/landing-page/src/components/cta-email/CTAEmail.vue
+++ b/client/apps/landing-page/src/components/cta-email/CTAEmail.vue
@@ -1,4 +1,5 @@
diff --git a/client/apps/landing-page/src/i18n/ui.ts b/client/apps/landing-page/src/i18n/ui.ts
index 98f9a47e..c8fc4848 100644
--- a/client/apps/landing-page/src/i18n/ui.ts
+++ b/client/apps/landing-page/src/i18n/ui.ts
@@ -1,6 +1,8 @@
+import { LogManager } from "@hatchgrid/logger";
import type { Lang, UIDict, UIMultilingual } from "./types";
// Use import.meta.glob to get all translation files
+const logger = LogManager.getLogger("landing-page:i18n-ui");
const translationModules = import.meta.glob<
Record>
>("./translations/*.ts", { eager: true });
@@ -38,8 +40,8 @@ export const ui: UIMultilingual = Object.values(translationModules).reduce(
// Enhanced debug log to check what was loaded
if (process.env.NODE_ENV === "development") {
- console.log(
- "㊙︎ Loaded translations:",
+ logger.debug(
+ "Loaded translations",
Object.keys(ui)
.map((lang) => `${lang}: ${Object.keys(ui[lang as Lang]).length} keys`)
.join(", "),
diff --git a/client/apps/landing-page/src/models/category/category.service.ts b/client/apps/landing-page/src/models/category/category.service.ts
index 301142ed..9599b802 100644
--- a/client/apps/landing-page/src/models/category/category.service.ts
+++ b/client/apps/landing-page/src/models/category/category.service.ts
@@ -4,11 +4,14 @@
*/
import { getCollection, getEntry } from "astro:content";
+import { LogManager } from "@hatchgrid/logger";
import { parseEntityId } from "@/utils/collection.entity";
import type { CategoryCriteria } from "./category.criteria";
import { toCategories, toCategory } from "./category.mapper";
import type Category from "./category.model";
+const logger = LogManager.getLogger("landing-page:category-service");
+
/**
* Retrieves categories from the content collection with filtering options
* @async
@@ -70,7 +73,7 @@ export const getCategoryById = async (
const entry = await getEntry("categories", categoryId);
return entry ? toCategory(entry) : undefined;
} catch (error) {
- console.error(`Failed to fetch category ${categoryId}:`, error);
+ logger.error(`Failed to fetch category ${categoryId}`, { error });
throw new Error(`Failed to fetch category ${categoryId}`);
}
};
diff --git a/client/apps/landing-page/src/models/tag/tag.service.ts b/client/apps/landing-page/src/models/tag/tag.service.ts
index e064263d..a6895a7b 100644
--- a/client/apps/landing-page/src/models/tag/tag.service.ts
+++ b/client/apps/landing-page/src/models/tag/tag.service.ts
@@ -4,11 +4,13 @@
*/
import { getCollection, getEntry } from "astro:content";
+import { LogManager } from "@hatchgrid/logger";
import { parseEntityId } from "@/utils/collection.entity";
import type { TagCriteria } from "./tag.criteria";
import { toTag, toTags } from "./tag.mapper";
import type Tag from "./tag.model";
+const logger = LogManager.getLogger("landing-page:tag-service");
const tagsCache: Record = {};
/**
@@ -58,7 +60,7 @@ export async function getTags(criteria?: TagCriteria): Promise {
tagsCache[cacheKey] = mappedTags;
return mappedTags;
} catch (error) {
- console.error("Failed to fetch tags:", error);
+ logger.error("Failed to fetch tags", { error });
throw new Error("Failed to fetch tags");
}
}
@@ -74,7 +76,7 @@ export async function getTagById(id: string): Promise {
const entry = await getEntry("tags", id);
return entry ? toTag(entry) : undefined;
} catch (error) {
- console.error(`Failed to fetch tag with id ${id}:`, error);
+ logger.error(`Failed to fetch tag with id ${id}`, { error });
throw new Error(`Failed to fetch tag with id ${id}`);
}
}
diff --git a/client/apps/landing-page/src/utils/test/mockEmailApi.ts b/client/apps/landing-page/src/utils/test/mockEmailApi.ts
index ba1347f7..3da3da87 100644
--- a/client/apps/landing-page/src/utils/test/mockEmailApi.ts
+++ b/client/apps/landing-page/src/utils/test/mockEmailApi.ts
@@ -3,6 +3,8 @@
* This simulates the backend API responses for email submissions
*/
+import { LogManager } from "@hatchgrid/logger";
+
export interface MockApiConfig {
delay?: number;
successRate?: number;
@@ -94,6 +96,7 @@ export class MockEmailApi {
}
// Global mock setup for fetch in development
+const logger = LogManager.getLogger("landing-page:mock-email-api");
export function setupMockApi(config?: MockApiConfig) {
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
const mockApi = new MockEmailApi(config);
@@ -132,7 +135,7 @@ export function setupMockApi(config?: MockApiConfig) {
return originalFetch(url, options);
};
- console.log("🚀 Mock Email API enabled for development");
+ logger.info("Mock Email API enabled for development");
// return mockApi // This return is not strictly necessary if not used elsewhere after setup
}
}
diff --git a/client/apps/web/package.json b/client/apps/web/package.json
index 1287412a..ba8331d0 100644
--- a/client/apps/web/package.json
+++ b/client/apps/web/package.json
@@ -15,6 +15,7 @@
"test:coverage": "vitest run --coverage"
},
"dependencies": {
+ "@hatchgrid/logger": "workspace:*",
"@hatchgrid/utilities": "workspace:*",
"@internationalized/date": "^3.8.2",
"@tailwindcss/vite": "^4.1.11",
diff --git a/client/apps/web/src/App.vue b/client/apps/web/src/App.vue
index 798d673d..1bf7fbf3 100644
--- a/client/apps/web/src/App.vue
+++ b/client/apps/web/src/App.vue
@@ -6,12 +6,14 @@
diff --git a/client/apps/web/src/account/register/register.vue b/client/apps/web/src/account/register/register.vue
index 7ad72906..ea7b1269 100644
--- a/client/apps/web/src/account/register/register.vue
+++ b/client/apps/web/src/account/register/register.vue
@@ -102,6 +102,7 @@