Using Logging correctly in python

My code looks like this. It is for image reshuffling in a couple of folders. Please assume that I have made all the required imports correctly. logging.basicConfig(filename = ‘make_folders.log’, filemode= ‘w’, level=logging.INFO, format=’%(asctime)::%(message)s’) def get_path_list(directory: str) -> list: """ Get a list of absolute paths of all the files in the directory. :param directory: Path… Read More Using Logging correctly in python

Log everything from every module except one third party module

I have a main.py: import logging, sys logging.basicConfig( level=logging.DEBUG, handlers=[logging.FileHandler("test.log"), logging.StreamHandler(sys.stdout)] ) # log everything to file and stdout logger = logging.getLogger("main") logger.info("hello main!") import thirdparty_module thirdpary_module.foo() import my_submodule1 which imports my_submodule1, my_submodule2 … my_submodule9 that log a few things in DEBUG: import logging logger = logging.getLogger("my_submodule1") logger.debug("my_submodule1 debug test") and a third party module… Read More Log everything from every module except one third party module

Python logger not working when I run package through __main__.py

I have a python package that I use for data preprocessing which I usually run through a Makefile. I want to run it like so: python3 -m utils.features, so that’s why I created __main__.py. However, if I run it like this (instead of python3 -m utils.features.build_features) all the loggers stop producing output, both defined in… Read More Python logger not working when I run package through __main__.py