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: forward backend logging to electron #2236

Merged
merged 2 commits into from
Sep 26, 2023
Merged

Conversation

kittaakos
Copy link
Contributor

@kittaakos kittaakos commented Sep 22, 2023

Motivation

Problem: When IDE2 runs in production mode (the app is bundled up), it logs into a file. When IDE2 starts, multiple processes start under the hood. The process hierarchy is like this electron main > backend main >> plugins_fsWatcher_and_other_subProcesses. IDE2 logs only in the backend main process and its child processes. The electron main process logging is missing from the generated single log file.

Since the electron main logging is missing, it very often happens that IDE2 does not even start on users' env (due to file permission, IPv6 vs. IPv4 issue, etc.), and the cause (error) is missing from the logs.

  • Without introducing a sophisticated logging server and/or message queues, it's impossible to write the same log file stream from different processes.
  • I would like to avoid introducing different log files (backend, electron) to simplify the info-gathering procedure.

This PR enables logging in the electorn main module, and the backend main with all its children will forward the log to the electron main via IPC. So it's in a centralized place and can be written into a file in production mode.

Steps to verify:

  • rename or delete the default log file location on your env. (on macOS, it's under ~/Library/Logs/Arduino IDE),
  • start IDE2 from a terminal,
  • normally quit the app,
  • open the generated log file and compare it with the terminal output.

You must see such entries in the generated log files:

[...]
2023-09-22 16:24:38 Arduino IDE 2.2.2-snapshot-0c567f78
2023-09-22 16:24:38 Checking for frontend application configuration customizations. Module path: /Users/a.kitta/dev/git/arduino-ide/electron-app/dist/mac/Arduino IDE.app/Contents/Resources/app/lib/backend/electron-main.js, destination 'package.json': /Users/a.kitta/dev/git/arduino-ide/electron-app/dist/mac/Arduino IDE.app/Contents/Resources/app/package.json
2023-09-22 16:24:38 Setting 'theia.frontend.config.appVersion' application configuration value to: "2.2.2-snapshot-0c567f78" (type of string)
2023-09-22 16:24:38 Setting 'theia.frontend.config.cliVersion' application configuration value to: "0.34.0" (type of string)
2023-09-22 16:24:38 Setting 'theia.frontend.config.buildDate' application configuration value to: "2023-09-22T14:22:41.170Z" (type of string)
[...]
2023-09-22 16:24:59 Storing the sketch as a workspace root: </Users/a.kitta/Documents/Arduino/WiFi101_OTA>.
2023-09-22 16:24:59 Skipped storing sketch as workspace root. Already visited: </Users/a.kitta/Documents/Arduino/WiFi101_OTA>.
2023-09-22 16:24:59 Stored workspaces roots: /Users/a.kitta/Documents/Arduino/WiFi101_OTA
2023-09-22 16:24:59 No sketches were scheduled for deletion.
[...]

The order of the log entries in the generated file and from the terminal is the same.

Change description

Other information

Reviewer checklist

  • PR addresses a single concern.
  • The PR has no duplicates (please search among the Pull Requests before creating one)
  • PR title and description are properly filled.
  • Docs have been added / updated (for bug fixes / features)

@kittaakos kittaakos added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Sep 22, 2023
@kittaakos kittaakos self-assigned this Sep 22, 2023
Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
@kittaakos kittaakos changed the title fix: forward log from electron to backend process fix: forward backend logging to electron Sep 22, 2023
@kittaakos kittaakos marked this pull request as ready for review September 22, 2023 14:55
Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
Copy link
Contributor

@per1234 per1234 left a comment

Choose a reason for hiding this comment

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

I verified this causes the previously missing content to be written to the log file.

Thanks Akos!

@Rinkurathod

This comment was marked as off-topic.

@kittaakos kittaakos merged commit ec28623 into main Sep 26, 2023
22 checks passed
@kittaakos kittaakos deleted the electron-main-logger branch September 26, 2023 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants