We have common libs those are reused in both environments: Android and Gradle. So we need a logger is not dependent on the concrete environment.
com.avito.logger.Logger. It helps us to reuse code.
Logging in Gradle#
To obtain a logger for Gradle we create the
GradleLoggerPlugin. It must be applied to the root project before others plugins dependent on it.
LoggerFactory for a
project or a
val projectLoggerFactory = GradleLoggerPlugin.getLoggerFactory(project) val taskLoggerFactory = GradleLoggerPlugin.getLoggerFactory(task)
Gradle uses lifecycle level by default, but to see info or debug level you have to set it for the whole Gradle run
--debug, which made console output unreadable and build slow.
There is an issue for that: gradle/#1010 Ability to set log level for specific task
PrintlnLoggerHandler adds the ability to tune log level for avito plugins separately
Logging in Android#
To obtain a logger for Android create a
StubLogger can be used in tests.
StubLogger will write to stdout only during test runs from IDE.