public String doLayout(ILoggingEvent event) {
        StringBuilder buf = new StringBuilder();
        startNewTableIfLimitReached(buf);

        boolean odd = true;
        if (((counter++) & 1) == 0) {
            odd = false;
        }

        String level = event.getLevel().toString().toLowerCase();

        buf.append(LINE_SEPARATOR);
        buf.append("<tr class=\"");
        buf.append(level);
        if (odd) {
            buf.append(" odd\">");
        } else {
            buf.append(" even\">");
        }
        buf.append(LINE_SEPARATOR);

        Converter<ILoggingEvent> c = head;
        while (c != null) {
            appendEventToBuffer(buf, c, event);
            c = c.getNext();
        }
        buf.append("</tr>");
        buf.append(LINE_SEPARATOR);

        if (event.getThrowableProxy() != null) {
            throwableRenderer.render(buf, event);
        }
        return buf.toString();
    }
@Test
    public void testDoLayout() throws Exception {
        ILoggingEvent le = createLoggingEvent();

        String result = layout.getFileHeader();
        result += layout.getPresentationHeader();
        result += layout.doLayout(le);
        result += layout.getPresentationFooter();
        result += layout.getFileFooter();

        Document doc = parseOutput(result);
        Element rootElement = doc.getRootElement();
        rootElement.toString();

        // the rest of this test is very dependent of the output generated
        // by HTMLLayout. Given that the XML parser already verifies
        // that the result conforms to xhtml-strict, we may want to
        // skip the assertions below. However, the assertions below are another
        // *independent* way to check the output format.

        // head, body
        assertEquals(2, rootElement.elements().size());
        Element bodyElement = (Element) rootElement.elements().get(1);
        Element tableElement = (Element) bodyElement.elements().get(3);
        assertEquals("table", tableElement.getName());
        Element trElement = (Element) tableElement.elements().get(1);
        {
            Element tdElement = (Element) trElement.elements().get(0);
            assertEquals("DEBUG", tdElement.getText());
        }
        {
            Element tdElement = (Element) trElement.elements().get(1);
            String regex = ClassicTestConstants.NAKED_MAIN_REGEX;
            System.out.println(tdElement.getText());
            assertTrue(tdElement.getText().matches(regex));
        }
        {
            Element tdElement = (Element) trElement.elements().get(2);
            assertEquals("test message", tdElement.getText());
        }
    }