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

Replace e.printStackTrace() with Log.e(TAG, "Error on ...", e); #2755

Open
EmmanuelMess opened this issue Aug 28, 2021 · 9 comments
Open

Replace e.printStackTrace() with Log.e(TAG, "Error on ...", e); #2755

EmmanuelMess opened this issue Aug 28, 2021 · 9 comments
Assignees
Labels
Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. Issue-Easy (good first issue) Beginners welcome! Issues with relative low difficulty. Issue-Task (low) This isn't a bug, but should be dealt with.

Comments

@EmmanuelMess
Copy link
Member

Replace e.printStackTrace() with Log.e(TAG, "Error on ...", e);

@EmmanuelMess EmmanuelMess added Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. Issue-Easy (good first issue) Beginners welcome! Issues with relative low difficulty. Issue-Task (low) This isn't a bug, but should be dealt with. labels Aug 28, 2021
@HoussemNasri
Copy link
Contributor

I found 174 occurrences of printStackTrace(), I am thinking of adding helper methods to LogHelper for future use, otherwise I'll have to add private static final TAG = ... for each class, @EmmanuelMess what do you think?

/**
* Helper method to log exceptions
*
* @param object the object where the exception was caught, used to retrieve the class name
* @param ex     the exception
*/
public static void e(Object object, Exception ex) {
      Log.e(object.getClass().getSimpleName(), ex.toString());
}

@VishalNehra
Copy link
Member

This make a whole lot of sense actually. I was already planning to have a form of abstraction over the logging. So that we can come to know of the silent errors from users, not just crash reports.
With this we can implement logic to- say, append logs in a txt file and keep it as reference for user reports.

@EmmanuelMess
Copy link
Member Author

I would see if there is a library for this, that already does this.

@EmmanuelMess
Copy link
Member Author

EmmanuelMess commented Sep 16, 2021

@HoussemNasri this implementation could lead to leaking of parent class instance if used in anonymous objects (like lambdas)

@puranjayK
Copy link

@EmmanuelMess I would like to work on this issue. Could you please assign it to me?

@ilihas786
Copy link

i want to contribute i am begineer in open source

@VishnuSanal
Copy link
Member

@puranjayK Please confirm if @ilihas786 can take this over.

@ilihas786 We'll assign it to you if there's no reply or if they confirm that they're no longer working on this.

@nilerudra
Copy link

Is this issue open?

@VishnuSanal
Copy link
Member

@VishalNehra is this still valid for we're using slf4j now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. Issue-Easy (good first issue) Beginners welcome! Issues with relative low difficulty. Issue-Task (low) This isn't a bug, but should be dealt with.
Projects
None yet
Development

No branches or pull requests

7 participants