I followed the debug guide here: https://serialport.io/docs/guide-debugging to enable SerialPort debugging in the log. This worked, now I no longer want a log full of serialport/bindings ... and other such entries.
The guide doesn't explain how to turn them off. I've cleared the environment variable and it still does it.
The env variable is read when the program starts up. Either you need to restart the program or the env variable isn鈥檛 cleared.
I probably should have mentioned, this is an Electron application.
I've cleared the environmental variable, restarted my machine and completely reinstalled all node modules. Whenever I start the application the debug messages are in the Electron log. Could Electron have picked up this environmental variable?
Try console.log(process.env.DEBUG) to see what it sees. Probably from the main process.
I get undefined.
Can you give me a sample of the log?
...\node_modules\@serialport\stream\node_modules\debug\src\browser.js:183 serialport/bindings loading WindowsBinding +0ms
...\node_modules\@serialport\stream\node_modules\debug\src\browser.js:183 serialport/stream .list +0ms
...\node_modules\@serialport\stream\node_modules\debug\src\browser.js:183 serialport/stream .list +1s
...\node_modules\@serialport\stream\node_modules\debug\src\browser.js:183 serialport/stream opening +23ms path: COM3
...\node_modules\@serialport\binding-abstract\node_modules\debug\src\browser.js:183 serialport/binding-abstract open +0ms
...\node_modules\@serialport\stream\node_modules\debug\src\browser.js:183 serialport/stream _read +8ms queueing _read for after open
...\node_modules\@serialport\stream\node_modules\debug\src\browser.js:183 serialport/stream opened +1ms path: COM3
...\node_modules\@serialport\stream\node_modules\debug\src\browser.js:183 serialport/stream _write +5ms 1 bytes of data
...\node_modules\@serialport\binding-abstract\node_modules\debug\src\browser.js:183 serialport/binding-abstract write +14ms 1 bytes
...\node_modules\@serialport\stream\node_modules\debug\src\browser.js:183 serialport/stream _read +2ms reading
...\node_modules\@serialport\binding-abstract\node_modules\debug\src\browser.js:183 serialport/binding-abstract read +1ms
...\node_modules\@serialport\stream\node_modules\debug\src\browser.js:183 serialport/stream binding.write +4ms write finished
...\node_modules\@serialport\stream\node_modules\debug\src\browser.js:183 serialport/stream binding.read +1ms finished
...\node_modules\@serialport\stream\node_modules\debug\src\browser.js:183 serialport/stream _read +1ms reading
...\node_modules\@serialport\binding-abstract\node_modules\debug\src\browser.js:183 serialport/binding-abstract read +6ms
...\node_modules\@serialport\stream\node_modules\debug\src\browser.js:183 serialport/stream binding.read +1ms finished
...\node_modules\@serialport\stream\node_modules\debug\src\browser.js:183 serialport/stream #close +2ms
...\node_modules\@serialport\binding-abstract\node_modules\debug\src\browser.js:183 serialport/binding-abstract close +3ms
...\node_modules\@serialport\stream\node_modules\debug\src\browser.js:183 serialport/stream _read +1ms queueing _read for after open
...\node_modules\@serialport\stream\node_modules\debug\src\browser.js:183 serialport/stream binding.close +4ms finished
I replaced my personal file structure with ..., but that's a log showing the messages I no longer require. I'm trying to debug other aspects of my code and these are getting in the way.
That鈥檚 really weird. We use the debug npm package. If you have any other package that messes with it鈥檚 global settings that might be the cause.
I'm completely uninstalling Node.js and starting fresh at the moment. I'll let you know if that fixes it. If not, I have no idea what's going on.
Completely uninstalled Node.js. Cleared node_modules and reinstalled. The debug messages are still coming up. I can't think what else could be triggering them.
According to some quick googling set DEBUG= or setx DEBUG or $env:DEBUG = $null might do the trick. NodeJS and your program can't be permanently changed by setting the env var to enable logging, but your environment can be. (Have you tried rebooting?)
You could also try another method, set debug to equal something else like set DEBUG=foobar which wont match anything from serialport.
Debug's docs can be found here https://www.npmjs.com/package/debug
Tried that before and restarted multiple times. I have no idea what aspect of my environment could even hold that setting as I've uninstalled everything and reinstalled it.
I had a different issue but same outcome: a boatload of log messages.
Thanks to a colleague I found that electron had stored the debug:* key in the localstorage. Maybe you have that same key
How did you access Electron's localstorage? I've not had to directly interact with it before.
Do you have the Developer Tools open?(I was kinda assuming you log issue was in the devtools)
If so: Application tab, Storage, Localstorage
That was it! Thank you!
Holy cow! Thanks for the tip!
Most helpful comment
I had a different issue but same outcome: a boatload of log messages.
Thanks to a colleague I found that electron had stored the
debug:*key in the localstorage. Maybe you have that same key