Lower default minimum log level from INFO to FINE (#1827)

* Increase logging level

* Adjust log levels for visibility in non-verbose logs

- Change log level from FINER to FINE in StreamingFileDescriptor
- Update log level from FINER to FINE in AccountSettingsMigration8
- Add note about log levels in LogManager documentation

* Fix KDoc typo

* Update comment
This commit is contained in:
Ricki Hirner
2025-11-20 11:37:24 +01:00
committed by GitHub
parent 794b4c1c7f
commit 76fc024ef6
4 changed files with 11 additions and 6 deletions

View File

@@ -39,6 +39,10 @@ import javax.inject.Singleton
* *
* When using the global logger, the class name of the logging calls will still be logged, so there's * When using the global logger, the class name of the logging calls will still be logged, so there's
* no need to always get a separate logger for each class (only if the class wants to customize it). * no need to always get a separate logger for each class (only if the class wants to customize it).
*
* Note about choosing log levels: records with [Level.FINE] or higher will always be printed to adb logs
* (regardless of whether verbose logging is active). Records with a lower level will only be
* printed to adb logs when verbose logging is active.
*/ */
@Singleton @Singleton
class LogManager @Inject constructor( class LogManager @Inject constructor(
@@ -79,7 +83,10 @@ class LogManager @Inject constructor(
// root logger: set default log level and always log to logcat // root logger: set default log level and always log to logcat
val rootLogger = Logger.getLogger("") val rootLogger = Logger.getLogger("")
rootLogger.level = if (logVerbose) Level.ALL else Level.INFO rootLogger.level = if (logVerbose)
Level.ALL // include everything (including HTTP interceptor logs) in verbose logs
else
Level.FINE // include detailed information like content provider operations in non-verbose logs
rootLogger.addHandler(LogcatHandler(BuildConfig.APPLICATION_ID)) rootLogger.addHandler(LogcatHandler(BuildConfig.APPLICATION_ID))
// log to file, if requested // log to file, if requested

View File

@@ -18,7 +18,6 @@ import dagger.hilt.components.SingletonComponent
import dagger.multibindings.IntKey import dagger.multibindings.IntKey
import dagger.multibindings.IntoMap import dagger.multibindings.IntoMap
import org.dmfs.tasks.contract.TaskContract import org.dmfs.tasks.contract.TaskContract
import org.dmfs.tasks.contract.TaskContract.CommonSyncColumns
import java.util.logging.Level import java.util.logging.Level
import java.util.logging.Logger import java.util.logging.Logger
import javax.inject.Inject import javax.inject.Inject
@@ -50,7 +49,7 @@ class AccountSettingsMigration8 @Inject constructor(
TaskContract.Tasks.SYNC1 to null, TaskContract.Tasks.SYNC1 to null,
TaskContract.Tasks.SYNC2 to null TaskContract.Tasks.SYNC2 to null
) )
logger.log(Level.FINER, "Updating task $id", values) logger.log(Level.FINE, "Updating task $id", values)
provider.client.update( provider.client.update(
ContentUris.withAppendedId(provider.tasksUri(), id).asSyncAdapter(account), ContentUris.withAppendedId(provider.tasksUri(), id).asSyncAdapter(account),
values, null, null) values, null, null)

View File

@@ -8,7 +8,6 @@ import android.accounts.Account
import android.content.ContentResolver import android.content.ContentResolver
import android.content.Context import android.content.Context
import android.content.SyncRequest import android.content.SyncRequest
import android.os.Build
import android.os.Bundle import android.os.Bundle
import androidx.annotation.WorkerThread import androidx.annotation.WorkerThread
import at.bitfire.davdroid.resource.LocalAddressBookStore import at.bitfire.davdroid.resource.LocalAddressBookStore

View File

@@ -97,7 +97,7 @@ class StreamingFileDescriptor @AssistedInject constructor(
body.byteStream().use { source -> body.byteStream().use { source ->
transferred += source.copyTo(destination) transferred += source.copyTo(destination)
} }
logger.finer("Downloaded $transferred byte(s) from $url") logger.fine("Downloaded $transferred byte(s) from $url")
} }
} else } else
@@ -118,7 +118,7 @@ class StreamingFileDescriptor @AssistedInject constructor(
override fun writeTo(sink: BufferedSink) { override fun writeTo(sink: BufferedSink) {
ParcelFileDescriptor.AutoCloseInputStream(readFd).use { input -> ParcelFileDescriptor.AutoCloseInputStream(readFd).use { input ->
transferred += input.copyTo(sink.outputStream()) transferred += input.copyTo(sink.outputStream())
logger.finer("Uploaded $transferred byte(s) to $url") logger.fine("Uploaded $transferred byte(s) to $url")
} }
} }
} }