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

Provide the listener with this, if any #53

Open
oakkitten opened this issue Feb 11, 2024 · 0 comments
Open

Provide the listener with this, if any #53

oakkitten opened this issue Feb 11, 2024 · 0 comments

Comments

@oakkitten
Copy link

This project seems to be well-suited for method call logging in debug builds. However, one of the drawbacks for this use case is that the listener is only provided with the function name and its arguments. While the fact that the function name is fully qualified helps with differentiating between different functions of the same name, without access to this:

  • It is not possible to differentiate between method calls on different objects of the same type. For instance, I have several Fragments in my app that are shown alongside each other, and I would like to know on which one of those the method was called.

  • It is not feasible to have custom loggers for objects.

I imagine that both of these problems could be solved with providing this to the listener. For instance, I could have an interface such as LoggerProvider { val logger: Logger }, that I could be slapping onto instances and companion objects, and in the listener I would be checking whether thisRef is LoggerProvider and act accordingly.

(I wonder if something similar could be done for file-level methods. Per-file loggers sounds like a great idea!)

(Maybe provide a list of this-es in case there are multiple?)

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

No branches or pull requests

1 participant