Skip to content

Support colors and extensionColors in mapConsoleTransport #114

@g-otn

Description

@g-otn

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch react-native-logs@5.3.0 for the project I'm working on.

Would be nice to be able to use mapConsoleTransport without losing the customization options available in consoleTransport.

  • colors
  • extensionColors

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 #106 (comment) 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions