Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent other JS console logs going through the formatter #39

Open
srcrip opened this issue Jun 30, 2021 · 1 comment
Open

Prevent other JS console logs going through the formatter #39

srcrip opened this issue Jun 30, 2021 · 1 comment

Comments

@srcrip
Copy link

srcrip commented Jun 30, 2021

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.

@kraklin
Copy link
Owner

kraklin commented Aug 1, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants