Util Log¶
Logging
- class dffml.util.log.DuplicateFilter[source]¶
Filter for logging only unique logs for download logger.
- dffml.util.log.create_download_logger(root_logger)[source]¶
Helper function-based context-manager to create a child logger for displaying download progress
- dffml.util.log.log_time(func)[source]¶
Decorator that can take either coroutine or normal function and log its runtime.
Examples
>>> import time >>> import asyncio >>> import logging >>> >>> logging.basicConfig(level=logging.DEBUG) >>> >>> from dffml import log_time >>> >>> @log_time ... def simple_function(): ... time.sleep(1) ... return True ... >>> >>> @log_time ... async def coroutine(): ... time.sleep(1) ... return True ... >>> >>> simple_function() True >>> >>> asyncio.run(coroutine()) True
You should see
DEBUG:dffml.util.duration_logger: coroutine took 1.0 seconds
Since logging was enabled using
basicConfig
.