A simple yet concise JavaScript console.log
for Android
I wrote this library because I want to feel like I'm writting JavaScript
console
in Android
It uses the default tag which is Console
to print to logcat
fun main() {
console.log("message1", "message2", obj)
console.info("message1", "message2")
console.error("message1", "message2")
console.warn("message1", "message2")
// Console: message1, message2, Object(...).toString()
}
It can be useful when you want to have different tags for different logs.
fun main() {
console.tag("myTag") {
log("hello", "world")
error("oh no!")
}
// myTag: hello, world
// myTag: oh no!
}
It's the same as
fun main() {
console.tag("myTag")
log("hello", "world")
error("oh no!")
console.tagReset()
}
Count every time it has been called
fun main() {
repeat(100) {
console.count("myCount")
// myCount: 1
// myCount: 2
// myCount: ..
// myCount: 100
}
console.countReset("myCount")
// myCount: 100
}
Useful for profiling your code
fun main() {
console.time("profile")
Thread.sleep(1_000L)
console.timeEnd("profile")
// profile: 1001 millis
}
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.seanghay:console:1.0.0-alpha01'
}
If you find anything unsual or bugs in this library, please open a new issue or pull request. I will try to solve it as soon as possible.
Also, please let me know if anything can be improved! 😄