https://github.com/tans5/tlog
A log library for Android.
https://github.com/tans5/tlog
android-lib logger
Last synced: 7 months ago
JSON representation
A log library for Android.
- Host: GitHub
- URL: https://github.com/tans5/tlog
- Owner: Tans5
- License: apache-2.0
- Created: 2025-03-11T07:44:43.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-03-20T06:57:38.000Z (about 1 year ago)
- Last Synced: 2025-03-20T07:37:18.881Z (about 1 year ago)
- Topics: android-lib, logger
- Language: Kotlin
- Homepage:
- Size: 135 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
A log library for Android.
## Installation
Add the dependency to your build.gradle:
```Groovy
dependencies {
// ...
implementation 'io.github.tans5:tlog:1.0.0'
// ...
}
```
## Usage
### Initialization
```Kotlin
val log = tLog.Companion.Builder(
// Required: Directory to store log files
File(application.externalCacheDir, "AppLog")
)
// Configure basic parameters (with default values):
.setMaxSize(1024L * 1024L * 30L) // Maximum total log size (default = 30MB)
.setLogFilterLevel(LogLevel.Debug) // // Minimum severity level to record
.setBackgroundThread(HandlerThread("LogThread")) // Dedicated I/O thread
.setLogToBytesConverter(CustomEncryptor()) // Add encryption layer
.setInitCallback(object : InitCallback {
override fun onSuccess() {
/* Ready for logging */
}
override fun onFail(e: Throwable) {
/* Handle failure */
}
}) // Track initialization status
.build()
```
### Basic Logging
```Kotlin
log.d(TAG, "Debug")
log.i(TAG, "Info")
log.w(TAG, "Waring")
log.e(TAG, "Error", Throwable("TestError"))
```
### Maintenance Operations
```Kotlin
// Ensure all buffered logs are persisted
log.flush()
// Create compressed archive (ideal for uploads)
log.zipLogFile(outputFile = File("logs.zip"))
// Remove all log files
log.deleteAllLogs()
```