package de.kif.backend.util

import ch.qos.logback.classic.Level
import ch.qos.logback.classic.spi.ILoggingEvent
import ch.qos.logback.core.filter.Filter
import ch.qos.logback.core.spi.FilterReply

class LogbackFilter : Filter<ILoggingEvent>() {
    override fun decide(event: ILoggingEvent?): FilterReply = if (event == null) {
        FilterReply.NEUTRAL
    } else {
        if (event.loggerName.contains("Exposed".toRegex())) {
            if (event.level.toInt() > Level.ERROR_INT) FilterReply.ACCEPT else FilterReply.DENY
        } else {
            FilterReply.ACCEPT
        }
    }
}