You can simply put your piece of registration code in the model definition file, models/db.pyor in your controller controllers/default.pyas follows:
with open("mylog.log", "at") as f:
f.write(repr(request))
def index():
or, if you need functions or classes that need to be defined:
def my_log(request):
with open("mylog.log", "at") as f:
f.write(repr(request))
my_log(request)
def index():
Of course, repr(request)this is not how you want it, but you get the idea: from there you can record any information that you like before calling the controllers (they are simply defined at this stage).
The server already supports logging in the root directory, in httpserver.log.
source
share