Closed nichollsh closed 2 months ago
This should only be done once https://github.com/FormingWorlds/JANUS/pull/52 is merged.
Imo it is a bad idea to step away from the widely used convention of using __name__
for the logger name. You can use this to filter and handle logging calls on a per-module basis. By using the same name for every logging call, you lose this information, making it more difficult to identity which part of the code the log comes from.
See also the python documentation:
A good convention to use when naming loggers is to use a module-level logger, in each module which uses logging, named as follows:
logger = logging.getLogger(__name__)
This means that logger names track the package/module hierarchy, and it’s intuitively obvious where events are logged just from the logger name.
To avoid issues with matplotlib, the idea is to set up the logger before importing matplotlib. Matplotlib seems to set up the root logger as well and this could interfere: https://stackoverflow.com/a/51529172
You can alse set or squelch the warnings from matplotlib through the logger library.
Current plan is to use the __name__
method for setting up logs in each module, and then disabling logging from imported modules through the following method:
https://stackoverflow.com/a/71193599
logger_blocklist = [
"fiona",
"rasterio",
"matplotlib",
"PIL",
]
for module in logger_blocklist:
logging.getLogger(module).setLevel(logging.WARNING)
For consistency with JANUS, the default logger name should be changed to "FWL" rather than "PROTEUS", and this name should be encouraged across all of the FWL programs currently under development.
This means that, when used together, these programs can use the same logger instance without having to do any ugly hacks.