Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added logger decorator to all functions #841

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

Daniel-olaO
Copy link

close #838

@ma-sadeghi
Copy link
Member

@Daniel-olaO I prefer the attribute approach. Adding decorators to every function, although is more explicit, but is less maintainable.

@ma-sadeghi
Copy link
Member

(especially since it's just for logging, if it were for something more substantial like just-in-time compilation, adding the decorator to function header would make sense since developers should really know what's going on, whereas for logging, the passive approach seems more sensible to me), but let's wait for @jgostick to weigh in before you make the changes to not waste your time. Also, I really appreciate your efforts :)

@Daniel-olaO
Copy link
Author

okay thanks @ma-sadeghi

@jgostick
Copy link
Member

jgostick commented Jun 2, 2023

There are pros/cons for both approaches. The decorator is nice because it let's us explicitly pick and choose which functions to emit the logger message from. I think @Daniel-olaO has gone a bit overboard by putting them on ALL the functions. If we just do it on the really heavy functions, then I think the maintenence would not be too bad, AND the approach would be explicit. On the otherhand, @ma-sadeghi's module attribute approach only requires code in ONE place, which is really tight. The downside of this approach to me is that it also represents a maintenence issue in the future when we have to ask ourselves WTF these logger messages are coming from!

@Daniel-olaO
Copy link
Author

hI @jgostick, why not write a list of functions you want me to add the logger decorator

@ma-sadeghi
Copy link
Member

Another perspective: do we even need this? Profiling should be done by the user, and there are many great tools that exactly does this for us: scalene, memprofiler, etc. They provide per function runtime, memory usage, and even nice flame graphs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add logger.info to beginning and end of each function
3 participants