https://github.com/ctoth/area_reader/blob/3297b88/area_reader/__init__.py#L3-L5
import logging
logger = logging.getLogger('area_reader')
logging.basicConfig(level=logging.INFO)
import area_reader configures the root logger of whatever application imports it — a library should never call basicConfig at import time. Combined with the per-section logger.info("Processing section %s" % section_name) in load_sections, any consumer gets stderr chatter for every section of every file it parses:
INFO:area_reader:Processing section area
INFO:area_reader:Processing section helps
INFO:area_reader:Processing section mobiles
...
and their own subsequent basicConfig call becomes a no-op because the root logger already has a handler.
Suggested fix, the standard library-logging pattern:
- drop
logging.basicConfig(...);
- optionally
logger.addHandler(logging.NullHandler());
- demote the per-section "Processing section" lines to
logger.debug (there are already debug calls for per-record progress; INFO-per-section is the same category of trace);
- keep
%-style lazy formatting (logger.info("Processing section %s", name)) instead of pre-formatted strings, matching the other call sites.
https://github.com/ctoth/area_reader/blob/3297b88/area_reader/__init__.py#L3-L5
import area_readerconfigures the root logger of whatever application imports it — a library should never callbasicConfigat import time. Combined with the per-sectionlogger.info("Processing section %s" % section_name)inload_sections, any consumer gets stderr chatter for every section of every file it parses:and their own subsequent
basicConfigcall becomes a no-op because the root logger already has a handler.Suggested fix, the standard library-logging pattern:
logging.basicConfig(...);logger.addHandler(logging.NullHandler());logger.debug(there are alreadydebugcalls for per-record progress; INFO-per-section is the same category of trace);%-style lazy formatting (logger.info("Processing section %s", name)) instead of pre-formatted strings, matching the other call sites.