Adding some debug options
This commit is contained in:
parent
43ed2ea438
commit
d98ac3058e
@ -33,6 +33,6 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
data := resolver.PerformZoneTransfer(cfg)
|
||||
data := resolver.PerformZoneTransfer(cfg, debug)
|
||||
shell.CreateShellAliases(data, user, cfg)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"rfi-sower/pkg/utils"
|
||||
"strings"
|
||||
|
||||
"git.linuxrocker.com/mattburchett/go_tab-magic/pkg/config"
|
||||
@ -29,7 +30,10 @@ func lookupName(fqdn, serverAddr string) (string, error) {
|
||||
}
|
||||
|
||||
// PerformZoneTransfer performs zone transfers and gathers a list from config.Domains
|
||||
func PerformZoneTransfer(config config.Config) []string {
|
||||
func PerformZoneTransfer(config config.Config, debug bool) []string {
|
||||
if debug {
|
||||
defer utils.LogElapsedTime("Perform Zone Transfer")
|
||||
}
|
||||
data := make([]string, 0)
|
||||
|
||||
// Do the transfer
|
||||
|
15
pkg/utils/logging.go
Normal file
15
pkg/utils/logging.go
Normal file
@ -0,0 +1,15 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
//LogElapsedTime provides a function that can be used to log the time elapsed between when this function is invoked, to the time the returned function is invoked.
|
||||
//Adding "defer LogElapsedTime("my log")" at the beginning of any function will log the time it takes to execute that function.
|
||||
func LogElapsedTime(what string) func() {
|
||||
start := time.Now()
|
||||
return func() {
|
||||
log.Printf("%s, Total Time Taken: %v\n", what, time.Since(start))
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user