josdejong / svelte-jsoneditor

A web-based tool to view, edit, format, repair, query, transform, and validate JSON
https://jsoneditoronline.org
Other
818 stars 108 forks source link

Cant disbable debug output #278

Closed azpublic closed 1 year ago

azpublic commented 1 year ago

Hi!

My question is related to #253

I'm unable to disable jsonEditor's debug mechanism because my app uses the same debug mechanism as yours. I'm using the debug-js library (https://github.com/debug-js/debug) which relies on

localStorage.debug = 'MyApp:*'

to enable and filter the debugging / logging output.

In your code at :

https://github.com/josdejong/svelte-jsoneditor/blob/51c1d5441085581402cc916e9479c2c91d5c068e/src/lib/utils/debug.ts#LL25C43-L25C43

you use :

enabled = !!tryReadLocalStorage('debug')

which will always return true if there's anything inside localStorage.debug variable.

So I basically cant disable debugging for jsoneditor.

I there a way you could change the localstorage key ? Another option would be to make is as such that I could use debugjs syntax to disable it but that would require slightly more elaborate parsing.

For example :

localStorage.debug = 'MyApp: -jsoneditor:';

Thanks

josdejong commented 1 year ago

Good point. I originally used the debug library that you mention, but it was too heavy weight for me, so I created a lightweight version of it.

I'll implement a simple pattern matching for it, that makes sense.

josdejong commented 1 year ago

I've implemented a very minimal filtering mechanism, I think that should do the trick:

https://github.com/josdejong/svelte-jsoneditor/blob/b2317a5db900b77644d992f2f14c97e1de31c3c5/src/lib/utils/debug.ts#L43-L47

(not yet published)

josdejong commented 1 year ago

Fixed now in v0.17.7

azpublic commented 1 year ago

Thanks a lot ! Will try it in a bit and let you know.