https://github.com/seanghay/console
A simple yet concise console.log for Android
https://github.com/seanghay/console
android javascript kotlin logcat
Last synced: 3 months ago
JSON representation
A simple yet concise console.log for Android
- Host: GitHub
- URL: https://github.com/seanghay/console
- Owner: seanghay
- License: apache-2.0
- Created: 2020-01-03T04:24:20.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-04-23T10:02:27.000Z (about 4 years ago)
- Last Synced: 2025-03-15T00:11:41.394Z (over 1 year ago)
- Topics: android, javascript, kotlin, logcat
- Language: Kotlin
- Size: 142 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Console
A simple yet concise JavaScript `console.log` for Android
[ ](https://travis-ci.org/seanghay/console)
[](https://opensource.org/licenses/Apache-2.0)
[  ](https://bintray.com/seanghay/maven/console/_latestVersion)
> I wrote this library because I want to feel like I'm writting JavaScript `console` in Android
------------
## Usage
It uses the default tag which is `Console` to print to `logcat`
```kotlin
fun main() {
console.log("message1", "message2", obj)
console.info("message1", "message2")
console.error("message1", "message2")
console.warn("message1", "message2")
// Console: message1, message2, Object(...).toString()
}
```
------------
### Customize Tag
It can be useful when you want to have different tags for different logs.
```kotlin
fun main() {
console.tag("myTag") {
log("hello", "world")
error("oh no!")
}
// myTag: hello, world
// myTag: oh no!
}
```
It's the same as
```kotlin
fun main() {
console.tag("myTag")
log("hello", "world")
error("oh no!")
console.tagReset()
}
```
------------
### Log Count
Count every time it has been called
```kotlin
fun main() {
repeat(100) {
console.count("myCount")
// myCount: 1
// myCount: 2
// myCount: ..
// myCount: 100
}
console.countReset("myCount")
// myCount: 100
}
```
------------
### Time Measurement
Useful for profiling your code
```kotlin
fun main() {
console.time("profile")
Thread.sleep(1_000L)
console.timeEnd("profile")
// profile: 1001 millis
}
```
--------
### Installation
[](https://jitpack.io/#seanghay/console)
```gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```
```gradle
dependencies {
implementation 'com.github.seanghay:console:1.0.0-alpha01'
}
```
### Issues
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! :smile: