Skip to content

Replacing calls to Exception#printStackTrace() with Java logging.#139

Merged
komamitsu merged 3 commits intomsgpack:masterfrom
benjamin-bader:no-exception-printing
Dec 7, 2014
Merged

Replacing calls to Exception#printStackTrace() with Java logging.#139
komamitsu merged 3 commits intomsgpack:masterfrom
benjamin-bader:no-exception-printing

Conversation

@benjamin-bader
Copy link
Copy Markdown

This will keep output cleaner, especially in Android where logging and stdout are mixed.

This will keep output cleaner, especially in Android where logging and stdout are mixed.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm puzzled by this formatting; the file itself seems to have proper indentation. Perhaps my local git configuration is to blame...

@oza
Copy link
Copy Markdown
Member

oza commented Oct 2, 2014

Thanks for your contribution, @benjamin-bader. It looks good to me. @komamitsu, could you check this issue?

@komamitsu
Copy link
Copy Markdown
Member

@benjamin-bader I noticed that the original e.printStackTrace() is outputted regardless of the log level. But in your change, the stack trace is hidden if the log level is more than FINE.

Also, we can output the stack trace of a Throwable using java.util.logging.Logger#log(java.util.logging.Level, java.lang.String, java.lang.Throwable). So maybe we don't need to create org.msgpack.util.Exceptions.

Originally, that error message is important and I think we should've outputted it as a higher log level with its stack trace...

After all, something like the following code seems better to me. What do you think?

    } catch (SecurityException e) {
        LOG.log(Level.WARNING, "Cannot append a search path of classloader", e);

@benjamin-bader
Copy link
Copy Markdown
Author

@komamitsu Sounds good, thank you for the feedback. I'll fix and update today.

Additionaly, increase log level of exceptions from FINE to WARNING.
komamitsu added a commit that referenced this pull request Dec 7, 2014
Replacing calls to `Exception#printStackTrace()` with Java logging.
@komamitsu komamitsu merged commit 8461d9d into msgpack:master Dec 7, 2014
@komamitsu
Copy link
Copy Markdown
Member

@benjamin-bader Sorry for my delay and thanks for your contribution!

@benjamin-bader
Copy link
Copy Markdown
Author

Thank you @komamitsu! I had assumed this section of the codebase was obsolete in the upcoming 0.7 release - glad to hear that this may still be useful.

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.

3 participants