Hi all,

Since a little more than a month I have been working on a bytecode
conversion tool that converts all logging API calls to chains of
`LogBuilder` calls with integrated location information.

The most complex API to convert was obviously Log4j2 API, with almost
400 methods to support. This is practically done[1], except method
references like `list.forEach(logger::info)` and two families of
methods: `traceEntry` and `traceExit`.

While it is possible to deal with them without modification to the
APIs, it would simplify the logic (especially for `traceEntry`) if we
add:

* a method `LogBuilder#logAndGet(Supplier<Message>)` that returns the
logged message or null if nothing was logged. This is the semantics of
`traceEntry`.
* a method `Logger#getFlowMessageFactory()` to return the flow message
factory used by the logger,
* move the logic that creates EntryMessage/ExitMessage from
AbstractLogger to FlowMessageFactory (3 new methods).

A concrete implementation of the proposal is in
https://github.com/apache/logging-log4j2/pull/1171. What do you think
about it?

Since the `LogBuilder` equivalent of `traceEntry` and `traceExit` is
much longer, I don't expect  anyone to employ these methods in their
source code.

Piotr

[1] https://github.com/apache/logging-log4j2/pull/1147

Reply via email to