From ebcac5a1427f0018ec17d072aca04175a601094a Mon Sep 17 00:00:00 2001 From: Michael Lustig Date: Thu, 2 Jan 2025 17:31:23 -0500 Subject: [PATCH] make logger light color scheme friendly (#1463) ### dark ![CleanShot 2025-01-02 at 16 22 47@2x](https://github.com/user-attachments/assets/9cc7cc60-9909-4a20-90c2-5bc15c62bf95) ### light ![CleanShot 2025-01-02 at 16 20 06@2x](https://github.com/user-attachments/assets/a457d954-f436-48e9-b3ae-08cb1f020063) ## Summary by CodeRabbit - **New Features** - Enhanced logging functionality with dynamic color schemes based on system appearance (dark or light mode) - Improved visual representation of log messages that adapt to user's system settings --- utils/logger.ts | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/utils/logger.ts b/utils/logger.ts index 5e042ce1e..6fd0b62a0 100644 --- a/utils/logger.ts +++ b/utils/logger.ts @@ -69,16 +69,30 @@ const converseTransport: transportFunctionType = async (props) => { await RNFS.appendFile(loggingFilePath, `${props.msg}\n`, "utf8"); }; +const developerSystemAppearance: "dark" | "light" = "dark" as const; +const darkSystemColorScheme = { + debug: "white", + info: "blueBright", + warn: "yellowBright", + error: "redBright", +}; + +const lightSystemColorScheme = { + debug: "black", + info: "blue", + warn: "orange", + error: "red", +}; + const _logger = RNLogger.createLogger({ severity: "debug", // @todo => change minimum severity according to env & user (debug addresses) transport: converseTransport, transportOptions: { - colors: { - debug: "white", - info: "blueBright", - warn: "yellowBright", - error: "redBright", - }, + colors: + // @ts-ignore + developerSystemAppearance === "dark" + ? darkSystemColorScheme + : lightSystemColorScheme, }, levels: { debug: 0,