https://github.com/tercanfurkan/log-inspector
LogInspector API: count the number of log lines which contain a given search query
https://github.com/tercanfurkan/log-inspector
filesystem kotlin logging regex zip
Last synced: over 1 year ago
JSON representation
LogInspector API: count the number of log lines which contain a given search query
- Host: GitHub
- URL: https://github.com/tercanfurkan/log-inspector
- Owner: tercanfurkan
- Created: 2022-10-26T12:23:35.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-13T09:08:01.000Z (over 3 years ago)
- Last Synced: 2024-10-24T16:51:07.223Z (over 1 year ago)
- Topics: filesystem, kotlin, logging, regex, zip
- Language: Kotlin
- Homepage:
- Size: 68.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# log-inspector
A gradle (7.3) project which uses kotlin.jvm 1.6.21
LogInspector API which maps log file names TO the number of lines which contains the given search query
## Sample
### ZIP file "23-10-2022_26-10-2022-output.zip":
ZIP archive contains:
```
23-10-2022-output.log
24-10-2022-output.log
25-10-2022-output.log
26-10-2022-output.log
```
### Using the API
```kotlin
val logInspector = LogInspector()
val searchQuery = "MQTT"
val zipFileName = "23-10-2022_26-10-2022-output.zip"
val zipFile: File = Paths.get(javaClass.getResource(zipFileName)!!.toURI()).toFile()
val fileNameToLineCountMap = logInspector.countEntries(LocalDate.of(2022, 10, 23), LocalDate.of(2022, 10, 25), "MQTT", zipFile)
```
### Output
```json
{
"23-10-2022-output.log" : 2,
"24-10-2022-output.log" : 3,
"25-10-2022-output.log" : 6
}
```
*** If you have a different date format in your log files:
```kotlin
val dateRegex = "\\d{4}-\\d{2}-\\d{2}"
val dateFormat = "yyyy-MM-dd"
val logInspector(dateRegex, dateFormat)
...
```