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 Filter.
We realize that this is a reduction in power, but depending on your filter configuration there should be a considerable speedup as compensation:
[info] Benchmark Mode Cnt Score Error Units
[info] FilterBenchmark.testEverything thrpt 25 255,250 ± 12,763 ops/s
[info] FilterBenchmark.testInfo thrpt 25 722,664 ± 25,608 ops/s
[info] FilterBenchmark.testNothing thrpt 25 11275,189 ± 314,631 ops/s
[success] Total time: 1509 s (25:09), completed 31 Mar 2023, 10.38.35
See modules/benchmarks/FilterBenchmark.scala.output.md for the full benchmark results and treatment.
What's Changed
- Upgrade scalafmt-core from 3.7.2 to 3.7.3 by @scala-steward in https://github.com/LEGO/woof/pull/143
- Upgrade nscplugin, sbt-scala-native, ... from 0.4.11 to 0.4.12 by @scala-steward in https://github.com/LEGO/woof/pull/142
- 140: #140 implement applicative filter DSL by @hejfelix in https://github.com/LEGO/woof/pull/141
Full Changelog: https://github.com/LEGO/woof/compare/v0.5.1...v0.6.0