Renamed vars and switched to use zerolog

This commit is contained in:
David Allen 2024-07-30 14:02:12 -06:00
parent 606a7b47cc
commit b27e6b6a73
No known key found for this signature in database
GPG key ID: 717C593FF60A2ACC
7 changed files with 68 additions and 103 deletions

View file

@ -7,6 +7,7 @@ import (
"time"
"github.com/OpenCHAMI/magellan/internal/db/sqlite"
"github.com/rs/zerolog/log"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@ -24,16 +25,19 @@ var listCmd = &cobra.Command{
" magellan list\n" +
" magellan list --cache ./assets.db",
Run: func(cmd *cobra.Command, args []string) {
probeResults, err := sqlite.GetProbeResults(cachePath)
scannedResults, err := sqlite.GetScannedResults(cachePath)
if err != nil {
logrus.Errorf("failed toget probe results: %v\n", err)
}
format = strings.ToLower(format)
if format == "json" {
b, _ := json.Marshal(probeResults)
b, err := json.Marshal(scannedResults)
if err != nil {
log.Error().Err(err).Msgf("failed to unmarshal scanned results")
}
fmt.Printf("%s\n", string(b))
} else {
for _, r := range probeResults {
for _, r := range scannedResults {
fmt.Printf("%s:%d (%s) @ %s\n", r.Host, r.Port, r.Protocol, r.Timestamp.Format(time.UnixDate))
}
}