Skip to content

Commit

Permalink
clean up logs in telemon
Browse files Browse the repository at this point in the history
  • Loading branch information
mpenkov committed Nov 17, 2023
1 parent ac9a996 commit 4eae526
Showing 1 changed file with 2 additions and 27 deletions.
29 changes: 2 additions & 27 deletions telemon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,31 +211,6 @@ func fetchMessages(c *client.Client, seqNums []uint32) (result []*imap.Message,
return result, nil
}

func lastSeenSeqNum(tempDir string) uint32 {
data, err := os.ReadFile(tempDir + "/seqnum")
if err != nil {
return 0
}

var seqnum uint32
_, err = fmt.Sscanf(string(data), "%d\n", &seqnum)
if err != nil {
return 0
}

return seqnum
}

func writeLastSeenSeqNum(tempDir string, seqNum uint32) error {
err := os.MkdirAll(tempDir, 0o700)
if err != nil {
return err
}
line := fmt.Sprintf("%d\n", seqNum)
err = os.WriteFile(tempDir+"/seqnum", []byte(line), 0o600)
return err
}

//
// Calculate the sequence number range
//
Expand Down Expand Up @@ -375,8 +350,6 @@ func readMatchingMessages(config Config, readonly bool) ([]*imap.Message, error)
return []*imap.Message{}, err
}

logPrintf("[seqnum: %d seen: %t] %s\n", msg.SeqNum, seen, subject)

match := false
for _, sf := range subjectFilters {
if sf.Match([]byte(subject)) {
Expand All @@ -385,6 +358,8 @@ func readMatchingMessages(config Config, readonly bool) ([]*imap.Message, error)
}
}

logPrintf("[seqnum: %d seen: %t match: %t] %s\n", msg.SeqNum, seen, match, subject)

if !seen && match {
seqNums = append(seqNums, msg.SeqNum)
}
Expand Down

0 comments on commit 4eae526

Please sign in to comment.