I hosted my python application using flask. My script has two functions, depends on the input data it will decide the method, for each method I am writing a different log file.
My code looks like this,
my_flask.py
if input_data=="one":
method_one()
else:
method_two()
"""my functions"""
def method_one():
logging.basicConfig(filename="method_one.log",level=logging.DEBUG,format="%(asctime)s:%(message)s")
s="performing method one"
logging.debug(s)
def method_two():
logging.basicConfig(filename="method_two.log",level=logging.DEBUG,format="%(asctime)s:%(message)s")
s="performing method two"
logging.debug(s)
when I access this method at the very first time, if the first input_data is "one"
then log is writing to method_one.log
If I access method_two() when the input_data !="one", still the s
is writing to method_one.log file
all the logs are logged based on which method is calling first.
how to handle this to write both the log files based on the condition, please help. Thanks in advance!