MySQL Forums
Forum List  »  Connector/Python

Re: Unable to log to a file executing infinite loops while polling data from python-telegram-bot
Posted by: pavan hnk
Date: July 20, 2022 07:06AM

I have partially resolved...

obviously i had inserted before code for logging, but i have simplied the code to have your opinion. Now i'm logging into a file (and see also logs on the console), but it don't catch all exeptions...

With a function (like "anothercommand"), who calls a second one (gpio setup for automation), i have an error logged to the console, but NOT in the file (related to an OUT assignment on an already assigned gpio pin).

Here is the python(https://hkrtrainings.com/python-training-in-hyderabad)code i'm running, outside the main def:

# create logger
logger = logging.getLogger()
logger.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s | %(levelname)s | %(message)s')
stdout_handler = logging.StreamHandler(sys.stdout)
stdout_handler.setLevel(logging.DEBUG)
stdout_handler.setFormatter(formatter)
file_handler = logging.FileHandler('logs.log')
file_handler.setLevel(logging.DEBUG)
file_handler.setFormatter(formatter)
logger.addHandler(file_handler)
logger.addHandler(stdout_handler)

Options: ReplyQuote


Subject
Written By
Posted
Re: Unable to log to a file executing infinite loops while polling data from python-telegram-bot
July 20, 2022 07:06AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.