mowispace / react-native-logs

Performance-aware simple logger for React-Native and Expo with namespaces, custom levels and custom transports (colored console, file writing, etc.)
MIT License
467 stars 33 forks source link

Colour support for mapConsoleTransport or map support for consoleTransport #56

Closed pke closed 10 months ago

pke commented 2 years ago

I recently wrote a test and wondered why my expectation that the logger.error would call console.error eventually did not work. Then I found out that consoleTransport uses console.log always and that to mimic console output traditionally one would have to use mapConsoleTransport

Now I have 2 questions:

  1. Why is consoleTransport using only console.log?
  2. Why isn't mapConsoleTransport not supporting colours.

Would it be possible to merge the 2 and have it map by default and use coloured output?

alessandro-bottamedi commented 2 years ago

Some consoles (e.g. chrome's) color the output according to the method used (console.warn, console.error, etc...) so I opted to create a separate transport without the colors...

alessandro-bottamedi commented 10 months ago

Reopen if you think it is still necessary.

trydalch commented 9 months ago

In VSCode when using mapConsoleTransport, it only colors the first part of the log message (LOG, DEBUG, WARN, or ERROR). Not the actual log message.

When using consoleTransport, it colors the whole message, but all of the logs are prefixed with "LOG" because it's just using console.log for all the log levels. This is confusing to look at because I'm logging things at different levels.

I'd like this feature, if possible.

Even if it's just a third transport (coloredMaptTransport) or something.