An open API service indexing awesome lists of open source software.

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

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)
...
```