Skip to content

Commit 340b948

Browse files
authored
Log rule name when properties are changed (and increase log message importance) (#162)
1 parent 42e82f4 commit 340b948

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/src/main/kotlin/at/bitfire/synctools/icalendar/validation/ICalPreprocessor.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,21 @@ import net.fortuna.ical4j.transform.rfc5545.DatePropertyRule
1616
import net.fortuna.ical4j.transform.rfc5545.Rfc5545PropertyRule
1717
import java.io.BufferedReader
1818
import java.io.Reader
19-
import java.util.logging.Level
2019
import java.util.logging.Logger
2120
import javax.annotation.WillNotClose
2221

2322
/**
2423
* Applies some rules to increase compatibility of parsed (incoming) iCalendars:
2524
*
2625
* - [CreatedPropertyRule] to make sure CREATED is UTC
27-
* - [DatePropertyRule], [DateListPropertyRule] to rename Outlook-specific TZID parameters
26+
* - [DatePropertyRule] and [DateListPropertyRule] to rename Outlook-specific TZID parameters
2827
* (like "W. Europe Standard Time" to an Android-friendly name like "Europe/Vienna")
29-
*
3028
*/
3129
class ICalPreprocessor {
3230

31+
private val logger
32+
get() = Logger.getLogger(javaClass.name)
33+
3334
private val propertyRules = arrayOf(
3435
CreatedPropertyRule(), // make sure CREATED is UTC
3536

@@ -105,12 +106,12 @@ class ICalPreprocessor {
105106
private fun applyRules(property: Property) {
106107
propertyRules
107108
.filter { rule -> rule.supportedType.isAssignableFrom(property::class.java) }
108-
.forEach {
109+
.forEach { rule ->
109110
val beforeStr = property.toString()
110-
(it as Rfc5545PropertyRule<Property>).applyTo(property)
111+
(rule as Rfc5545PropertyRule<Property>).applyTo(property)
111112
val afterStr = property.toString()
112113
if (beforeStr != afterStr)
113-
Logger.getLogger(javaClass.name).log(Level.FINER, "$beforeStr -> $afterStr")
114+
logger.info("${rule.javaClass.name}: $beforeStr -> $afterStr")
114115
}
115116
}
116117

0 commit comments

Comments
 (0)