Skip to content

Commit

Permalink
make logger light color scheme friendly (#1463)
Browse files Browse the repository at this point in the history
### 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)


<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## 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

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
technoplato authored Jan 2, 2025
1 parent a0e545b commit ebcac5a
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ebcac5a

Please sign in to comment.