ArcPy-Logging Documentation#
ArcPy-Logging is a succinct project providing tight integration of ArcPy messaging into Python logging using
standard Python logging. If all you want is a quick logging object, grab the get_logger() method. If you
want to create your own logger, use the ArcpyHandler object.
arcpy_logging#
|
Logging message handler capable of routing logging through ArcPy AddMessage, AddWarning and AddError methods. |
|
Get Python |
|
Helper function facilitating outputting a |
- class arcpy_logging.ArcpyHandler(level=10)[source]#
Logging message handler capable of routing logging through ArcPy AddMessage, AddWarning and AddError methods. DEBUG and INFO logging messages are be handled by the AddMessage method. WARNING logging messages are handled by the AddWarning method. ERROR and CRITICAL logging messages are handled by the AddError method.
Basic use consists of the following.
logger = logging.getLogger('arcpy-logger') logger.setLevel('INFO') ah = ArcpyHandler() logger.addHandler(ah) logger.debug('nauseatingly detailed debugging message') logger.info('something actually useful to know') logger.warning('The sky may be falling') logger.error('The sky is falling.) logger.critical('The sky appears to be falling because a giant meteor is colliding with the earth.')
Initializes the instance - basically setting the formatter to None and the filter list to empty.
- arcpy_logging.get_logger(logger_name='arcpy-logger', log_level='INFO', logfile_pth=None, propagate=False)[source]#
Get Python
Loggerconfigured to provide stream, file or, if available, ArcPy output. The way the method is set up, logging will be routed through ArcPy messaging usingArcpyHandlerif ArcPy is available. If ArcPy is not available, messages will be sent to the console using aStreamHandler. Next, if thelogfile_pathis provided, log messages will also be written to the provided path to a logfile using aFileHandler.Valid
log_levelinputs include:DEBUG- Detailed information, typically of interest only when diagnosing problems.INFO- Confirmation that things are working as expected.WARNINGorWARN- An indication that something unexpected happened, or indicative of some problem in the near future (e.g. ‘disk space low’). The software is still working as expected.ERROR- Due to a more serious problem, the software has not been able to perform some function.CRITICAL- A serious error, indicating that the program itself may be unable to continue running.
- Parameters:
logger_name (
Optional[str]) – Name for logger. Default is ‘arcpy-logger’.log_level (
Union[str,int,None]) – Logging level to use. Default is ‘INFO’.logfile_pth (
Union[Path,str,None]) – Where to save the logfile.log if file output is desired.propagate (
bool) – Whether to propagate message up to any parent loggers. Defaults toFalseto avoid repeated messages to ArcPy.
# assuming part of python module logger = get_logger(__name__) logger.debug('nauseatingly detailed debugging message') logger.info('something actually useful to know') logger.warning('The sky may be falling') logger.error('The sky is falling.) logger.critical('The sky appears to be falling because a giant meteor is colliding with the earth.')
- Return type:
- arcpy_logging.log_pandas_df(logger, pandas_df, title, line_tab_prefix='\\t\\t')[source]#
Helper function facilitating outputting a
Pandas DataFrameinto a logfile. This typically is used for including descriptive statistics in logfile outputs.- Parameters:
- Return type: