-1

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()
2

2 Answers 2

2

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')
Sign up to request clarification or add additional context in comments.

1 Comment

Try something like this: logging.basicConfig(filename='file.log', filemode='w', format='%(name)s - %(levelname)s - %(message)s')
0

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")

`

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.