(Aug-16-2020, 02:47 PM)Mekala Wrote: How can I create a new handler (not adding) on each iteration?
import my_log targets = ["a", "b", "c"] for target in targets: my_log.logger.info(f"Log file: {target}")So now hide boilerplate code as it not look nice mixed in with other code.
Or better use Loguru
from loguru import logger logger.add("loop.log", rotation="1 week") targets = ["a", "b", "c"] for target in targets: logger.info(f"Log file: {target}")