1
Fala, Povo!
I have a log - add_log() - add function that takes a title, status and Obs to register in a txt file along with the time.
I wonder if there is any way to get the name of the parent function in which add_log() is called.
Ex:
def Soma(a,b):
try:
return a+b
except:
add_log() #add_log recebe Soma no parâmetro mida sem precisar passar
>>> '12:09:18.3544 Soma() - OK'
import datetime
def getnow():
return str(datetime.datetime.now())[:24].split()
def add_log(media,status,obs=""):
path = '../logs/{}.txt'.format(getnow()[0])
arq = open(path,'a+')
arq.write('{} {} - {} - {}'.format(getnow()[1],media,status,obs).strip().strip('-')+'\n')
```
0