import kotlinx.coroutines.*
import org.cikit.syslog.*
import java.io.FileInputStream
import java.nio.*
import java.nio.charset.*
fun main(args: Array<String>) = runBlocking<Unit> {
val scanner = ProgressiveScanner()
val p = SyslogParser()
val tmp = InMemoryByteChannel()
//feed input
launch {
val buffer = ByteBuffer.wrap(FileInputStream("logfile").readBytes())
scanner.send(buffer)
scanner.close()
}
//process log records
while (p.parse5424(scanner)) {
println("${p.ts()} ${p.host()}")
if (scanner.readUntil(tmp) { it == '\n'.code.toByte() }) {
scanner.readByte()
}
println(tmp.toString(Charsers.UTF_8))
}
assert(scanner.isClosed())
println("Done!")
}
-
Notifications
You must be signed in to change notification settings - Fork 0
rfc5424 syslog implementation
License
b8b/cikit-syslog
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
rfc5424 syslog implementation
Topics
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published