Support `colors` and `extensionColors` in `mapConsoleTransport`
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected] for the project I'm working on.
Would be nice to be able to use mapConsoleTransport without losing the customization options available in consoleTransport.
colorsextensionColors
For now, I'm using consoleTransport and consoleFunc with a patch to achieve the same behavior.
Here is the diff that solved my problem:
diff --git a/node_modules/react-native-logs/dist/transports/consoleTransport.js b/node_modules/react-native-logs/dist/transports/consoleTransport.js
index 4018b52..f3ef254 100644
--- a/node_modules/react-native-logs/dist/transports/consoleTransport.js
+++ b/node_modules/react-native-logs/dist/transports/consoleTransport.js
@@ -44,7 +44,14 @@ const consoleTransport = (props) => {
msg = msg.replace(props.extension, `${extStart} ${props.extension} ${extEnd}`);
}
if ((_c = props.options) === null || _c === void 0 ? void 0 : _c.consoleFunc) {
- props.options.consoleFunc(msg.trim());
+ /**
+ * PATCH:
+ *
+ * Send level information to consoleFunc so it can be used to used
+ * to call different console functions (warn, error)
+ * https://github.com/mowispace/react-native-logs/issues/114
+ */
+ props.options.consoleFunc(msg.trim(), props.level.text);
}
else {
console.log(msg.trim());
See discussion https://github.com/mowispace/react-native-logs/discussions/106#discussioncomment-12706168 for usage of this patch.
Keep in mind this diff is not what I'm suggesting, it's just the workaround I did.
This issue body was partially generated by patch-package.
If the settings from mapConsoleTransport would work for consoleTransport, there wouldn't be even a need for mapConsoleTransport.