I need to show logging messages while debugging what should I do to show messages with the code like this:
logs.out("Here are the error messages")
logs.clear()
I need to show logging messages while debugging what should I do to show messages with the code like this:
logs.out("Here are the error messages")
logs.clear()
You should be using the logging module. Here is an example:
import logging
logging.debug('debug message')
logging.info('information message')
logging.warning('A warning message')
logging.error('Error Description')
logging.critical('Critical messages should be here')
If you prefer to just output some common text for logging then you can opt in the print()
function of Python or else of you want to log like the proper way that it should be then you can use the logging
API provided by the Python itself as a library.
`
import logging
logging.basicConfig(filename='example.log', level=logging.debug)
logging.debug("Debugging")
`