-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve logging system to filter markers (#1270)
- Loading branch information
1 parent
721370e
commit e89bf41
Showing
7 changed files
with
49 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package de.schildbach.wallet.util | ||
|
||
import ch.qos.logback.classic.spi.ILoggingEvent | ||
import ch.qos.logback.core.filter.Filter | ||
import ch.qos.logback.core.spi.FilterReply | ||
|
||
class LogMarkerFilter(acceptedMarkers: List<String>) : Filter<ILoggingEvent?>() { | ||
|
||
constructor() : this(listOf()) | ||
|
||
private val acceptedMarkers = arrayListOf<String>() | ||
|
||
init { | ||
this.acceptedMarkers.addAll(acceptedMarkers) | ||
} | ||
|
||
fun addAcceptedMarker(marker: String) { | ||
acceptedMarkers.add(marker) | ||
} | ||
override fun decide(event: ILoggingEvent?): FilterReply { | ||
val marker = event?.markers?.get(0) ?: return FilterReply.ACCEPT | ||
|
||
return if (acceptedMarkers.contains(marker.name)) { | ||
FilterReply.ACCEPT | ||
} else { | ||
FilterReply.DENY | ||
} | ||
} | ||
} |