I like the original code better since it gives more information.

Also, if you want to provide for lamdas that supply a Message, provide a
method that accepts a MessageSupplier.

The reason is that the Object returned by the Supplier<?> will be wrapped
in a new Message (
https://logging.apache.org/log4j/2.x/log4j-api/xref/org/apache/logging/log4j/spi/AbstractLogger.html#L1003),
while the Message returned by MessageSupplier is used as is (
https://logging.apache.org/log4j/2.x/log4j-api/xref/org/apache/logging/log4j/spi/AbstractLogger.html#L997
).

On Saturday, 13 February 2016, <[email protected]> wrote:

> Repository: logging-log4j2
> Updated Branches:
>   refs/heads/master 13f49fccc -> dc80330b5
>
>
> Make ObjectMessage work for code like logger.traceEntry(new
> Supplier<ObjectMessage>() { ... Tests to follow but are currently mixed
> with other changes in my local repo.
>
> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
> Commit:
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/dc80330b
> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/dc80330b
> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/dc80330b
>
> Branch: refs/heads/master
> Commit: dc80330b521535746969e888c4b59539a147c265
> Parents: 13f49fc
> Author: ggregory <[email protected] <javascript:;>>
> Authored: Fri Feb 12 11:13:03 2016 -0800
> Committer: ggregory <[email protected] <javascript:;>>
> Committed: Fri Feb 12 11:13:03 2016 -0800
>
> ----------------------------------------------------------------------
>  .../main/java/org/apache/logging/log4j/message/ObjectMessage.java  | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> ----------------------------------------------------------------------
>
>
>
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/dc80330b/log4j-api/src/main/java/org/apache/logging/log4j/message/ObjectMessage.java
> ----------------------------------------------------------------------
> diff --git
> a/log4j-api/src/main/java/org/apache/logging/log4j/message/ObjectMessage.java
> b/log4j-api/src/main/java/org/apache/logging/log4j/message/ObjectMessage.java
> index 7cffe47..ad3dba8 100644
> ---
> a/log4j-api/src/main/java/org/apache/logging/log4j/message/ObjectMessage.java
> +++
> b/log4j-api/src/main/java/org/apache/logging/log4j/message/ObjectMessage.java
> @@ -98,7 +98,7 @@ public class ObjectMessage implements Message {
>
>      @Override
>      public String toString() {
> -        return "ObjectMessage[obj=" + getFormattedMessage() + ']';
> +        return getFormattedMessage();
>      }
>
>      private void writeObject(final ObjectOutputStream out) throws
> IOException {
>
>

Reply via email to