This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val channels = if(BuildConfig.DEBUG) { | |
val categoriesFilter = Filter.categories(listOf( | |
Categories.Default, | |
// ... | |
)) | |
val filterCombination = Filter.level(Level.WARN) or categoriesFilter | |
Log.Setup.Configuration() | |
.addLogCatChannel(filter = filterCombination) | |
.create() | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Filter.level(Level.ERROR) or Filter.categories( | |
listOf( | |
Categories.UI, | |
Categories.User, | |
Categories.Push | |
) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CrashlyticsChannel : ReleaseChannel() { | |
override val filter: Filter = Filter.level(Level.ERROR) | |
override val id: Int = Channels.Crashlytics | |
override val default: Boolean = true | |
override fun print(line: Line) { | |
FirebaseCrashlytics.getInstance() | |
.log("${line.level.name} ${line.category}: ${line.message}") | |
line.throwable?.let { error -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defaultConfig { | |
buildConfigField "String[]", "LOG_CATEGORIES", readProperty( | |
project.rootProject.file('local.properties'), | |
"log.categories", | |
"{\"Default\"}" | |
) | |
// ... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static def readProperty(propertiesFile, key, defaultValue){ | |
def properties = new Properties() | |
if (propertiesFile.canRead()) { | |
properties.load(propertiesFile.newDataInputStream()) | |
properties.get(key, defaultValue) | |
} else { | |
defaultValue | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (BuildConfig.DEBUG) { | |
val filterCombination = Filter.level(Level.WARN) or BuildConfigCategoryFilter | |
val channels = Log.Setup.Configuration() | |
.addLogCatChannel(filter = filterCombination, default = true) | |
.create() | |
Log.Setup.addChannels(channels) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object BuildConfigCategoryFilter: CategoryFilter() { | |
override val categories: List<Category> = BuildConfig.LOG_CATEGORIES | |
.map { Category(it) } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defaultConfig { | |
buildConfigField "String[]", "LOG_CATEGORIES", "{" + | |
"\"Default\"," + | |
"\"Push\"," + | |
"\"Registration\"" + | |
"}" | |
// ... | |
} |