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

Empty log dir at default location for Electron with ESM #368

Closed
raphaelmenges opened this issue Sep 25, 2023 · 2 comments
Closed

Empty log dir at default location for Electron with ESM #368

raphaelmenges opened this issue Sep 25, 2023 · 2 comments

Comments

@raphaelmenges
Copy link

raphaelmenges commented Sep 25, 2023

Hello 👋

I am using Electron in an ESM environment (which is soon to be available without workaround) together with electron-log. I need to change the location of the log file. However, I cannot prohibit electron-log from creating an empty directory with the name from my package.json. I guess it has something to do with how import works differently from require, because a similar issue had been resolved for the latter. I have created a minimal reproduction of the bug here: https://github.com/raphaelmenges/electron-log-empty-dir-bug.

This is how the Logs directory looks on my Mac after execution:
Screenshot 2023-09-25 at 09 33 11

Here is where I create the app:
https://github.com/raphaelmenges/electron-log-empty-dir-bug/blob/main/packages/main/src/app.ts

Here is where I setup the log:
https://github.com/raphaelmenges/electron-log-empty-dir-bug/blob/main/packages/main/src/log.ts

Here is where I combine both:
https://github.com/raphaelmenges/electron-log-empty-dir-bug/blob/main/packages/main/src/index.ts

It does not hurt the UX but feels weird to have an empty directory created with no use!

@megahertz
Copy link
Owner

Thank you for the sample. That dir is created automatically when app.getPath('logs') is called. Now it's called lazily to prevent that.

@raphaelmenges
Copy link
Author

Thank you very much @megahertz for the quick fix and release of 5.0.0-rc.1. Can confirm it fixes the issue for me as well!

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