diff --git a/app/src/main/java/app/logorrr/io/FileManager.scala b/app/src/main/java/app/logorrr/io/FileManager.scala index 7315025b..44c74957 100644 --- a/app/src/main/java/app/logorrr/io/FileManager.scala +++ b/app/src/main/java/app/logorrr/io/FileManager.scala @@ -11,7 +11,7 @@ object FileManager extends CanLog { private def openFileWithDetectedEncoding(path: Path): BufferedReader = { val encoding = FEncoding(path) if (encoding == Unknown) { - logTrace(encoding.asString + " encoding - fallback to UTF-8") + logTrace(s"${encoding.asString} encoding - fallback to UTF-8") new BufferedReader(new InputStreamReader(new FileInputStream(path.toFile), UTF8.asString)) } else { new BufferedReader(new InputStreamReader(new FileInputStream(path.toFile), encoding.asString)) diff --git a/app/src/main/scala/app/logorrr/LogoRRRApp.scala b/app/src/main/scala/app/logorrr/LogoRRRApp.scala index 3c70fcca..2d38db3d 100644 --- a/app/src/main/scala/app/logorrr/LogoRRRApp.scala +++ b/app/src/main/scala/app/logorrr/LogoRRRApp.scala @@ -25,7 +25,7 @@ class LogoRRRApp extends javafx.application.Application with CanLog { def start(stage: Stage): Unit = { - logInfo(s"Started " + AppMeta.fullAppNameWithVersion) + logInfo(s"Started ${AppMeta.fullAppNameWithVersion}") logInfo(s"Working directory: ${Paths.get("").toAbsolutePath.toString}") val settings: Settings = SettingsIO.fromFile() LogoRRRGlobals.set(settings, getHostServices) diff --git a/app/src/main/scala/app/logorrr/model/LogFileReader.scala b/app/src/main/scala/app/logorrr/model/LogFileReader.scala index 5933d8ef..81530d4a 100644 --- a/app/src/main/scala/app/logorrr/model/LogFileReader.scala +++ b/app/src/main/scala/app/logorrr/model/LogFileReader.scala @@ -10,7 +10,7 @@ object LogFileReader extends CanLog { def readFromFile(logFile: Path): Seq[String] = { if (OsUtil.enableSecurityBookmarks) { - logInfo("Registering security bookmark for " + logFile.toAbsolutePath.toString) + logInfo(s"Registering security bookmark for ${logFile.toAbsolutePath.toString}") OsxBridge.registerPath(logFile.toAbsolutePath.toString) } val lines = FileManager.fromPath(logFile) diff --git a/app/src/main/scala/app/logorrr/model/LogFileSettings.scala b/app/src/main/scala/app/logorrr/model/LogFileSettings.scala index bd5676a0..d14507ce 100644 --- a/app/src/main/scala/app/logorrr/model/LogFileSettings.scala +++ b/app/src/main/scala/app/logorrr/model/LogFileSettings.scala @@ -5,8 +5,8 @@ import app.logorrr.util.{CanLog, OsUtil} import app.logorrr.views.search.Filter import javafx.collections.{FXCollections, ObservableList} import javafx.scene.paint.Color -import pureconfig.{ConfigReader, ConfigWriter} import pureconfig.generic.semiauto.{deriveReader, deriveWriter} +import pureconfig.{ConfigReader, ConfigWriter} import java.nio.file.{Files, Path, Paths} import java.time.Instant @@ -23,10 +23,10 @@ object LogFileSettings { private val DefaultLogFormat: Option[LogEntryInstantFormat] = None private val DefaultAutoScroll = false - private val finest: Filter = new Filter("FINEST", Color.GREY) - private val info: Filter = new Filter("INFO", Color.GREEN) - private val warning: Filter = new Filter("WARNING", Color.ORANGE) - private val severe: Filter = new Filter("SEVERE", Color.RED) + private val finest: Filter = new Filter("FINEST", Color.GREY, true) + private val info: Filter = new Filter("INFO", Color.GREEN, true) + private val warning: Filter = new Filter("WARNING", Color.ORANGE, true) + private val severe: Filter = new Filter("SEVERE", Color.RED, true) val DefaultFilter: Seq[Filter] = Seq(finest, info, warning, severe) val DefaultFontSize = 12 diff --git a/app/src/main/scala/app/logorrr/views/LogFileTab.scala b/app/src/main/scala/app/logorrr/views/LogFileTab.scala index d378cfc1..14eff46c 100644 --- a/app/src/main/scala/app/logorrr/views/LogFileTab.scala +++ b/app/src/main/scala/app/logorrr/views/LogFileTab.scala @@ -114,7 +114,7 @@ class LogFileTab(val pathAsString: String op } - private val filtersToolBar = { + val filtersToolBar = { val fbtb = new FiltersToolBar(filteredList, removeFilter) fbtb.filtersProperty.bind(filtersListProperty) fbtb @@ -259,9 +259,8 @@ class LogFileTab(val pathAsString: String * - update file menu * */ - def closeTab(): Unit = { - shutdown() - } + def closeTab(): Unit = shutdown() + def shutdown(): Unit = { if (getLogFileSettings.isAutoScroll) { @@ -277,15 +276,5 @@ class LogFileTab(val pathAsString: String def removeFilter(filter: Filter): Unit = filtersListProperty.remove(filter) - /* - def getVisualViewWidth(): Double = { - val w = splitPane.getDividers.get(0).getPosition * splitPane.getWidth - if (w != 0.0) { - w - } else { - initialWidth.doubleValue() - } - } - */ } \ No newline at end of file diff --git a/app/src/main/scala/app/logorrr/views/main/LogoRRRMain.scala b/app/src/main/scala/app/logorrr/views/main/LogoRRRMain.scala index 4f8bb506..60754192 100644 --- a/app/src/main/scala/app/logorrr/views/main/LogoRRRMain.scala +++ b/app/src/main/scala/app/logorrr/views/main/LogoRRRMain.scala @@ -38,7 +38,7 @@ class LogoRRRMain(closeStage: => Unit) private def loadLogFiles(logs: Seq[LogFileSettings]): Unit = { val futures: Future[Seq[(String, ObservableList[LogEntry])]] = Future.sequence { - logInfo(s"Loading ${logs.length} log files: " + logs.map(_.pathAsString).mkString("['", "',`'", "']")) + logInfo(s"Loading ${logs.length} log files: ${logs.map(_.pathAsString).mkString("['", "',`'", "']")}") logs.filter(s => !ambp.contains(s.pathAsString)).map(s => Future((s.pathAsString, s.readEntries()))) } futures.onComplete({ diff --git a/app/src/main/scala/app/logorrr/views/main/LogoRRRMainTabPane.scala b/app/src/main/scala/app/logorrr/views/main/LogoRRRMainTabPane.scala index 885673e6..886d7081 100644 --- a/app/src/main/scala/app/logorrr/views/main/LogoRRRMainTabPane.scala +++ b/app/src/main/scala/app/logorrr/views/main/LogoRRRMainTabPane.scala @@ -52,7 +52,7 @@ class LogoRRRMainTabPane() def contains(p: String): Boolean = getLogFileTabs.exists(lr => lr.pathAsString == p) - private def getLogFileTabs: mutable.Seq[LogFileTab] = getTabs.asScala.flatMap { + def getLogFileTabs: mutable.Seq[LogFileTab] = getTabs.asScala.flatMap { t => t match { case l: LogFileTab => Option(l) diff --git a/app/src/main/scala/app/logorrr/views/main/LogoRRRScene.scala b/app/src/main/scala/app/logorrr/views/main/LogoRRRScene.scala deleted file mode 100644 index f1df089f..00000000 --- a/app/src/main/scala/app/logorrr/views/main/LogoRRRScene.scala +++ /dev/null @@ -1,25 +0,0 @@ -package app.logorrr.views.main - -import app.logorrr.conf.LogoRRRGlobals -import app.logorrr.util.JfxUtils -import javafx.beans.value.ChangeListener -import javafx.scene.Scene - - -object LogoRRRScene { - - /** after scene got initialized and scene was set to stage immediately set position of stage */ - val sceneListener = LogoRRRScene.mkSceneListener() - - /** - * @param x x coordinate of upper left corner of scene from last execution - * @param y y coordinate of upper left corner of scene from last execution - */ - def mkSceneListener(): ChangeListener[Scene] = - JfxUtils.onNew[Scene](scene => { - val (x, y) = (LogoRRRGlobals.getStageX, LogoRRRGlobals.getStageY) - scene.getWindow.setX(x) - scene.getWindow.setY(y) - }) -} - diff --git a/app/src/main/scala/app/logorrr/views/main/LogoRRRStage.scala b/app/src/main/scala/app/logorrr/views/main/LogoRRRStage.scala index 9df57dc7..8c062d61 100644 --- a/app/src/main/scala/app/logorrr/views/main/LogoRRRStage.scala +++ b/app/src/main/scala/app/logorrr/views/main/LogoRRRStage.scala @@ -46,11 +46,17 @@ case class LogoRRRStage(stage: Stage) extends CanLog { stage.setOnCloseRequest((_: WindowEvent) => closeApp()) private def closeApp(): Unit = { + // to save global filter state + for (t <- logorrrMain.ambp.logViewTabPane.getLogFileTabs) { + for ((f, i) <- t.filtersToolBar.activeFilters().zipWithIndex) { + LogoRRRGlobals.getLogFileSettings(t.pathAsString).setFilter(i, f) + } + } LogoRRRGlobals.persist() logorrrMain.shutdown() LogoRRRGlobals.unbindWindow() stage.sceneProperty.removeListener(LogoRRRStage.sceneListener) - logInfo(s"Stopped " + AppMeta.fullAppNameWithVersion) + logInfo(s"Stopped ${AppMeta.fullAppNameWithVersion}") } def show(): Unit = { diff --git a/app/src/main/scala/app/logorrr/views/search/AnyFilter.scala b/app/src/main/scala/app/logorrr/views/search/AnyFilter.scala index 6c708d7d..45a7fd8d 100644 --- a/app/src/main/scala/app/logorrr/views/search/AnyFilter.scala +++ b/app/src/main/scala/app/logorrr/views/search/AnyFilter.scala @@ -2,7 +2,7 @@ package app.logorrr.views.search import javafx.scene.paint.Color -class AnyFilter(filters: Set[Filter]) extends Fltr { +class AnyFilter(filters: Set[Filter]) extends Fltr(Color.WHITE) { override val color: Color = { if (filters.isEmpty) { @@ -15,5 +15,5 @@ class AnyFilter(filters: Set[Filter]) extends Fltr { } - override def applyMatch(searchTerm: String): Boolean = filters.exists(_.applyMatch(searchTerm)) + override def matches(searchTerm: String): Boolean = filters.exists(_.matches(searchTerm)) } diff --git a/app/src/main/scala/app/logorrr/views/search/Filter.scala b/app/src/main/scala/app/logorrr/views/search/Filter.scala index 709048f6..2d3021ed 100644 --- a/app/src/main/scala/app/logorrr/views/search/Filter.scala +++ b/app/src/main/scala/app/logorrr/views/search/Filter.scala @@ -1,5 +1,7 @@ package app.logorrr.views.search +import app.logorrr.views.search +import javafx.beans.property.SimpleBooleanProperty import javafx.scene.paint.Color import pureconfig.generic.semiauto.{deriveReader, deriveWriter} import pureconfig.{ConfigReader, ConfigWriter} @@ -24,7 +26,7 @@ object Filter { * - a melange of all colors from all hits in all other cases * */ def calcColor(value: String, filters: Seq[Fltr]): Color = { - val hits = filters.filter(sf => sf.applyMatch(value)) + val hits = filters.filter(sf => sf.matches(value)) val color = { if (hits.isEmpty) { Color.LIGHTGREY @@ -46,9 +48,29 @@ object Filter { * The idea is to encode each search term with a color such that one can immediately spot an occurence in the views. * * @param pattern text to search for - * @param color associated color + * @param color associated color + * @param active is filter active */ -class Filter(val pattern: String, val color: Color) extends Fltr { +class Filter(val pattern: String + , override val color: Color + , val active: Boolean) extends Fltr(color) { - override def applyMatch(searchTerm: String): Boolean = searchTerm.contains(pattern) + + private lazy val activeProperty = new SimpleBooleanProperty(active) + + def isActive = activeProperty.get() + + def bind(filterButton: FilterButton): Unit = { + filterButton.selectedProperty().bindBidirectional(activeProperty) + } + + def unbind(button: FilterButton): Unit = { + button.selectedProperty().unbindBidirectional(activeProperty) + } + + override def matches(searchTerm: String): Boolean = searchTerm.contains(pattern) + + def withActive(): Filter = { + new search.Filter(pattern, color, isActive) + } } \ No newline at end of file diff --git a/app/src/main/scala/app/logorrr/views/search/SearchTag.scala b/app/src/main/scala/app/logorrr/views/search/FilterButton.scala similarity index 69% rename from app/src/main/scala/app/logorrr/views/search/SearchTag.scala rename to app/src/main/scala/app/logorrr/views/search/FilterButton.scala index a14a56f0..98adcfd6 100644 --- a/app/src/main/scala/app/logorrr/views/search/SearchTag.scala +++ b/app/src/main/scala/app/logorrr/views/search/FilterButton.scala @@ -4,7 +4,7 @@ import app.logorrr.views.ops.RectButton import javafx.beans.{InvalidationListener, Observable} import javafx.scene.control.{ContentDisplay, ToggleButton, Tooltip} -object SearchTag { +object FilterButton { class RemoveFilterbutton(filter: Filter, removeFilter: Filter => Unit) extends RectButton(10, 10, filter.color, "remove") { setOnAction(_ => removeFilter(filter)) setStyle( @@ -18,21 +18,25 @@ object SearchTag { /** * Displays a search term and triggers displaying the results. */ -class SearchTag(filter: Filter - , i: Int - , updateActiveFilter: () => Unit - , removeFilter: Filter => Unit) extends ToggleButton(filter.pattern) { +class FilterButton(val filter: Filter + , i: Int + , updateActiveFilter: () => Unit + , removeFilter: Filter => Unit) extends ToggleButton(filter.pattern) { setTooltip(new Tooltip(if (i == 1) "one item found" else s"$i items found")) - if (!filter.isInstanceOf[UnclassifiedFilter]) { + if (!isUnclassified) { setContentDisplay(ContentDisplay.RIGHT) - setGraphic(new SearchTag.RemoveFilterbutton(filter, removeFilter)) + setGraphic(new FilterButton.RemoveFilterbutton(filter, removeFilter)) } - setSelected(true) + setSelected(filter.active) + selectedProperty().addListener(new InvalidationListener { // if any of the buttons changes its selected value, reevaluate predicate // and thus change contents of all views which display filtered List override def invalidated(observable: Observable): Unit = updateActiveFilter() }) + + def isUnclassified: Boolean = filter.isInstanceOf[UnclassifiedFilter] + } diff --git a/app/src/main/scala/app/logorrr/views/search/FiltersToolBar.scala b/app/src/main/scala/app/logorrr/views/search/FiltersToolBar.scala index aebf75b9..e5feb682 100644 --- a/app/src/main/scala/app/logorrr/views/search/FiltersToolBar.scala +++ b/app/src/main/scala/app/logorrr/views/search/FiltersToolBar.scala @@ -11,14 +11,14 @@ import scala.jdk.CollectionConverters._ /** A toolbar with buttons which filter log events */ object FiltersToolBar { -/* - private val BackgroundSelectedStyle: String = - """ - |-fx-background-color: GREEN; - |-fx-border-width: 1px 1px 1px 1px; - |-fx-border-color: RED; - |""".stripMargin -*/ + /* + private val BackgroundSelectedStyle: String = + """ + |-fx-background-color: GREEN; + |-fx-border-width: 1px 1px 1px 1px; + |-fx-border-color: RED; + |""".stripMargin + */ } @@ -30,8 +30,13 @@ object FiltersToolBar { class FiltersToolBar(filteredList: FilteredList[LogEntry] , removeFilter: Filter => Unit) extends ToolBar { - // setStyle(FiltersToolBar.BackgroundSelectedStyle) + var filterButtons: Map[Filter, FilterButton] = Map[Filter, FilterButton]() + var someUnclassifiedFilter: Option[(Filter, FilterButton)] = None + + var occurrences: Map[Filter, Int] = Map().withDefaultValue(0) + + /** will be bound to the current active filter list */ val filtersProperty = new SimpleListProperty[Filter]() init() @@ -46,35 +51,55 @@ class FiltersToolBar(filteredList: FilteredList[LogEntry] private def processFiltersChange(change: ListChangeListener.Change[_ <: Filter]): Unit = { while (change.next()) { if (change.wasAdded()) { - change.getAddedSubList.asScala.foreach(addSearchTag) + change.getAddedSubList.asScala.foreach(addFilterButton) updateUnclassified() } else if (change.wasRemoved()) { - change.getRemoved.asScala.foreach(removeSearchTag) + change.getRemoved.asScala.foreach(removeFilterButton) updateUnclassified() } } } - var filterButtons: Map[Filter, SearchTag] = Map[Filter, SearchTag]() - - var someUnclassifiedFilter: Option[(Filter, SearchTag)] = None - - var occurrences: Map[Filter, Int] = Map().withDefaultValue(0) - private def updateOccurrences(sf: Filter): Unit = { - occurrences = occurrences + (sf -> filteredList.getSource.asScala.count(e => sf.applyMatch(e.value))) + occurrences = occurrences + (sf -> filteredList.getSource.asScala.count(e => sf.matches(e.value))) } private def updateUnclassified(): Unit = { val unclassified = new UnclassifiedFilter(filterButtons.keySet) updateOccurrences(unclassified) - val searchTag = new SearchTag(unclassified, occurrences(unclassified), updateActiveFilter, removeFilter) + val filterButton = new FilterButton(unclassified, occurrences(unclassified), updateActiveFilter, removeFilter) someUnclassifiedFilter.foreach(ftb => getItems.remove(ftb._2)) - getItems.add(0, searchTag) - someUnclassifiedFilter = Option((unclassified, searchTag)) + getItems.add(0, filterButton) + someUnclassifiedFilter = Option((unclassified, filterButton)) updateActiveFilter() } + private def addFilterButton(filter: Filter): Unit = { + updateOccurrences(filter) + val searchTag = new FilterButton(filter, occurrences(filter), updateActiveFilter, removeFilter) + filter.bind(searchTag) + getItems.add(searchTag) + filterButtons = filterButtons.updated(filter, searchTag) + } + + private def removeFilterButton(filter: Filter): Unit = { + val button = filterButtons(filter) + filter.unbind(button) + getItems.remove(button) + filterButtons = filterButtons.removed(filter) + } + + def activeFilters(): Seq[Filter] = { + (for (i <- getItems.asScala) yield { + val st = i.asInstanceOf[FilterButton] + if (st.isUnclassified) { + None + } else { + Option(st.filter.withActive()) + } + }).flatten.toSeq + } + /** * Filters are only active if selected. * @@ -87,25 +112,10 @@ class FiltersToolBar(filteredList: FilteredList[LogEntry] filterButtons.filter(fst => fst._2.isSelected).keySet) } - private def addSearchTag(filter: Filter): Unit = { - updateOccurrences(filter) - val searchTag = new SearchTag(filter, occurrences(filter), updateActiveFilter, removeFilter) - getItems.add(searchTag) - filterButtons = filterButtons + (filter -> searchTag) - } - - private def removeSearchTag(filter: Filter): Unit = { - getItems.remove(filterButtons(filter)) - filterButtons = filterButtons - filter - } - def updateActiveFilter(): Unit = { - val filter = computeCurrentFilter() - filteredList.setPredicate((entry: LogEntry) => filter.applyMatch(entry.value)) + filteredList.setPredicate((entry: LogEntry) => computeCurrentFilter().matches(entry.value)) } - updateUnclassified() - } diff --git a/app/src/main/scala/app/logorrr/views/search/Fltr.scala b/app/src/main/scala/app/logorrr/views/search/Fltr.scala index 4fd3e2e4..dbb4185f 100644 --- a/app/src/main/scala/app/logorrr/views/search/Fltr.scala +++ b/app/src/main/scala/app/logorrr/views/search/Fltr.scala @@ -2,12 +2,8 @@ package app.logorrr.views.search import javafx.scene.paint.Color -trait Fltr { - - val color: Color - - def applyMatch(searchTerm: String): Boolean - +abstract class Fltr(val color: Color) { + def matches(searchTerm: String): Boolean } diff --git a/app/src/main/scala/app/logorrr/views/search/RegexFilter.scala b/app/src/main/scala/app/logorrr/views/search/RegexFilter.scala index 86c94cb1..dde9d96e 100644 --- a/app/src/main/scala/app/logorrr/views/search/RegexFilter.scala +++ b/app/src/main/scala/app/logorrr/views/search/RegexFilter.scala @@ -6,11 +6,12 @@ import java.util.regex.Pattern class RegexFilter(override val pattern: String - , override val color: Color) extends Filter(pattern, color) { + , override val color: Color + , override val active: Boolean) extends Filter(pattern, color, active) { val compiledPattern = Pattern.compile(pattern) - override def applyMatch(searchTerm: String): Boolean = compiledPattern.matcher(searchTerm).find() + override def matches(searchTerm: String): Boolean = compiledPattern.matcher(searchTerm).find() } diff --git a/app/src/main/scala/app/logorrr/views/search/SearchButton.scala b/app/src/main/scala/app/logorrr/views/search/SearchButton.scala index 5cd65294..9c4adb2d 100644 --- a/app/src/main/scala/app/logorrr/views/search/SearchButton.scala +++ b/app/src/main/scala/app/logorrr/views/search/SearchButton.scala @@ -18,9 +18,9 @@ class SearchButton(searchTextField: SearchTextField if (searchTextField.getText.nonEmpty) { val filter = if (regexToggleButton.isSelected) { - new RegexFilter(searchTextField.getText, colorPicker.getValue) + new RegexFilter(searchTextField.getText, colorPicker.getValue, true) } else { - new Filter(searchTextField.getText, colorPicker.getValue) + new Filter(searchTextField.getText, colorPicker.getValue, true) } colorPicker.setValue(ColorUtil.randColor) searchTextField.clear() diff --git a/app/src/main/scala/app/logorrr/views/search/UnclassifiedFilter.scala b/app/src/main/scala/app/logorrr/views/search/UnclassifiedFilter.scala index 5ac2f9a1..423e9ced 100644 --- a/app/src/main/scala/app/logorrr/views/search/UnclassifiedFilter.scala +++ b/app/src/main/scala/app/logorrr/views/search/UnclassifiedFilter.scala @@ -1,8 +1,8 @@ package app.logorrr.views.search class UnclassifiedFilter(filters: Set[Filter]) extends - Filter("Unclassified", Filter.unClassifiedFilterColor) { + Filter("Unclassified", Filter.unClassifiedFilterColor, true) { - override def applyMatch(searchTerm: String): Boolean = !filters.exists(_.applyMatch(searchTerm)) + override def matches(searchTerm: String): Boolean = !filters.exists(_.matches(searchTerm)) } diff --git a/app/src/main/scala/app/logorrr/views/settings/timer/TimerSettingsLogViewLabel.scala b/app/src/main/scala/app/logorrr/views/settings/timer/TimerSettingsLogViewLabel.scala index cba2740a..bc3fac7d 100644 --- a/app/src/main/scala/app/logorrr/views/settings/timer/TimerSettingsLogViewLabel.scala +++ b/app/src/main/scala/app/logorrr/views/settings/timer/TimerSettingsLogViewLabel.scala @@ -37,7 +37,7 @@ case class TimerSettingsLogViewLabel(settings: MutLogFileSettings val l = new Label(c.toString) l.setUserData(i) // save position of label for later l.setOnMouseClicked(applyStyleAtPos(i) _) - l.setTooltip(new Tooltip("column: " + i.toString)) + l.setTooltip(new Tooltip(s"column: ${i.toString}")) l.setOnMouseEntered(_ => { l.setStyle( """-fx-border-color: RED; diff --git a/app/src/test/scala/app/logorrr/views/text/FilterCalculatorSpec.scala b/app/src/test/scala/app/logorrr/views/text/FilterCalculatorSpec.scala index 5e4bc192..c963a61d 100644 --- a/app/src/test/scala/app/logorrr/views/text/FilterCalculatorSpec.scala +++ b/app/src/test/scala/app/logorrr/views/text/FilterCalculatorSpec.scala @@ -20,7 +20,7 @@ object FilterCalculatorSpec { class FilterCalculatorSpec extends LogoRRRSpec { def applySingleFilter(logEntry: String, pattern: String): Seq[Seq[LinePart]] = { - FilterCalculator(LogEntry(0, Color.BLUE, logEntry, None), Seq(new Filter(pattern, Color.RED))).filteredParts + FilterCalculator(LogEntry(0,logEntry, None), Seq(new Filter(pattern, Color.RED, true))).filteredParts } "calcParts" should { @@ -46,8 +46,8 @@ class FilterCalculatorSpec extends LogoRRRSpec { assert(partss.size == 1) val parts = partss.head - assert(parts(0).startIndex == 0) - assert(parts(0).endIndex == 0) + assert(parts.head.startIndex == 0) + assert(parts.head.endIndex == 0) assert(parts(1).startIndex == 1) assert(parts(1).endIndex == 1) assert(parts(2).startIndex == 2) @@ -59,8 +59,8 @@ class FilterCalculatorSpec extends LogoRRRSpec { assert(partss.size == 1) val parts = partss.head - assert(parts(0).startIndex == 0) - assert(parts(0).endIndex == 1) + assert(parts.head.startIndex == 0) + assert(parts.head.endIndex == 1) assert(parts(1).startIndex == 2) assert(parts(1).endIndex == 3) } @@ -80,9 +80,9 @@ class FilterCalculatorSpec extends LogoRRRSpec { "filteredParts" should { val filters = Seq( - new Filter("a", Color.RED) - , new Filter("b", Color.BLUE) - , new Filter("t", Color.YELLOW) + new Filter("a", Color.RED, true) + , new Filter("b", Color.BLUE, true) + , new Filter("t", Color.YELLOW, true) ) val entry = LogEntry(0, "test a b c", None) val calculator = FilterCalculator(entry, filters) @@ -90,7 +90,7 @@ class FilterCalculatorSpec extends LogoRRRSpec { "produce correct amount of matches" in { val filteredParts = calculator.filteredParts assert(filteredParts.size == 3) - assert(filteredParts(0).size == 1) // match a once + assert(filteredParts.head.size == 1) // match a once assert(filteredParts(1).size == 1) // match b once assert(filteredParts(2).size == 2) // match t twice } diff --git a/core/src/main/scala/app/logorrr/io/Fs.scala b/core/src/main/scala/app/logorrr/io/Fs.scala index d5550cbe..587fd384 100644 --- a/core/src/main/scala/app/logorrr/io/Fs.scala +++ b/core/src/main/scala/app/logorrr/io/Fs.scala @@ -9,10 +9,10 @@ object Fs extends CanLog { def createDirectories(path: Path): Unit = { if (Files.exists(path)) { - logTrace("Using directory " + path.toAbsolutePath.toString) + logTrace(s"Using directory ${path.toAbsolutePath.toString}") } else { Files.createDirectories(path) - logTrace("Created directory " + path.toAbsolutePath.toString) + logTrace(s"Created directory ${path.toAbsolutePath.toString}") } }