mowispace/react-native-logs

Enable and disable config for multiple messages concatenation.

khan-zia opened this issue · 4 comments

#27 is a bit related but in my use case I would like to disable the default concatenation when I pass multiple messages to the log functions. This is because I don't want my main log message to be cluttered with stringified stuff and I would like to handle my other passed messages in a custom way already.

I can still access additional objects via the rawMsg prop but my main message is still cluttered with the stringified version of it. It would be great to have this things as optional via the config.

Regards.

I can't understand why rawMsg is not sufficient, can you give me an example of your use case?

I don't fully remember everything as it's been exactly one year but I think the problem was related to taking complete control over how the final message that gets sent to the logs is formatted. This will allow developers to have one central logger interface. This interface/class will have let's say a log method that accepts an object aka rawMsg and based on what values inside the raw message have been defined, the developer would format the message before sending it off.

The problem I am sure was that while you can define a rawMsg but then you have to accept whatever format this package comes up with using the contents of the rawMsg.

Okay I get it, basically you would like to have both the ability to use rawMsg and the ability to disable message formatting to use both systems together. This change is not related to transports so it would probably involve several breaking changes, for now I have added the ability to set in configuration a custom function for message stringify, we will evaluate other changes in the future. Thanks and sorry for delay;)

Thanks for the update. Yeah, that was pretty much it. For e.g. Some developers might want to format the timestamp that's concatenated to the log message differently. Some developers might want to change the position of the timestamp (which if I remember correctly always appears at the beginning). So in summary, the formatting of the log message should have a default that's not enforced otherwise.