8000
logging should use named logger rather than root logger #240
Labels
Hi,
I'm plotting maps with cartopy and use the GSHHS maps as background. From there I get warnings like:
WARNING:root:Possible issue encountered when converting Shape #95 to GeoJSON: Shapefile format requires that polygons contain at least one exterior ring, but the Shape was entirely made up of interior holes (defined by counter-clockwise orientation in the shapefile format). The rings were still included but were encoded as GeoJSON exterior rings instead of holes.
After some search I found out that these warnings are from shapefile.py, which uses the root-logger as
logger.warning
whenever a problem occurs. Currently, I have to suppress the root-logger to suppress the warning, i.e.As a library, it would make the users life easier if a named logger rather than the root logger would be used as suggested by the logging 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:
Then a user (or the GSHHS library provider) could suppress the specific warnings as
logging.getLogger('shapefile').setLevel(logging.ERROR)
Best regards,
Heiko
The text was updated successfully, but these errors were encountered: