Move from log.Printf to fmt.Printf to avoid timestamp

This commit is contained in:
maride 2019-11-27 16:48:14 +01:00
parent 19f4143858
commit 62c11bd3ac
2 changed files with 16 additions and 16 deletions

View File

@ -173,19 +173,19 @@ func printDNSSummary() {
// Prints a summary of all DNS questions // Prints a summary of all DNS questions
func printDNSQuestionSummary() { func printDNSQuestionSummary() {
// Overall question stats // Overall question stats
log.Printf("%d DNS questions in total", numQuestions) fmt.Printf("%d DNS questions in total\n", numQuestions)
log.Printf("%s records", generateDNSTypeSummary(questionType)) fmt.Printf("%s records\n", generateDNSTypeSummary(questionType))
log.Printf("%d unique domains of %d base domains, of which are %d private (non-ICANN) TLDs.", len(questionDomains), len(questionBaseDomains), len(questionPrivateDomains)) fmt.Printf("%d unique domains of %d base domains, of which are %d private (non-ICANN) TLDs.\n", len(questionDomains), len(questionBaseDomains), len(questionPrivateDomains))
// Output base domains asked for // Output base domains asked for
if len(questionBaseDomains) > 0 { if len(questionBaseDomains) > 0 {
log.Println("Asked for these base domains:") fmt.Println("Asked for these base domains:")
printTree(questionBaseDomains) printTree(questionBaseDomains)
} }
// Output private domains // Output private domains
if len(questionPrivateDomains) > 0 { if len(questionPrivateDomains) > 0 {
log.Println("Asked for these private (non-ICANN managed) domains:") fmt.Println("Asked for these private (non-ICANN managed) domains:")
printTree(questionPrivateDomains) printTree(questionPrivateDomains)
} }
} }
@ -193,26 +193,26 @@ func printDNSQuestionSummary() {
// Prints a summary of all DNS answers // Prints a summary of all DNS answers
func printDNSAnswerSummary() { func printDNSAnswerSummary() {
// Overall question stats // Overall question stats
log.Printf("%d DNS answers in total", numAnswers) fmt.Printf("%d DNS answers in total\n", numAnswers)
log.Printf("%s records", generateDNSTypeSummary(answerType)) fmt.Printf("%s records\n", generateDNSTypeSummary(answerType))
log.Printf("%d unique domains of %d base domains, of which are %d private (non-ICANN) TLDs.", len(answerDomains), len(answerBaseDomains), len(answerPrivateDomains)) fmt.Printf("%d unique domains of %d base domains, of which are %d private (non-ICANN) TLDs.\n", len(answerDomains), len(answerBaseDomains), len(answerPrivateDomains))
// Output base domains answered with // Output base domains answered with
if len(answerBaseDomains) > 0 { if len(answerBaseDomains) > 0 {
log.Println("Answered with these base domains:") fmt.Println("Answered with these base domains:")
printTree(answerBaseDomains) printTree(answerBaseDomains)
} }
// Output private domains // Output private domains
if len(answerPrivateDomains) > 0 { if len(answerPrivateDomains) > 0 {
log.Println("Answered with these private (non-ICANN managed) domains:") fmt.Println("Answered with these private (non-ICANN managed) domains:")
printTree(answerPrivateDomains) printTree(answerPrivateDomains)
} }
// Check for public and private IPs // Check for public and private IPs
log.Printf("Answered with %d public IP addresses and %d private IP addresses", len(answerPublicIPv4), len(answerPrivateIPv4)) fmt.Printf("Answered with %d public IP addresses and %d private IP addresses\n", len(answerPublicIPv4), len(answerPrivateIPv4))
if len(answerPrivateIPv4) > 0 { if len(answerPrivateIPv4) > 0 {
log.Println("Private IP addresses in answer:") fmt.Println("Private IP addresses in answer:")
printTree(answerPrivateIPv4) printTree(answerPrivateIPv4)
} }
} }
@ -223,9 +223,9 @@ func printTree(strarr []string) {
for iter, elem := range strarr { for iter, elem := range strarr {
// check if we got the last element // check if we got the last element
if iter < len(strarr) - 1 { if iter < len(strarr) - 1 {
log.Printf("|- %s", elem) fmt.Printf("|- %s\n", elem)
} else { } else {
log.Printf("'- %s\n\n", elem) fmt.Printf("'- %s\n\n", elem)
} }
} }
} }

View File

@ -2,10 +2,10 @@ package main
import ( import (
"flag" "flag"
"fmt"
"github.com/google/gopacket" "github.com/google/gopacket"
"github.com/google/gopacket/layers" "github.com/google/gopacket/layers"
"github.com/google/gopacket/pcap" "github.com/google/gopacket/pcap"
"log"
) )
var ( var (
@ -27,7 +27,7 @@ func openPCAP() (*gopacket.PacketSource, layers.LinkType, error) {
} }
// Output basic information about this PCAP // Output basic information about this PCAP
log.Printf("PCAP capture link type is %s (ID %d)", handle.LinkType().String(), handle.LinkType()) fmt.Printf("PCAP capture link type is %s (ID %d)\n", handle.LinkType().String(), handle.LinkType())
// Open given handle as packet source and return it // Open given handle as packet source and return it
packetSource := gopacket.NewPacketSource(handle, handle.LinkType()) packetSource := gopacket.NewPacketSource(handle, handle.LinkType())