RFR: 8152635: Create a UL class to represent a Log + Level combination
Marcus Larsson
marcus.larsson at oracle.com
Tue Mar 29 14:51:16 UTC 2016
Hi Stefan,
On 03/29/2016 03:46 PM, Stefan Karlsson wrote:
> Hi all,
>
> Please review this patch to introduce a Unified Logging class to
> describe a combination of a tagset and a log level.
>
> http://cr.openjdk.java.net/~stefank/8152635/webrev.01
The change looks good, but there's a small issue with the test.
Test_logtarget_off breaks if you run with logging configured on other
outputs than stdout, so for example "java -XX:+ExecuteInternalVMTests
-Xlog:all=trace:trace.log -version" should fail that test. The
TestLogSavedConfig class only saves & clears the configuration for
stdout, and leaves any other outputs untouched, which means that the
assert(!log.is_enabled(), "assert") will fail since the log is enabled
for the trace.log output.
Thanks,
Marcus
> https://bugs.openjdk.java.net/browse/JDK-8152635
>
> The patch is applied on top of the patch in:
> http://mail.openjdk.java.net/pipermail/hotspot-dev/2016-March/022302.html
>
> With this class we could write code as:
> LogTarget(Debug, gc, heap) log;
> if (log.is_enabled()) {
> log.print(...);
> log.print(...);
> ... = log.stream();
> }
>
> instead of the current model:
> Log(gc, heap) log;
> if (log.is_debug()) {
> log.debug(...)
> log.debug(...)
> ... = log.debug_stream():
> }
>
> The LogTarget class/macro ensures that we only mention the log level
> once, so that we don't accidentally log to the wrong level. The
> previous version forces the coder to repeat 'debug' four times.
>
> One example where the wrong log level has been used:
> https://bugs.openjdk.java.net/browse/JDK-8152962
>
> I've converted one function in compactibleFreeListSpace.cpp to show
> how to use the new class.
>
> Test: new internal vm test, jprt
>
> Thanks,
> StefanK
More information about the hotspot-dev
mailing list