-
Notifications
You must be signed in to change notification settings - Fork 477
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
Improve the logging implementation #88
Comments
That all sounds good. I agree :) As for who to own the root-logger. If it's supposed to be the script that calls PyBoy, I would put it in our But I would be against logging to a file per default. Firstly I think most people wouldn't need more than just a terminal output for the logging, and secondly, we would need to handle what happens when you run multiple instances ― which we do when testing. |
That's a good point--multiple instances would get messy. Since Python's logging runs at the module level (not instance), we'd have to make a special handler that prepends an instance name or something if that's going to be supported. I'm fine with not logging to a file by default. Should we still include the option to log to a file if we pass the file to |
I would just leave it out. Either the user can pipe stdout to a file through |
I've added the first two points in the new I'll close the issue for now, but I will encourage everyone to add logging if they are trying to trace out a bug in the code. If it makes sense to keep it, we'll keep it. |
In order to help isolate bugs experienced by new users, it would help to add more verbose logging that helps track the state of the emulator. However, we should also add a more control to the logging handling and printing for performance and clutter reasons, especially if users will be running it as an installed module and not a standalone emulator. (#87)
There are three items to address for this issue:
PyBoy
constructor.logging
module properly (https://docs.python.org/3.7/library/logging.html). More on this below.So the logging module has a pretty tidy setup: Each module gets its own hierarchical
Logger
vialogging.getLogger(__name__)
instead of importing a global instance. This way the format string can be modified to include the module that created the message, and different modules can be filtered out for specific debugging. For example, we could silence all messages coming from the entirebotsupport
module and allow messages from thecartridge
module while developing new MBC support.Also the root
Logger
should be owned by... eitherpyboy
ormain.py
or whatever script happens to callpyboy
, I'm actually not sure. I think the best case here would be forpyboy
to have a setting/kwarg that could direct its handler print to the terminal and/or save to a file. Saving to a file (or nothing) should be the default, probably, and the caller (main.py
or user code) can be in charge of the actual root logger that can be configured to print at the desired level. Both of these would be active, sopyboy
could automatically log to a file whilemain.py
optionally prints messages.The text was updated successfully, but these errors were encountered: