Environment variable for log.transports.console.level?
jjeff opened this issue · 3 comments
I'm using Mocha (electron-mocha
actually) to unit test a lot of the functionality in my Electron app. I'm also using electron-log
's default instance to sprinkle copious (often VERY silly) logging messages throughout my code.
Here's the problem: When I run my Electron app, I can set the log level during my bootstrap process. But when I'm running my unit tests, that code doesn't get executed and electron-log defaults to outputting all levels of log messages, which really makes a mess of my unit test console.
Would you be open to an ELECTRON_LOG_CONSOLE_LEVEL environment variable (or similar) to set the fallback log.transports.consol.level
? If so, I'd be happy to take a swing at a pull request.
Or am I missing something? Is there another approach I should be taking?
It looks like the electron-mocha supports require a generic module in the main process. I think that's the best way to configure the logging level for tests.
My understanding is that electron-mocha has the capability of emulating code running in the main or renderer process. But it doesn't mean that all of the main or renderer process code is bootstrapped. If I'm testing a single isolated class from an individual file, that's the only code that will get run.
What do you mean by "require a generic module in the main process"? You're referring to electron-mocha
's --require-main
argument to add some electron-log
configuration code to the mocha tests? Okay, I could see that working!
You're referring to electron-mocha's --require-main argument to add some electron-log configuration code to the mocha tests
Yes