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

Fix: logging and empty config #601

Merged
merged 18 commits into from
Oct 13, 2024
Merged

Fix: logging and empty config #601

merged 18 commits into from
Oct 13, 2024

Conversation

baruchiro
Copy link
Collaborator

This pull request refactors the logging statements in the codebase to use the logger instead of console.log. This improves the consistency and maintainability of the logging system.

The following commits are included in this pull request:

  • license package.json

  • enable logger

  • Refactor logging statements to use logger instead of console.log

Copy link
Contributor

github-actions bot commented Oct 9, 2024

Please fix the title of this PR.

Examples:

Breaking: I broke something
Fix: fix (fixes #1234)
Update: some packages updates (refs #123)
New: Added a new feature

See more in release.config.js.

Comment on lines +19 to +24
const config = JSON.parse(decrypted);
if (Object.keys(config).length === 0) {
logger.log('Empty config file found, returning default config');
return configExample;
}
return config;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fix for my case, when the config somehow became {}. (Locally on dev env)

Comment on lines +12 to +18
log.initialize();

// This will transport the logs to the renderer process (DevTools) in production too
log.transports.ipc.level = log.transports.file.level;

Object.assign(console, log.functions);
const logger = log.scope('main');
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • initialize: Get all logs from the renderer into the main logger (the renderer can't write to file)
  • transport.ipc defaults to false for production. Since our users learned to debug the problem with the DevTools, I think it will help to send the main logs into the renderer console.
  • Object.assign(console, log.functions) to catch also the console.loga

@@ -18,19 +27,20 @@ const onError: MainErrorHandlerOptions['onError'] = ({ error }) => {
logger.error(error.message || error);
if (error.stack) logger.debug(error.stack);
};
logger.errorHandler.startCatching({ onError });
logger.catchErrors({ onError });
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deprecated

@baruchiro baruchiro changed the title Refactor logging statements to use logger Fix: logging and empty config Oct 10, 2024
import fs from 'fs';
import { EOL } from 'os';
import path from 'path';

log.initialize();

// This will transport the logs to the renderer process (DevTools) in production too
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove comment

@baruchiro baruchiro merged commit d41cde2 into master Oct 13, 2024
10 checks passed
@baruchiro baruchiro deleted the baruch/fixes branch October 13, 2024 14:52
Copy link
Contributor

🎉 This PR is included in version 2.0.6 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants