I have a simple request. I have a python file with a list of variables. I want to execute the python file and get the output of that written to the log file. What is the simple way to do this? Example: var.py has the following code
x = (10,11,12)
y = str("case when id =1 then gr8 else ok end")
z = datetime.datatime.today().strftime('%Y-%m-%d')
I want the log to show the variables resolution in the same order
x = (10,11,12)
y = 'case when id =1 then gr8 else ok end'
z = 2016-06-07
How can I accomplish this in python?
This is what I tried
# In:
import logging
# set root logger level
root_logger = logging.getLogger()
root_logger.setLevel(logging.DEBUG)
# setup custom logger
logger = logging.getLogger(__name__)
handler = logging.FileHandler('example.log')
handler.setLevel(logging.INFO)
logger.addHandler(handler)
# log
x = (10,11,12)
y = str("case when id =1 then gr8 else ok end")
logger.debug(x)
logger.debug(y)
example.log file is empty