Skip to content

Instantly share code, notes, and snippets.

@jonboulle
Last active October 16, 2015 01:47
Show Gist options
  • Save jonboulle/86132305a24793423ebd to your computer and use it in GitHub Desktop.
Save jonboulle/86132305a24793423ebd to your computer and use it in GitHub Desktop.
go-systemd journal test
package main
import (
"fmt"
"github.com/coreos/go-systemd/journal"
"github.com/coreos/go-systemd/sdjournal"
)
func main() {
journal.Print(journal.PriNotice, "mooooooooooo")
j, err := sdjournal.NewJournal()
if err != nil {
panic(err)
}
err = j.SeekTail()
if err != nil {
panic(err)
}
for i := 0; i < 10; i++ {
j.Next()
s, err := j.GetData("MESSAGE")
if err != nil {
panic(err)
}
fmt.Println(s)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment