Mahoney / slf4j-test

Implementation of SLF4J which allows easy access to logging events in tests
39 stars 24 forks source link

LoggingEvent#getFormattedMessage() doesn't format nulls the same way as SLF4J #31

Open josephw opened 2 years ago

josephw commented 2 years ago

Although LoggingEvent#getFormattedMessage() isn't public (#28), its code is still usable as a reference. However, it doesn't present null values the same way as SLF4J, due to un-matched wrapping/unwrapping of Optional:

        LoggingEvent e = new LoggingEvent(Level.INFO, "Content: {}, {}", null, "value");
        System.out.println(MessageFormatter.arrayFormat(e.getMessage(), e.getArguments().toArray()).getMessage());

Produces:

Content: Optional.absent(), value

Rather than the expected:

Content: null, value