You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Gary Gregory <ga...@gmail.com> on 2016/02/22 07:05:35 UTC
Flow logging implementation pattern
We have:
@Override
public <R> R traceExit(final Message message, final R result) {
if (isEnabled(Level.TRACE, EXIT_MARKER, message, null)) {
logMessage(FQCN, Level.TRACE, EXIT_MARKER, new
MessageSupplier() {
@Override
public Message get() {
return flowMessageFactory.newExitMessage(result,
message);
};
}, null);
}
return result;
}
But then we turn around and extract the message with:
protected void logMessage(final String fqcn, final Level level, final
Marker marker,
final MessageSupplier msgSupplier, final Throwable t) {
final Message message = LambdaUtil.get(msgSupplier);
logMessage(fqcn, level, marker, message, t);
}
Why not simply do:
@Override
public <R> R traceExit(final Message message, final R result) {
if (isEnabled(Level.TRACE, EXIT_MARKER, message, null)) {
logMessage(FQCN, Level.TRACE, EXIT_MARKER,
flowMessageFactory.newExitMessage(result, message), null);
}
return result;
}
?
Thank you,
Gary
--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory
Re: Flow logging implementation pattern
Posted by Gary Gregory <ga...@gmail.com>.
Fixed in git master.
Gary
On Sun, Feb 21, 2016 at 10:43 PM, Remko Popma <re...@gmail.com> wrote:
> Makes sense. I was also wondering why it was that way.
>
> On Mon, Feb 22, 2016 at 3:05 PM, Gary Gregory <ga...@gmail.com>
> wrote:
>
>> We have:
>>
>> @Override
>> public <R> R traceExit(final Message message, final R result) {
>> if (isEnabled(Level.TRACE, EXIT_MARKER, message, null)) {
>> logMessage(FQCN, Level.TRACE, EXIT_MARKER, new
>> MessageSupplier() {
>> @Override
>> public Message get() {
>> return flowMessageFactory.newExitMessage(result,
>> message);
>> };
>> }, null);
>> }
>> return result;
>> }
>>
>> But then we turn around and extract the message with:
>>
>> protected void logMessage(final String fqcn, final Level level, final
>> Marker marker,
>> final MessageSupplier msgSupplier, final Throwable t) {
>> final Message message = LambdaUtil.get(msgSupplier);
>> logMessage(fqcn, level, marker, message, t);
>> }
>>
>> Why not simply do:
>>
>> @Override
>> public <R> R traceExit(final Message message, final R result) {
>> if (isEnabled(Level.TRACE, EXIT_MARKER, message, null)) {
>> logMessage(FQCN, Level.TRACE, EXIT_MARKER,
>> flowMessageFactory.newExitMessage(result, message), null);
>> }
>> return result;
>> }
>>
>> ?
>>
>> Thank you,
>> Gary
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> Java Persistence with Hibernate, Second Edition
>> <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>>
>
>
--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory
Re: Flow logging implementation pattern
Posted by Remko Popma <re...@gmail.com>.
Makes sense. I was also wondering why it was that way.
On Mon, Feb 22, 2016 at 3:05 PM, Gary Gregory <ga...@gmail.com>
wrote:
> We have:
>
> @Override
> public <R> R traceExit(final Message message, final R result) {
> if (isEnabled(Level.TRACE, EXIT_MARKER, message, null)) {
> logMessage(FQCN, Level.TRACE, EXIT_MARKER, new
> MessageSupplier() {
> @Override
> public Message get() {
> return flowMessageFactory.newExitMessage(result,
> message);
> };
> }, null);
> }
> return result;
> }
>
> But then we turn around and extract the message with:
>
> protected void logMessage(final String fqcn, final Level level, final
> Marker marker,
> final MessageSupplier msgSupplier, final Throwable t) {
> final Message message = LambdaUtil.get(msgSupplier);
> logMessage(fqcn, level, marker, message, t);
> }
>
> Why not simply do:
>
> @Override
> public <R> R traceExit(final Message message, final R result) {
> if (isEnabled(Level.TRACE, EXIT_MARKER, message, null)) {
> logMessage(FQCN, Level.TRACE, EXIT_MARKER,
> flowMessageFactory.newExitMessage(result, message), null);
> }
> return result;
> }
>
> ?
>
> Thank you,
> Gary
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>