001package org.atteo.moonshine.logback;
002
003import ch.qos.logback.classic.spi.LoggingEvent;
004import ch.qos.logback.core.filter.AbstractMatcherFilter;
005import ch.qos.logback.core.spi.FilterReply;
006
007public class LoggerNameFilter extends AbstractMatcherFilter<LoggingEvent> {
008
009    private String loggerName;
010
011    @Override
012    public FilterReply decide(LoggingEvent event) {
013        if (event.getLoggerName().startsWith(loggerName)) {
014            return onMatch;
015        } else {
016            return onMismatch;
017        }
018    }
019
020    public void setLoggerName(String loggerName) {
021        this.loggerName = loggerName;
022    }
023
024    public String getLoggerName() {
025        return loggerName;
026    }
027
028    @Override
029    public void start() {
030        if (loggerName != null) {
031            super.start();
032        }
033    }
034
035}