UL: LogStream autoflush?

Thomas Stüfe thomas.stuefe at gmail.com
Wed Apr 25 05:40:21 UTC 2018


.. I just saw than LogStream::flush() is not even implemented and we
fall back to noop-flush in outputStream. So... yea, autoflush (or,
better, auto-cr()) in ~LogStream would be good.

On Wed, Apr 25, 2018 at 7:23 AM, Thomas Stüfe <thomas.stuefe at gmail.com> wrote:
> Hi,
>
> I ran into following problem:
>
> (metaspace.cpp)
>   LogTarget(Trace, gc, metaspace) lt;
>   if (lt.is_enabled()) {
>     LogStream ls(lt);
> ...
>     vsl->print_on(&ls);
>   }
>
> I did modify VirtualSpaceNode::print_on() to not print a trailing cr,
> since that suits my needs at other places. Then I ran into this
> assert:
>
> #  Internal Error
> (/priv/d031900/openjdk/jdk-jdk/source/src/hotspot/share/logging/logStream.cpp:36),
> pid=8827, tid=8828
> #  assert(_pos == 0) failed: still outstanding bytes in the line buffer
>
> Of course, the simple fix would here to add an ls.cr() at the end of
> the LogStream scope. But I find that clumsy: as a caller of
> VirtualSpaceNode::print_on(), why should I have care or even know if
> the called print_on() function ends with a cr() ?
>
> I also could add an ls.flush() at the end of the scope, but then, why
> should I have to think about this?
>
> The point is that LogStream() requires me to end output with a cr()
> before it dies, but as an implementator of a print function, I do not
> know how long the stream I write into lives. And as a user of
> LogStream, I do not want to have to think about this.
>
> I would it find way more convenient if LogStream would just autoflush
> at destruction time, treating an unfinished line like a finished line.
> Would that make sense to you?
>
> Kind Regards, Thomas


More information about the hotspot-runtime-dev mailing list