Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bitfireAT/vcard4android.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicki Hirner <hirner@bitfire.at>2020-11-25 19:24:31 +0300
committerRicki Hirner <hirner@bitfire.at>2020-11-25 19:24:31 +0300
commitd4e00ff429ea8e89ce27232f6fd225ca76d63242 (patch)
tree0fb9fe00f3867fb32916b7df2535c262544d0dc2
parentec994f5470dab937c958c5cea13e9c58cef366bb (diff)
Improve logging
-rw-r--r--src/main/java/at/bitfire/vcard4android/AndroidContact.kt34
-rw-r--r--src/main/java/at/bitfire/vcard4android/BatchOperation.kt7
-rw-r--r--src/main/java/at/bitfire/vcard4android/Constants.kt6
3 files changed, 16 insertions, 31 deletions
diff --git a/src/main/java/at/bitfire/vcard4android/AndroidContact.kt b/src/main/java/at/bitfire/vcard4android/AndroidContact.kt
index e48e373..a1a9aee 100644
--- a/src/main/java/at/bitfire/vcard4android/AndroidContact.kt
+++ b/src/main/java/at/bitfire/vcard4android/AndroidContact.kt
@@ -621,8 +621,6 @@ open class AndroidContact(
if (addressBook.readOnly)
builder.withValue(RawContacts.RAW_CONTACT_IS_READ_ONLY, 1)
-
- Constants.log.log(Level.FINER, "Built RawContact data row", builder.build())
}
@@ -674,8 +672,6 @@ open class AndroidContact(
.withValue(StructuredName.PHONETIC_GIVEN_NAME, contact.phoneticGivenName)
.withValue(StructuredName.PHONETIC_MIDDLE_NAME, contact.phoneticMiddleName)
.withValue(StructuredName.PHONETIC_FAMILY_NAME, contact.phoneticFamilyName)
-
- Constants.log.log(Level.FINER, "Built StructuredName data row", builder.build())
batch.enqueue(builder)
}
@@ -761,8 +757,6 @@ open class AndroidContact(
.withValue(Phone.LABEL, typeLabel)
.withValue(Phone.IS_PRIMARY, if (isPrimary) 1 else 0)
.withValue(Phone.IS_SUPER_PRIMARY, if (isPrimary) 1 else 0)
-
- Constants.log.log(Level.FINER, "Built Phone data row", builder.build())
batch.enqueue(builder)
}
@@ -816,8 +810,6 @@ open class AndroidContact(
.withValue(Email.LABEL, typeLabel)
.withValue(Email.IS_PRIMARY, if (isPrimary) 1 else 0)
.withValue(Phone.IS_SUPER_PRIMARY, if (isPrimary) 1 else 0)
-
- Constants.log.log(Level.FINER, "Built Email data row", builder.build())
batch.enqueue(builder)
}
@@ -843,8 +835,6 @@ open class AndroidContact(
.withValue(Organization.DEPARTMENT, department)
.withValue(Organization.TITLE, contact.jobTitle)
.withValue(Organization.JOB_DESCRIPTION, contact.jobDescription)
-
- Constants.log.log(Level.FINER, "Built Organization data row", builder.build())
batch.enqueue(builder)
}
@@ -899,26 +889,22 @@ open class AndroidContact(
}
}
- val builder: BatchOperation.CpoBuilder
- if (sipAddress) {
+ val builder = if (sipAddress)
// save as SIP address
- builder = insertDataBuilder(SipAddress.RAW_CONTACT_ID)
+ insertDataBuilder(SipAddress.RAW_CONTACT_ID)
.withValue(SipAddress.MIMETYPE, SipAddress.CONTENT_ITEM_TYPE)
.withValue(SipAddress.DATA, impp.handle)
.withValue(SipAddress.TYPE, typeCode)
.withValue(SipAddress.LABEL, typeLabel)
- Constants.log.log(Level.FINER, "Built SipAddress data row", builder.build())
- } else {
+ else
// save as IM address
- builder = insertDataBuilder(Im.RAW_CONTACT_ID)
+ insertDataBuilder(Im.RAW_CONTACT_ID)
.withValue(Im.MIMETYPE, Im.CONTENT_ITEM_TYPE)
.withValue(Im.DATA, impp.handle)
.withValue(Im.TYPE, typeCode)
.withValue(Im.LABEL, typeLabel)
.withValue(Im.PROTOCOL, protocolCode)
.withValue(Im.CUSTOM_PROTOCOL, protocolLabel)
- Constants.log.log(Level.FINER, "Built Im data row", builder.build())
- }
batch.enqueue(builder)
}
@@ -948,8 +934,6 @@ open class AndroidContact(
.withValue(Nickname.NAME, nick.values.first())
.withValue(Nickname.TYPE, typeCode)
.withValue(Nickname.LABEL, typeLabel)
-
- Constants.log.log(Level.FINER, "Built Nickname data row", builder.build())
batch.enqueue(builder)
}
@@ -961,8 +945,6 @@ open class AndroidContact(
val builder = insertDataBuilder(Note.RAW_CONTACT_ID)
.withValue(Note.MIMETYPE, Note.CONTENT_ITEM_TYPE)
.withValue(Note.NOTE, contact.note)
-
- Constants.log.log(Level.FINER, "Built Note data row", builder.build())
batch.enqueue(builder)
}
@@ -1025,8 +1007,6 @@ open class AndroidContact(
.withValue(StructuredPostal.REGION, address.region)
.withValue(StructuredPostal.POSTCODE, address.postalCode)
.withValue(StructuredPostal.COUNTRY, address.country)
-
- Constants.log.log(Level.FINER, "Built StructuredPostal data row", builder.build())
batch.enqueue(builder)
}
@@ -1060,8 +1040,6 @@ open class AndroidContact(
.withValue(Website.URL, url.value)
.withValue(Website.TYPE, typeCode)
.withValue(Website.LABEL, typeLabel)
-
- Constants.log.log(Level.FINER, "Built Website data row", builder.build())
batch.enqueue(builder)
}
@@ -1084,8 +1062,6 @@ open class AndroidContact(
.withValue(Event.MIMETYPE, Event.CONTENT_ITEM_TYPE)
.withValue(Event.TYPE, type)
.withValue(Event.START_DATE, dateStr)
-
- Constants.log.log(Level.FINER, "Built Event data row", builder.build())
batch.enqueue(builder)
}
@@ -1111,8 +1087,6 @@ open class AndroidContact(
.withValue(Relation.NAME, related.text)
.withValue(Relation.TYPE, typeCode)
.withValue(Relation.LABEL, StringUtils.trimToNull(labels.joinToString(", ")))
-
- Constants.log.log(Level.FINER, "Built Relation data row", builder.build())
batch.enqueue(builder)
}
diff --git a/src/main/java/at/bitfire/vcard4android/BatchOperation.kt b/src/main/java/at/bitfire/vcard4android/BatchOperation.kt
index d54bfdb..ce49a11 100644
--- a/src/main/java/at/bitfire/vcard4android/BatchOperation.kt
+++ b/src/main/java/at/bitfire/vcard4android/BatchOperation.kt
@@ -13,6 +13,7 @@ import android.net.Uri
import android.os.RemoteException
import android.os.TransactionTooLargeException
import java.util.*
+import java.util.logging.Level
class BatchOperation(
private val providerClient: ContentProviderClient
@@ -44,7 +45,11 @@ class BatchOperation(
var affected = 0
if (!queue.isEmpty())
try {
- Constants.log.fine("Committing ${queue.size} operations")
+ if (Constants.log.isLoggable(Level.FINE)) {
+ Constants.log.log(Level.FINE, "Committing ${queue.size} operations:")
+ for ((idx, op) in queue.withIndex())
+ Constants.log.log(Level.FINE, "#$idx: ${op.build()}")
+ }
results = arrayOfNulls(queue.size)
runBatch(0, queue.size)
diff --git a/src/main/java/at/bitfire/vcard4android/Constants.kt b/src/main/java/at/bitfire/vcard4android/Constants.kt
index 1b79e10..028110f 100644
--- a/src/main/java/at/bitfire/vcard4android/Constants.kt
+++ b/src/main/java/at/bitfire/vcard4android/Constants.kt
@@ -8,10 +8,16 @@
package at.bitfire.vcard4android
+import java.util.logging.Level
import java.util.logging.Logger
object Constants {
val log: Logger = Logger.getLogger("vcard4android")
+ init {
+ if (BuildConfig.DEBUG)
+ log.level = Level.ALL
+ }
+
} \ No newline at end of file