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.)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow specifying a colour during logger extension creation

pke opened this issue · comments

I'd like to colour my loggers with a specific colour.

Would be helpful if during extend one could specify options for each transport like:

const logger = mainLogger.extend("api", { consoleTransport: { colour: "darkgray"  } })

At the moment it is only possible to colour by level, not by namespace/extension, but this is a function I absolutely must add as soon as possible, you are right...

Like the possibility to choose which colour, I just have to find a way to manage this option since it is the transports that take care of colouring the logs not the library...

Maybe like I wrote in the example. One can specify the transporter name and supply options only the transporter understands.
Then console transporter could then colour the level and the message differently if a custom colour was set, otherwise the behaviour stays as it is now

From v 4.0.0 in the consoleTransport it is possible to choose the color of the log levels and also the colors of the extensions.

Thanks, great work!
I think I will add the option to generate a random colour for my loggers, that don't specify a colour.