JakeWharton / timber

A logger with a small, extensible API which provides utility on top of Android's normal Log class.
https://jakewharton.github.io/timber/docs/5.x/
Apache License 2.0
10.44k stars 961 forks source link

Expensive to filter on package name and priority #217

Open gladed opened 7 years ago

gladed commented 7 years ago

Goal: allow a Tree subclass that can filter by package name at different priority levels for each.

Today, a Tree subclass can return null based on the fully qualified name of the calling class, and then isLoggable can be overridden to return false if the tag is null.

But then if you also want to filter based on priority on a per-package basis, it's too late. By the time isLoggable() is called, you've already calculated and trimmed down the tag, losing the package name. So you would have to extract the caller's full class name a second time.

Could Tree.getTag() (and correspondingly DebugTree.createStackElementTag) receive the priority as a parameter, so the filtering decision could be made in a single place?

By default, Tree.getTag(int priority) would fall back to Tree.getTag() for a fully backwards-compatible solution.

If this is acceptable I can generate a pull request.

jeffypooo commented 7 years ago

@gladed have you pursued this?

gladed commented 7 years ago

Not yet, but if a maintainer greenlights it I would be happy to.