-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Add --log-file
command line argument to write output log to a file
#87373
Add --log-file
command line argument to write output log to a file
#87373
Conversation
main/main.cpp
Outdated
if (FileAccess::get_create_func(FileAccess::ACCESS_USERDATA) && | ||
(!log_file.is_empty() || (!project_manager && !editor && GLOBAL_GET("debug/file_logging/enable_file_logging")))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--log-file
typically wouldn't be used to write to user://
, but to a pass relative to the working directory, so I'm not sure the check for ACCESS_USERDATA
makes sense / is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested an absolute path located outside user://
and it worked fine, but I guess we can check for ACCESS_FILESYSTEM
when the log path isn't empty.
Edit: Done.
Also, the logger currently fails with a crash if the file can't be written by the current user (e.g. when trying to write /log.txt
as non-root). A check needs to be added so that it prints an error and exits gracefully instead (or even keep going).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a good option to have, especially for when users struggling getting actual console output to debug issues on Windows. Would be worth checking to confirm that it works well for both the .console.exe
wrapper and the normal .exe
.
b41b473
to
70305d2
Compare
This works even if file logging is disabled in the project settings, or for the editor/project manager. `--log-file`'s value can be an absolute path or relative to the project directory (similar to existing arguments like `--write-movie`).
70305d2
to
6e5e7b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to work fine on Windows with either console.exe
or regular exe
.
Thanks! |
@Calinou thank you for quick development, is it good idea to create different proposal for optional running godot in background, reopening log file on signal and having ability to have a PID file to run it as a service. Or better just leave it as is? |
Yes, each of these items should be tracked in its own proposal. Please don't cram several unrelated items into a single proposal, as this makes it difficult to track them individually. |
This allows using a custom output path for the log file, with log rotation disabled. This works even if file logging is disabled in the project settings, or for the editor/project manager.
--log-file
's value can be an absolute path or relative to the project directory (similar to existing arguments like--write-movie
).Note that flushing stdout on print isn't forced in release builds (it still depends on the project setting's value). We may need a way to enforce this, but we already have a lot of CLI arguments exposed.