https://github.com/ml-opensource/lib-log-viewer
A library for storing and analysing logs within a debugged application
https://github.com/ml-opensource/lib-log-viewer
android
Last synced: 4 months ago
JSON representation
A library for storing and analysing logs within a debugged application
- Host: GitHub
- URL: https://github.com/ml-opensource/lib-log-viewer
- Owner: ml-opensource
- License: mit
- Created: 2018-11-29T12:14:19.000Z (about 7 years ago)
- Default Branch: develop
- Last Pushed: 2019-01-08T13:58:56.000Z (about 7 years ago)
- Last Synced: 2025-09-03T02:34:37.865Z (5 months ago)
- Topics: android
- Language: Kotlin
- Homepage:
- Size: 665 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lib-log-viewer (Name under discussion)
A library for storing and analysing logs within a debugged application. You can:
- Group logs into categories (e.g. "API calls", "Database writes", "Calculation results" etc.)
- Attach common severity levels to logs (e.g. "Warning", "Error" etc.) as well as add custom ones
- View logs for a specific category in real time
- View details for each log
## Future plans
- Take screenshot together with the log
- Various log sharing options
# Usage
## Initialize the logging library
You need to initialize the library before logging anything. Usually you'd want to do this in `onCreate(...)` of your `Application` child class.
```kotlin
Logger.initialize(context)
```
By default, the logs are stored in a Room-backed database. However, you can create your own implementation of `LogRepository`
and use that instead.
```kotlin
Logger.initialize(context, myRepository)
```
## Logging
Your log entry contains the following information:
- The time of logging (inserted automatically)
- A category name to group your logs under ("General" by default)
- A severity level (e.g. warning, error, debug etc.); verbose by default.
- A tag (optional)
- A throwable (optional)
- A log message
You can store logs with:
```kotlin
Logger.log(
message,
severityLevel,
tag,
categoryName,
throwable
)
```
Helper extensions are also provided to reflect the more common Android `Log` class functions:
```kotlin
Logger.v(/* arguments without the severity level */)
Logger.i(/* arguments without the severity level */)
Logger.d(/* arguments without the severity level */)
Logger.w(/* arguments without the severity level */)
Logger.e(/* arguments without the severity level */)
Logger.wtf(/* arguments without the severity level */)
```
## Viewing logs
You can view your logs in the `LogViewerActivity`:
```kotlin
LogViewerActivity
.createIntent(context)
.let { startActivity(it) }
```
### First a category has to be selected.

### Then all the logs for that category will be shown.

### Landscape orientation allows more message text to be seen. Line numbers are also shown then.

### Tapping on a log opens its details.

