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

Environment variable for log.transports.console.level? #412

Open
jjeff opened this issue Apr 2, 2024 · 3 comments
Open

Environment variable for log.transports.console.level? #412

jjeff opened this issue Apr 2, 2024 · 3 comments

Comments

@jjeff
Copy link

jjeff commented Apr 2, 2024

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?

@megahertz
Copy link
Owner

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.

@jjeff
Copy link
Author

jjeff commented Apr 2, 2024

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!

@megahertz
Copy link
Owner

You're referring to electron-mocha's --require-main argument to add some electron-log configuration code to the mocha tests

Yes

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