ValueDecorator extends EventSinkDecorator<S> { public void append(Event e) throws IOException, InterruptedException { byte[] attrVal = escape ? e.escapeString(unescapedValue).getBytes() : value; e.set(attr, attrVal); super.append(e); } ValueDecorator(S s, String attr, String value);  ValueDecorator(S s, String attr, String value, boolean escape); void append(Event e); static SinkDecoBuilder builder(); static final String KW_ESCAPE; }
@Test public void testValueDecoratorWithEscape() throws IOException, InterruptedException { String value = "value-%{nanos}-%{body}"; ValueDecorator dec = new ValueDecorator(new ConsoleEventSink(), "attr", value, true); dec.open(); Event e = new EventImpl("bodyString".getBytes(), 1234567L, Event.Priority.INFO, 87654321L, "host"); dec.append(e); Assert.assertNotNull("Attribute wasn't added", e.get("attr")); Assert.assertEquals("Attribute value is incorrect", "value-87654321-bodyString", new String(e.get("attr"))); dec.close(); }