Should I use the print function or logging module??

Logging is the process of outputting messages from your code/script either to the terminal or mostly to a file, in order to be informed on what’s happening, it’s a great use in debugging and can be used in other situations to.

Quite a lot of programmers use the print function, which is of itself a great tool, however it becomes extremely strenous during large projects, also logging is useful when checking the status of a program, for this reason and more logging is recommended.

How to get started
In python, the logging module is preinstalled just have to import it.

It’s as simple as just...

import logging

We can then setup some little configurations of our choice. By default logging logs to the terminal, We can setup a dedicated file for logging, give a specific level of logging we want to use, and also a format output for the logging.

logging.basicConfig(filename='loggingFile.log', level=logging.DEBUG, format='%(asctime)s:%(levelname)s:%(message)s')

A full list of the options available can be gotten at the logrecord attributes here.
In order to prevent logging clashes from different modules when we import them, we can set different loggers for each module.

Read More