https://github.com/telefonica/android-logger
https://github.com/telefonica/android-logger
cdco managed org-cdo srv-novum
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/telefonica/android-logger
- Owner: Telefonica
- Created: 2020-11-24T09:14:54.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-04-08T07:14:10.000Z (about 1 month ago)
- Last Synced: 2025-04-13T05:06:54.610Z (about 1 month ago)
- Topics: cdco, managed, org-cdo, srv-novum
- Language: Kotlin
- Homepage:
- Size: 258 KB
- Stars: 2
- Watchers: 28
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# App Logger for Android
[](https://github.com/Telefonica/android-logger)
[](https://search.maven.org/artifact/com.telefonica/androidlogger)
[](https://github.com/Telefonica/android-logger)
[](https://kotlinlang.org/docs/reference/whatsnew14.html)App Logger that allows app logs visualization, classification, filtering, sharing and recording from the application where it is included.
## Installation
Inside the dependency block in the `build.gradle` of your application, add this line to add the library:
```gradle
dependencies {
...
implementation 'com.telefonica:androidlogger:$version'
...
}
```In case you want to disable any logging on release versions (and avoid inclusion of any transitive libraries), we provide a no-op version that will do nothing, without the need of handling this from your app code:
```gradle
dependencies {
...
debugImplementation 'com.telefonica:androidlogger:$version'
releaseImplementation 'com.telefonica:androidlogger-no-op:$version'
...
}
```## Configuration
To initialize the logger, call `initAppLogger` in your Application's onCreate:
```kotlin
open class MyApplication : Application() {val categories: List = listOf(
LogCategory(
name = "UI",
color = Color.parseColor("#28A745"),
logTags = listOf(
"MyActivity",
"MyFragment",
)
),
LogCategory(
name = "Your Category",
color = Color.parseColor("#17A2B8"),
logTags = listOf(
"MyStorage",
"MyApiClient",
)
),
)
override fun onCreate() {
super.onCreate()
initAppLogger(applicationContext, LoggerGroup.values().flatMap(transformation))
}
}
```And use `log` to write a log entry:
```kotlin
log(DEBUG, "MyActivity", "onCreate happened")
```Finally, to open the logger activity, just get the intent calling `getLaunchIntent`
```kotlin
startActivity(getLaunchIntent(context))
```## Demo app
There is a demo app of the logger viewer window in this repository. To compile the app manually run the [App](app) module in Android Studio.
## Contributing
See [CONTRIBUTING.md](./CONTRIBUTING.md)