0.6.0 Move to applicative DSL for filters, introduce optimization based on new filters
The highlight is the move to a new DSL for filters. Previously, filters were a type alias:
type Filter = LogLine => Boolean
This has changed to be an enum-based DSL:
enum Filter:
private[woof] case AtLeastLevel(level: LogLevel)
private[woof] case ExactLevel(level: LogLevel)
private[woof] case ClassRegex(regex: Regex)
private[woof] case MessageFilter(filter: String => Boolean)
private[woof] case LineNumberFilter(filter: Int => Boolean)
private[woof] case CompositeAnd(a: Filter, b: Filter)
private[woof] case CompositeOr(a: Filter, b: Filter)
private[woof] case Nothing
private[woof] case Everything
end Filter
with the same Monoid instance and syntax as before:
given Monoid[Filter] with
def empty: Filter = nothing
def combine(f: Filter, g: Filter): Filter = f or g
extension (f: Filter)
infix def and(g: Filter): Filter = Filter.CompositeAnd(f, g)
infix def or(g: Filter): Filter = Filter.CompositeOr(f, g)
For code using compositions of the pre-defined filters, this should not be a breaking change. However, if you have a custom filter, you need to migrate to some composition of the filters in the companion object of . We realize that this is a reduction in power, but depending on your filter configuration there should be a considerable speedup as compensation: