pyprep.setup_logging#
- pyprep.setup_logging(level='info', *, stream=None, fmt='%(asctime)s [%(levelname)s] %(name)s: %(message)s')[source]#
Send pyprep’s log records to a stream, at the given level.
If your application already routes logging somewhere of its own, do not call this at all. The records will reach your handlers by propagation, and
pyprep.set_log_level()is there if you want the"INFO"ones too.- Parameters:
- level
int|str Level for the
pypreplogger, either a name (e.g."debug","WARNING") or a stdlib constant such aslogging.DEBUG. Names are case-insensitive, as inmne.set_log_level(). Defaults to"info".- streamfile-like |
None Destination for pyprep’s handler.
Nonemeanssys.stdout.- fmt
str Format string for the handler, in the style of
logging.Formatter. Defaults topyprep._logging.DEFAULT_FORMAT, which prefixes each record with a timestamp, its level, and the name of the logger it came from.
- level
- Returns:
- logger
logging.Logger The configured
pypreplogger.
- logger
Notes
To hand the output back afterwards, drop the handler again with
logging.getLogger("pyprep").handlers.clear().