package org.xbib.logging.test;

import java.util.ArrayList;
import java.util.List;
import org.xbib.logging.ExtHandler;
import org.xbib.logging.ExtLogRecord;

class StringListHandler extends ExtHandler {
    private final List<String> messages = new ArrayList<String>();

    @Override
    protected void doPublish(final ExtLogRecord record) {
        super.doPublish(record);
        messages.add(record.getFormattedMessage());
    }

    public String getMessage(final int index) {
        return messages.get(index);
    }

    public int size() {
        return messages.size();
    }

    @Override
    public void close() throws SecurityException {
        super.close();
        messages.clear();
    }
}
