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

Can not log when undefined return by getAppName() #418

Closed
henrydf opened this issue May 24, 2024 · 2 comments
Closed

Can not log when undefined return by getAppName() #418

henrydf opened this issue May 24, 2024 · 2 comments

Comments

@henrydf
Copy link

henrydf commented May 24, 2024

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Recently, my project can not log any more in production env. And it reports The "path" argument must be of type string. Received undefined.

Here is the diff that solved my problem:

diff --git a/node_modules/electron-log/src/node/NodeExternalApi.js b/node_modules/electron-log/src/node/NodeExternalApi.js
index 7c5359f..5257a42 100644
--- a/node_modules/electron-log/src/node/NodeExternalApi.js
+++ b/node_modules/electron-log/src/node/NodeExternalApi.js
@@ -21,7 +21,7 @@ class NodeExternalApi {
   }
 
   getAppName() {
-    return this.appName || this.getAppPackageJson()?.name;
+    return this.appName || this.getAppPackageJson()?.name || 'default';
   }
 
   /**

This issue body was partially generated by patch-package.

@megahertz
Copy link
Owner

Thank you. I'll investigate that this week

@megahertz
Copy link
Owner

megahertz commented May 25, 2024

It happens when the library can't load the app name from electron.app or package.json (there is no package.json file in the current or any parent dir). I don't want to provide a default value for this case since it isn't an expected behavior. Instead, I'm thinking about a way how app name can be configured. When that's not possible to determine it, the lib should throw a more user-friendly exception.

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