pyrosm.enable_logging

Contents

pyrosm.enable_logging#

pyrosm.enable_logging(level='INFO', to_file=None, progress=True)#

Show pyrosm’s log messages, and set how every operation shows its progress.

Attaches one handler to the pyrosm logger, writing to stderr, or to the file to_file when given, and sets the logger’s level: "INFO" (default) logs the configuration of each OSM object and a line per read with the number of features and the seconds it took; "DEBUG" adds the time of each phase of a read. Calling it again replaces the handler it attached before. pyrosm’s messages then no longer reach the root logger, so they are not shown twice when the application has configured logging too.

Parameters:
  • level (str | int) – A logging level name, such as "INFO" or "DEBUG" (any letter case), or number.

  • to_file (str | pathlib.Path, optional) – A file to append the messages to instead of writing them to stderr.

  • progress (bool | callable (default: True)) – The progress of reads, writes, crops, merges, searches for extracts, downloads and graph exports (OSM.to_graph and pyrosm.graphs) whose own progress is not given: True shows a bar on stderr (see pyrosm.OSM), False shows nothing, and a callable is called as progress(done, 100) with the percentage done, or for a download as progress(written, total) with its bytes. Without a call to this function, progress is shown as with True. enable_logging("WARNING", progress=False) turns the progress off without turning on the log messages.

Returns:

The handler attached.

Return type:

logging.Handler