You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by kinow <gi...@git.apache.org> on 2018/02/05 11:13:33 UTC
[GitHub] commons-imaging pull request #35: IMAGING-154 Removed Debug class
GitHub user kinow opened a pull request:
https://github.com/apache/commons-imaging/pull/35
IMAGING-154 Removed Debug class
Removed the `Debug` and `ImageDump` classes. Also removed methods with the `verbose` parameter, as well as any `System.out.println`'s. Tried to keep the change to a minimum, but given the extent of its use, I believe the pull request diff will be a bit long.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/kinow/commons-imaging IMAGING-154
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/commons-imaging/pull/35.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #35
----
commit 0e218c63086ce0e0ee9270d6099cc9466a0cda4c
Author: Bruno P. Kinoshita <br...@...>
Date: 2018-02-05T11:10:25Z
IMAGING-154 Removed Debug class
----
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging issue #35: IMAGING-154 Removed Debug class
Posted by kinow <gi...@git.apache.org>.
Github user kinow commented on the issue:
https://github.com/apache/commons-imaging/pull/35
`changes.xml` updated. Last commit contains the word-trick to close the pull request. Once merged, everything should be correct, just need to update JIRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging pull request #35: IMAGING-154 Removed Debug class
Posted by kinow <gi...@git.apache.org>.
Github user kinow commented on a diff in the pull request:
https://github.com/apache/commons-imaging/pull/35#discussion_r210523866
--- Diff: src/main/java/org/apache/commons/imaging/formats/psd/PsdHeaderInfo.java ---
@@ -45,9 +50,14 @@ public PsdHeaderInfo(final int version, final byte[] reserved, final int channel
}
public void dump() {
- final PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, Charset.defaultCharset()));
- dump(pw);
- pw.flush();
+ try (StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw)) {
--- End diff --
@garydgregory I'm not sure how to refactor it. If you look at the `dump` methods, you will see they are scattered all over the place, but there's no `@Override` tags, as they are not defined in any parent class.........
I am ignoring this for now, as we could have users coming from Sanselan using these methods. But for 2.x I would like to tackle this problem and either remove the `dump` methods, or have a design with a base class defining the signature of these methods.
That would give us a place to implement a method that could remove this duplication.
The alternative that I see here, is to add a `Util` class to the project, and add a method to remove the duplication. But I am not very fond of `Util` classes for a case like this one (where a proper design would remove the need for it).
I hope this makes sense. Do you think we could ignore this duplication for now, and fix in the upcoming (hopefully soon) next releases?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging issue #35: IMAGING-154 Removed Debug class
Posted by andreasrosdal <gi...@git.apache.org>.
Github user andreasrosdal commented on the issue:
https://github.com/apache/commons-imaging/pull/35
I hope we can get a 1.0 release of Commons Imaging very soon. Thanks for working towards this!
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging issue #35: IMAGING-154 Removed Debug class
Posted by kinow <gi...@git.apache.org>.
Github user kinow commented on the issue:
https://github.com/apache/commons-imaging/pull/35
Agreed on not using INFO level @sebbASF & @garydgregory .
Moved what was in FINE to FINEST level. And moved what was in INFO to FINE.
My plan for the web site information is to have the following information, just with more complete information:
>we are using jul
>
>exceptions will be logged to SEVERE
>a more verbose output is available at FINE
>nformation for debug and troubleshooting is available at FINEST
@garydgregory addressed your comments about code duplication with comments above.
If there are no other objections here or in the mailing list, I am planning to merge this work next weekend (that should give plenty of time for others to review, and time for me to try to work on the **last** blocking issue for 1.0: documentation!
Thanks!
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging pull request #35: IMAGING-154 Removed Debug class
Posted by sebbASF <gi...@git.apache.org>.
Github user sebbASF commented on a diff in the pull request:
https://github.com/apache/commons-imaging/pull/35#discussion_r210327438
--- Diff: src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java ---
@@ -327,7 +331,7 @@ private BmpImageContents readImageContents(final InputStream is,
switch (bhi.compression) {
case BI_RGB:
if (verbose) {
--- End diff --
Seems to me it would be better to use the log-level alone to control what is being logged.
So the verbose flag would become a log-level instead.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging issue #35: IMAGING-154 Removed Debug class
Posted by sebbASF <gi...@git.apache.org>.
Github user sebbASF commented on the issue:
https://github.com/apache/commons-imaging/pull/35
Agreed
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging pull request #35: IMAGING-154 Removed Debug class
Posted by kinow <gi...@git.apache.org>.
Github user kinow commented on a diff in the pull request:
https://github.com/apache/commons-imaging/pull/35#discussion_r210521304
--- Diff: src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java ---
@@ -327,7 +331,7 @@ private BmpImageContents readImageContents(final InputStream is,
switch (bhi.compression) {
case BI_RGB:
if (verbose) {
--- End diff --
You are both correct @garydgregory , @sebbASF .
I tried to remove the flags `DEBUG` or `isDebug()` or `getDebug()` by `LOGGER.isLoggable(Level.FINE)`, but forgot to do the same for `verbose` using the `INFO` level (wonder if we should use FINEST for debug, and FINE for the verbose messages...)
Will just log to info. I believe we can assume that
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging issue #35: IMAGING-154 Removed Debug class
Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on the issue:
https://github.com/apache/commons-imaging/pull/35
+1 to merge. I'd prefer to see a 1.0-alpha1 or 1.0-beta1 released next instead of 1.0 but I'm not RM'ing this one... ;-)
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging issue #35: IMAGING-154 Removed Debug class
Posted by kinow <gi...@git.apache.org>.
Github user kinow commented on the issue:
https://github.com/apache/commons-imaging/pull/35
Thanks @andreasrosdal ! I still have some more development bandwidth this month, so hopefully it will be merged this weekend, and I will find a way to squeeze in a few more hours to finish the website updates. Then we will be ready to call a 1.0 vote again.
@garydgregory ping. I left a few replies to your comments. I think that'd be OK to merge as is, unless you prefer to address the exception handling & code duplication now.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging pull request #35: IMAGING-154 Removed Debug class
Posted by kinow <gi...@git.apache.org>.
Github user kinow commented on a diff in the pull request:
https://github.com/apache/commons-imaging/pull/35#discussion_r210524716
--- Diff: src/main/java/org/apache/commons/imaging/icc/IccTag.java ---
@@ -73,11 +76,12 @@ private IccTagDataType getIccTagDataType(final int quad) {
}
public void dump(final String prefix) throws ImageReadException, IOException {
- final PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, Charset.defaultCharset()));
-
- dump(pw, prefix);
-
- pw.flush();
+ try (StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw)) {
--- End diff --
This was intentional.
The previous code contains the `throws IOException` (while the other methods don't) -> https://github.com/apache/commons-imaging/blob/d2ec76bd10f30c39ae5180ede1254908e76045f0/src/main/java/org/apache/commons/imaging/icc/IccTag.java#L75
Should we make them all the same, catching and logging, instead of throwing the IOException? As this is a `dump` method, not used by another method such as `toString()`, I think the impact on end users should be minimal.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging pull request #35: IMAGING-154 Removed Debug class
Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on a diff in the pull request:
https://github.com/apache/commons-imaging/pull/35#discussion_r210287763
--- Diff: src/test/java/org/apache/commons/imaging/formats/jpeg/exif/WriteExifMetadataExampleTest.java ---
@@ -27,7 +27,7 @@
import org.apache.commons.imaging.formats.jpeg.JpegImageParser;
import org.apache.commons.imaging.formats.tiff.TiffField;
import org.apache.commons.imaging.formats.tiff.TiffImageMetadata;
-import org.apache.commons.imaging.util.Debug;
+import org.apache.commons.imaging.internal.Debug;
--- End diff --
I like the package name :-)
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [GitHub] commons-imaging issue #35: IMAGING-154 Removed Debug class
Posted by Gary Gregory <ga...@gmail.com>.
On Thu, Aug 23, 2018 at 7:58 AM kinow <gi...@git.apache.org> wrote:
> Github user kinow commented on the issue:
>
> https://github.com/apache/commons-imaging/pull/35
>
> Thanks @garydgregory ! No objection for a 1.0-alpha1, then wait a
> couple of months or a bit more perhaps for user feedback. I assume this
> 1.0-alpha1 would make all the way to maven central?
>
Yes, just like any other release.
Gary
>
>
> ---
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
[GitHub] commons-imaging issue #35: IMAGING-154 Removed Debug class
Posted by kinow <gi...@git.apache.org>.
Github user kinow commented on the issue:
https://github.com/apache/commons-imaging/pull/35
Thanks @garydgregory ! No objection for a 1.0-alpha1, then wait a couple of months or a bit more perhaps for user feedback. I assume this 1.0-alpha1 would make all the way to maven central?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging pull request #35: IMAGING-154 Removed Debug class
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/commons-imaging/pull/35
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging pull request #35: IMAGING-154 Removed Debug class
Posted by kinow <gi...@git.apache.org>.
Github user kinow commented on a diff in the pull request:
https://github.com/apache/commons-imaging/pull/35#discussion_r210546814
--- Diff: src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java ---
@@ -327,7 +331,7 @@ private BmpImageContents readImageContents(final InputStream is,
switch (bhi.compression) {
case BI_RGB:
if (verbose) {
--- End diff --
Done in https://github.com/apache/commons-imaging/pull/35/commits/96b0a18e3c0ac435da85a3cf361975e2e77aa7f0
Also removed the `PARAM_KEY_VERBOSE` constant, used to include a param in a map to enable verbose. I initially put a `@deprecated` annotation, then realized this will be 1.0 of imaging, not sanselan, so removing it should be OK.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging pull request #35: IMAGING-154 Removed Debug class
Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on a diff in the pull request:
https://github.com/apache/commons-imaging/pull/35#discussion_r210286324
--- Diff: src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java ---
@@ -327,7 +331,7 @@ private BmpImageContents readImageContents(final InputStream is,
switch (bhi.compression) {
case BI_RGB:
if (verbose) {
--- End diff --
Seeing "if verbose" and then "log at the info level" is slightly confusing here. If we want to keep the 'verbose' setting then maybe the code should rename this to 'logInfo', or, should we provide a setting that contains the log level to use when 'verbose' is enabled?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging pull request #35: IMAGING-154 Removed Debug class
Posted by kinow <gi...@git.apache.org>.
Github user kinow commented on a diff in the pull request:
https://github.com/apache/commons-imaging/pull/35#discussion_r210519489
--- Diff: src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkText.java ---
@@ -42,9 +47,9 @@ public PngChunkText(final int length, final int chunkType, final int crc, final
final int textLength = bytes.length - (index + 1);
text = new String(bytes, index + 1, textLength, StandardCharsets.ISO_8859_1);
- if (getDebug()) {
- System.out.println("Keyword: " + keyword);
- System.out.println("Text: " + text);
+ if (LOGGER.isLoggable(Level.FINE)) {
--- End diff --
I went straight for `LOGGER.isDebugEnabled()` and the IDE remembered me what it actually looked like :=/
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging pull request #35: IMAGING-154 Removed Debug class
Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on a diff in the pull request:
https://github.com/apache/commons-imaging/pull/35#discussion_r210287038
--- Diff: src/main/java/org/apache/commons/imaging/formats/psd/PsdHeaderInfo.java ---
@@ -45,9 +50,14 @@ public PsdHeaderInfo(final int version, final byte[] reserved, final int channel
}
public void dump() {
- final PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, Charset.defaultCharset()));
- dump(pw);
- pw.flush();
+ try (StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw)) {
--- End diff --
This seems like duplicate code from a similar block I saw above. Should it be refactored?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging pull request #35: IMAGING-154 Removed Debug class
Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on a diff in the pull request:
https://github.com/apache/commons-imaging/pull/35#discussion_r210287176
--- Diff: src/main/java/org/apache/commons/imaging/formats/psd/PsdImageContents.java ---
@@ -40,9 +45,14 @@ public PsdImageContents(final PsdHeaderInfo header,
}
public void dump() {
- final PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, Charset.defaultCharset()));
- dump(pw);
- pw.flush();
+ try (StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw)) {
--- End diff --
Same comment as above.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging issue #35: IMAGING-154 Removed Debug class
Posted by andreasrosdal <gi...@git.apache.org>.
Github user andreasrosdal commented on the issue:
https://github.com/apache/commons-imaging/pull/35
I hope that you will publish the release to the maven central repos, since I hope to use it as a dependency.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging pull request #35: IMAGING-154 Removed Debug class
Posted by kinow <gi...@git.apache.org>.
Github user kinow commented on a diff in the pull request:
https://github.com/apache/commons-imaging/pull/35#discussion_r210549560
--- Diff: src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java ---
@@ -327,7 +331,7 @@ private BmpImageContents readImageContents(final InputStream is,
switch (bhi.compression) {
case BI_RGB:
if (verbose) {
--- End diff --
And on
>(wonder if we should use FINEST for debug, and FINE for the verbose messages...)
If you have the chance to run the tests, you will notice the huge amount of verbose messages being printed now. I believe some users could be inundated with log lines (as the INFO is enabled by default? and verbose was disabled by default)
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging pull request #35: IMAGING-154 Removed Debug class
Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on a diff in the pull request:
https://github.com/apache/commons-imaging/pull/35#discussion_r210287298
--- Diff: src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java ---
@@ -355,9 +360,14 @@ private String getValueDescription(final Object o) {
}
public void dump() {
- final PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, Charset.defaultCharset()));
- dump(pw);
- pw.flush();
+ try (StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw)) {
--- End diff --
Same comment as above.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging pull request #35: IMAGING-154 Removed Debug class
Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on a diff in the pull request:
https://github.com/apache/commons-imaging/pull/35#discussion_r210286764
--- Diff: src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkText.java ---
@@ -42,9 +47,9 @@ public PngChunkText(final int length, final int chunkType, final int crc, final
final int textLength = bytes.length - (index + 1);
text = new String(bytes, index + 1, textLength, StandardCharsets.ISO_8859_1);
- if (getDebug()) {
- System.out.println("Keyword: " + keyword);
- System.out.println("Text: " + text);
+ if (LOGGER.isLoggable(Level.FINE)) {
--- End diff --
Uhg, the JUL level names are AWFUL :=(
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging pull request #35: IMAGING-154 Removed Debug class
Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on a diff in the pull request:
https://github.com/apache/commons-imaging/pull/35#discussion_r210287591
--- Diff: src/main/java/org/apache/commons/imaging/icc/IccTag.java ---
@@ -73,11 +76,12 @@ private IccTagDataType getIccTagDataType(final int quad) {
}
public void dump(final String prefix) throws ImageReadException, IOException {
- final PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, Charset.defaultCharset()));
-
- dump(pw, prefix);
-
- pw.flush();
+ try (StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw)) {
--- End diff --
Same comment as above even though this code is slightly different - no catch clause.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[GitHub] commons-imaging issue #35: IMAGING-154 Removed Debug class
Posted by garydgregory <gi...@git.apache.org>.
Github user garydgregory commented on the issue:
https://github.com/apache/commons-imaging/pull/35
In general I do not think a library should log at INFO, only DEBUG or TRACE.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org