Skip to content

JVM: Logging cannot be configured (PagingLogger spams output) #269

Open

Description

Great work guys with the library, but currently there is a small problem:

Paging version: 3.3.0-alpha02-0.5.1
Platform: JVM

The built-in logging cannot be configured.
This leads to thousands of lines of VERBOSE and DEBUG output.

Currently the JVM PagingLogger is hardwired for some reason: isLoggable() always returns true.

PagingLogger.jvm.kt:

package androidx.paging

import androidx.annotation.RestrictTo

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public actual object PagingLogger {

    public actual fun isLoggable(level: Int): Boolean {
        return true
    }

    // consider using java.util.logging APIs instead
    public actual fun log(level: Int, message: String, tr: Throwable?) {
        print("\n$message")
    }
}

example log spam when scrolling a paginated list:

Generated new PagingSource my.package.MyOffsetQueryMappedPagingSource@58e7f207
Sent PageEvent.LoadStateUpdate (
   sourceLoadStates: LoadStates(refresh=Loading(endOfPaginationReached=false), prepend=NotLoading(endOfPaginationReached=false), append=NotLoading(endOfPaginationReached=false))
)
Collected PageEvent.LoadStateUpdate (
   sourceLoadStates: LoadStates(refresh=Loading(endOfPaginationReached=false), prepend=NotLoading(endOfPaginationReached=false), append=NotLoading(endOfPaginationReached=false))
)
Start REFRESH with loadKey null my.package.MyOffsetQueryMappedPagingSource@58e7f207
End REFRESH with loadKey null. Returned LoadResult.Page(
   data size: 1500
   first Item: MyItem(...)
   last Item: MyItem(...)
   nextKey: 1500
   prevKey: null
   itemsBefore: 0
   itemsAfter: 2691
) 
Sent PageEvent.Insert for REFRESH, with 1500 items (
   first item: MyItem(...)
   last item: MyItem(...)
   placeholdersBefore: 0
   placeholdersAfter: 2691
   sourceLoadStates: LoadStates(refresh=NotLoading(endOfPaginationReached=false), prepend=NotLoading(endOfPaginationReached=true), append=NotLoading(endOfPaginationReached=false))
)
Collected PageEvent.Insert for REFRESH, with 1500 items (
   first item: MyItem(...)
   last item: MyItem(...)
   placeholdersBefore: 0
   placeholdersAfter: 2691
   sourceLoadStates: LoadStates(refresh=NotLoading(endOfPaginationReached=false), prepend=NotLoading(endOfPaginationReached=true), append=NotLoading(endOfPaginationReached=false))
)
Presenting data:
   first item: MyItem(...)
   last item: MyItem(...)
   placeholdersBefore: 0
   placeholdersAfter: 2691
   hintReceiver: androidx.paging.PageFetcher$PagerHintReceiver@36d82710
   sourceLoadStates: LoadStates(refresh=NotLoading(endOfPaginationReached=false), prepend=NotLoading(endOfPaginationReached=true), append=NotLoading(endOfPaginationReached=false))
)PAGING ITEMS: LoadStateNotLoading: NotLoading(endOfPaginationReached=false)
PAGING ITEMS: LoadStateNotLoading: NotLoading(endOfPaginationReached=false)
PAGING ITEMS: LoadStateNotLoading: NotLoading(endOfPaginationReached=false)

Accessing item index[0]
Accessing item index[1]
Accessing item index[2]
Accessing item index[3]
Accessing item index[4]
Accessing item index[5]
Accessing item index[6]
Accessing item index[7]
Accessing item index[8]
Accessing item index[9]
Accessing item index[10]
Accessing item index[11]
Accessing item index[12]
Accessing item index[13]
Accessing item index[14]
Accessing item index[15]
Accessing item index[16]
Accessing item index[17]
Accessing item index[18]
Accessing item index[19]
Accessing item index[20]
Accessing item index[21]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions