-
Notifications
You must be signed in to change notification settings - Fork 554
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
Different TAGs for each Adapter #431
Comments
@thelong1EU, I think this is possible in somehow, now the Log system is custom and static, I will probably need to add new custom functions to accept dynamic TAG to the Log class. Let's keep it aside for the moment. |
In can implement it if you want and make a pull request.
…On Aug 27, 2017 11:44 AM, "Davide Steduto" ***@***.***> wrote:
@thelong1EU <https://github.com/thelong1eu>, I think this is possible in
somehow, now the Log system is custom and static, I will probably need to
add new custom functions to accept dynamic *TAG* to the Log class.
Let's keep it aside for the moment.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#431 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AI2nVjWXgdFxaQXOx45HLxU130GTfsFgks5scSxjgaJpZM4PDX8F>
.
|
@thelong1EU, I couldn't find another "quick" solution than this: Log.java public static void useTag(@Nullable String customTag) {
Log.customTag = customTag;
}
private static String getTag() {
if (customTag != null) return customTag;
StackTraceElement traceElement = new Throwable().getStackTrace()[2];
......
} Using static Activity2.java onCreate() {
Log.useTag("FlexibleAdapter2");
mAdapter = new FlexibleAdapter();
}
onDestroy() {
// Because it's static we need to restore previous value for 1st instance
Log.useTag(null); or Log.useTag("FlexibleAdapter1");
} However, this has a defect when used with Observables that receive a callback to update the list in another Activity, it will log with the latest tag unless is set/restored everytime. Another solution would be to have non-static internal Logger initialized inside with the default or from a static setter before creation. Like this: Activity2.java FlexibleAdapter.useTag("FlexibleAdapter2");
mAdapter = new FlexibleAdapter(); Anyway, the others helper classes around the Adapter won't take the custom tag! |
@thelong1EU, I opted for a mixed solution, please see the next commit in CustomTags branch. |
Perfect, thanks!
…On Sep 2, 2017 2:41 PM, "Davide Steduto" ***@***.***> wrote:
@thelong1EU <https://github.com/thelong1eu>, I opted for a mixed
solution, please see the next commit in *CustomTags* branch.
You can also see the javaDoc description of the new Logger class that now
works in collaboration with Log. Now FlexibleAdapter instances can have
custom tag and the tag reset is automatic.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#431 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AI2nVi9UmBfSoTZu01780h75nRPKS5vxks5seT78gaJpZM4PDX8F>
.
|
It will be very useful to set a tag for each adapter. This will make debugging a lot easier when you have multiple adapters.
The text was updated successfully, but these errors were encountered: