mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-09-08 10:21:27 +00:00
Add pkg/kmsg
This very simple program reads from `/dev/kmsg` and logs the output. Signed-off-by: David Scott <dave.scott@docker.com>
This commit is contained in:
25
pkg/kmsg/main.go
Normal file
25
pkg/kmsg/main.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
// Log the kernel log buffer (from /dev/kmsg)
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/euank/go-kmsg-parser/kmsgparser"
|
||||
)
|
||||
|
||||
func main() {
|
||||
parser, err := kmsgparser.NewParser()
|
||||
if err != nil {
|
||||
log.Fatalf("unable to create parser: %v", err)
|
||||
}
|
||||
defer parser.Close()
|
||||
|
||||
kmsg := parser.Parse()
|
||||
|
||||
for msg := range kmsg {
|
||||
fmt.Printf("(%d) - %s: %s", msg.SequenceNumber, msg.Timestamp.Format(time.RFC3339Nano), msg.Message)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user