Skip to content

Is it possible to make isLoggable() function public? #467

@mattinger

Description

@mattinger

I'm trying to write a lazy wrapper around Timber so that it doesn't construct the final log string unless things are actually going to get logged.

class DefaultLazyTimberTree(private val delegate: Timber.Tree): LazyTimberTree {
    override fun d(message: () -> String?) {
        if (delegate.isLoggable(Log.DEBUG)) {
            delegate.d(message())
        }
    }
}

The issue here is that "isLoggable" is not a public function, so you can't inspect the tree/forest to decide if you need to call the lambda function or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions