If a LogStreamImpl can be constructed from a LogMessageImpl, then we get non-interleaving streaming logs and xml logs (because xmlStream can be created from outputStream, which LogStreamImpl is).
This enables UL to replace two patterns found in the logging framework:
ttyLocker + (x)tty
Instead of taking the global tty lock in order to ensure non-interleaving logs we can now make a NonInterleavingLogstream and pass that around to various print_on(outputStream*) functions.
stringStream + outputStream*
In order to avoid taking the lock and being able to take arbitrary output streams a stringStream is created and finally printed through print_raw(ss.as_string()). This however requires a ResourceMark, which NonInterleavingLogStream does not require.
This enables UL to replace two patterns found in the logging framework:
ttyLocker + (x)tty
Instead of taking the global tty lock in order to ensure non-interleaving logs we can now make a NonInterleavingLogstream and pass that around to various print_on(outputStream*) functions.
stringStream + outputStream*
In order to avoid taking the lock and being able to take arbitrary output streams a stringStream is created and finally printed through print_raw(ss.as_string()). This however requires a ResourceMark, which NonInterleavingLogStream does not require.