From b1d7a044cff86b34cfbfd5ba18bae657cf8a83f7 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Tue, 5 Mar 2024 01:16:10 -0800 Subject: [PATCH] new logging --- packages/astro-ghostcms/src/astro-ghostcms.ts | 42 +++++++------------ 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/packages/astro-ghostcms/src/astro-ghostcms.ts b/packages/astro-ghostcms/src/astro-ghostcms.ts index 3516fb21..0333e22b 100644 --- a/packages/astro-ghostcms/src/astro-ghostcms.ts +++ b/packages/astro-ghostcms/src/astro-ghostcms.ts @@ -44,19 +44,18 @@ export default defineIntegration({ // Configure Loggers const GhostLogger = logger.fork(c.bold(c.blue("👻 Astro-GhostCMS"))); + const loggerTagged = (message: string) => { + return logger.fork(`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue(message)}`) + } + // Configure ENV Logger - const GhostENVLogger = logger.fork( - `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( - "ENV Check", - )}`, - ); + const GhostENVLogger = loggerTagged("ENV Check"); // Configure Integration Loggers & verbose logging - const GhostIntegrationLogger = logger.fork( - `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( - "Integrations", - )}`, - ); + const GhostIntegrationLogger = loggerTagged("Integrations"); + + // Configure Route Logger & verbose logging + const GhostRouteLogger = loggerTagged("Router"); // Log Info Helper const intLogInfo = (message:string) => { @@ -65,13 +64,6 @@ export default defineIntegration({ } }; - // Configure Route Logger & verbose logging - const GhostRouteLogger = logger.fork( - `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.blue( - "Router", - )}`, - ); - // Log Route Info Helper const routeLogInfo = (message:string) => { if (verbose) { @@ -241,17 +233,13 @@ export default defineIntegration({ ); }, "astro:server:start": async ({ logger }) => { + const loggerTagged = (message: string) => { + return logger.fork(`${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.green(message)}`) + } // Configure Loggers - const GhostLogger = logger.fork( - `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.bold( - c.green("DEV"), - )}`, - ); - const GhostUpdateLogger = logger.fork( - `${c.bold(c.blue("👻 Astro-GhostCMS"))}${c.gray("/")}${c.bold( - c.green("VERSION CHECK"), - )}`, - ); + const GhostLogger = loggerTagged("DEV"); + + const GhostUpdateLogger = loggerTagged("VERSION CHECK"); // Start the DEV server GhostLogger.info(