@Override
    public void encode(Event event, OutputStream output) throws IOException {
        String outputString = (format == null
                ? event.toString()
                : StringInterpolation.evaluate(event, format));
        output.write(outputString.getBytes(charset));
    }
@Test
    public void testEncodeWithFormat() throws IOException {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        Plain encoder = new Plain(new ConfigurationImpl(Collections.singletonMap("format", "%{host}-%{message}")), null);
        String message = "Hello world";
        String host = "test";
        String expectedOutput = host + "-" + message;
        Event e = new Event();
        e.setField("message", message);
        e.setField("host", host);

        encoder.encode(e, outputStream);

        String resultingString = outputStream.toString();
        assertEquals(expectedOutput, resultingString);
    }