RFR: 8303682: Simplify HttpClient DebugLogger

Jaikiran Pai jpai at openjdk.org
Wed Mar 8 07:35:13 UTC 2023


On Tue, 7 Mar 2023 10:16:24 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

> The HttpClient internal DebugLogger could be simplified if its configuration was held in a record. Some of the methods in Utils that return a debug logger could also be simplified/removed. The system property that configures the debug logging could be extended to choose between System.err, System.out, System.Logger, or any of these configurations.
> Passing -Djdk.internal.httpclient.debug=true still works as before.

src/java.net.http/share/classes/jdk/internal/net/http/common/DebugLogger.java line 98:

> 96:         public LoggerConfig withLogLevel(Level logLevel) {
> 97:             return new LoggerConfig(outLevel, errLevel, logLevel);
> 98:         }

To avoid shadowing, do you think we could rename the method params of these 3 methods to `newErrLevel`, `newOutLevel` and `newLogLevel`? If you prefer, the current form, that's fine too.

src/java.net.http/share/classes/jdk/internal/net/http/common/DebugLogger.java line 103:

> 101:         public static final LoggerConfig STDERR = new LoggerConfig(Level.OFF, Level.ALL, Level.OFF);
> 102:         /** Logs on {@link System#out} only, does not forward to System.Logger **/
> 103:         public static final LoggerConfig STDOUT = new LoggerConfig(Level.OFF, Level.ALL, Level.OFF);

This looks like an oversight. I think this should have been:

new LoggerConfig(Level.ALL, Level.OFF, Level.OFF);

-------------

PR: https://git.openjdk.org/jdk/pull/12900


More information about the net-dev mailing list