AlessandroLovo / general_purpose

Set of general purpose python functions
MIT License
2 stars 0 forks source link

execution_time doesn't log to file #10

Closed AlessandroLovo closed 9 months ago

AlessandroLovo commented 9 months ago

When we decorate a function with @ut.execution_time, the information is logged using ut.logger. This means that if the decorated function is also logging something onto a file with its own logger, the execution time informations won't appear in the file.

It'd be better to pass the logger to the decorator.

AlessandroLovo commented 9 months ago

Actually I noticed that this happens only for the children of Learn2_new, but not on Learn2_new itself. I think this is due to the fact that when we inherit from Learn2_new, its logger is not the root one

AlessandroLovo commented 9 months ago

Now you can use @ut.exec_time(logger) to explicitly provide the logger. @ut.execution_time remains for backward compatibility, with its old buggy behavior.

AlessandroLovo commented 9 months ago

With this fix we have a correct logging to file, but no longer on stdout

AlessandroLovo commented 9 months ago

Nevermind, the bug was elsewhere