Skip to content

Commit

Permalink
verbose flag
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensayshi committed Sep 6, 2019
1 parent 0324fd2 commit e5fa8d7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/cmd/yubitoast/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ import (
var pkAuthRegexp = regexp.MustCompile("PKAUTH OPENPGP\\.3$")
var pkSignRegexp = regexp.MustCompile("PKSIGN --hash=.+ OPENPGP\\.1$")

var logfile = flag.String("logfile", "/var/log/gpg-agent.log", "path to gpg-agent.log")
var fLogfile = flag.String("logfile", "/var/log/gpg-agent.log", "path to gpg-agent.log")
var fVerbose = flag.Bool("verbose", false, "verbose logging")

func main() {
flag.Parse()

t, err := tail.TailFile(*logfile, tail.Config{
t, err := tail.TailFile(*fLogfile, tail.Config{
Follow: true,
// seek to end of file
Location: &tail.SeekInfo{
Expand All @@ -28,12 +29,14 @@ func main() {
},
})
if err != nil {
panic(errors.Wrapf(err, "tail gpg-agent log [%s]", (logfile)))
panic(errors.Wrapf(err, "tail gpg-agent log [%s]", (fLogfile)))
}

// now we wait
for line := range t.Lines {
fmt.Println(line.Text)
if *fVerbose {
fmt.Println(line.Text)
}

if pkAuthRegexp.Match([]byte(line.Text)) {
showNotification("Authenticate")
Expand Down

0 comments on commit e5fa8d7

Please sign in to comment.