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 printStackTrace() in OpenHtmlGvtFont with proper logging #715

Closed
tfo opened this issue Jun 2, 2021 · 1 comment
Closed

Replace printStackTrace() in OpenHtmlGvtFont with proper logging #715

tfo opened this issue Jun 2, 2021 · 1 comment

Comments

@tfo
Copy link

tfo commented Jun 2, 2021

Hello,

While analyzing a problem in our system where we use the openhtmltopdf re noticed that our logs are heavily polluted with stacktraces that are created through a e.printStackTrace() in in the OpenHtmlGvtFont class. Because of our setup we are not able to redirect STDOUT and STDERR into our logging framework. Although the corresponding exception should not happen (according to the code) it would be great if it would be logged using a proper logger and not STDERR.

`
public OpenHtmlGvtFont(byte[] fontBytes, GVTFontFamily family, float size, Float fontWeight, Float fontStyle) throws FontFormatException {
Font font;

	try {
		font = Font.createFont(Font.TRUETYPE_FONT, new ByteArrayInputStream(fontBytes)).deriveFont(toFontWeight(fontWeight) | toStyle(fontStyle) , size);
	} catch (IOException e) {
		// Shouldn't happen
		e.printStackTrace(); // Although it should not happen, it would be great to use a logger here.
		font = null;
	}

	this.baseFont = font;
	this.fontFamily = family;
}

`

@syjer
Copy link
Contributor

syjer commented Jun 3, 2021

hi @tfo , you are right, I've submitted a PR for fixing this issue ( #716 ).

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

2 participants