elm-debug-transformer icon indicating copy to clipboard operation
elm-debug-transformer copied to clipboard

Prevent other JS console logs going through the formatter

Open srcrip opened this issue 4 years ago • 1 comments

Hi,

I love the library, but one request I have is I'd like the ability to 'whitelist' messages from other parts of my JS to not go through the formatter. If I use other JS libraries alongside my elm, I have to be careful about not outputting non alphanumeric characters in their console logs.

I'm not sure exactly how it could be done cause I haven't read the code in question yet, but is there a way to listen only to the elm bundles logs? Or have some kind of special string we look for in the beginning of the message to override the formatter and escape? Then you could write a special console log function that always inserts that string for your own code.

srcrip avatar Jun 30 '21 13:06 srcrip

Hey @sevensidedmarble,

sadly there is no way to distinguish between elm and non-elm console logs :/ The transformer should transform only the logs that are in the format of elm Debug.log, i.e. something before colon : "some parsable value" - if the parser is not able to parse this, it should default to the plain console.log

I have to be careful about not outputting non alphanumeric characters in their console logs.

I don't understand the limitation here - it should not limit you if you don't want to format the other JS logs - if you put in the non alphanumeric character it should just default to the console.log without the formatting.

Or have some kind of special string we look for in the beginning of the message to override the formatter and escape? Then you could write a special console log function that always inserts that string for your own code.

You can try to start the console messages with e.g. :: - that should fail the parser.

Anyway, can you provide the messages you are trying to get through and what you actually get?

kraklin avatar Aug 01 '21 19:08 kraklin