improved logging in main.go (tiny little bit)

This commit is contained in:
Bora Alper 2017-11-05 01:50:54 +00:00
parent 453ecae634
commit e9d23c3292

View File

@ -15,6 +15,7 @@ import (
"magnetico/magneticod/dht" "magnetico/magneticod/dht"
"magnetico/persistence" "magnetico/persistence"
"encoding/hex"
) )
type cmdFlags struct { type cmdFlags struct {
@ -85,7 +86,7 @@ func main() {
for stopped := false; !stopped; { for stopped := false; !stopped; {
select { select {
case result := <-trawlingManager.Output(): case result := <-trawlingManager.Output():
logger.Info("result: ", zap.String("hash", result.InfoHash.String())) zap.L().Info("Trawled!", zap.String("infoHash", result.InfoHash.String()))
exists, err := database.DoesTorrentExist(result.InfoHash[:]) exists, err := database.DoesTorrentExist(result.InfoHash[:])
if err != nil { if err != nil {
zap.L().Fatal("Could not check whether torrent exists!", zap.Error(err)) zap.L().Fatal("Could not check whether torrent exists!", zap.Error(err))
@ -98,7 +99,7 @@ func main() {
logger.Sugar().Fatalf("Could not add new torrent %x to the database: %s", logger.Sugar().Fatalf("Could not add new torrent %x to the database: %s",
metadata.InfoHash, err.Error()) metadata.InfoHash, err.Error())
} }
logger.Sugar().Infof("D I S C O V E R E D: `%s` %x", metadata.Name, metadata.InfoHash) zap.L().Info("Fetched!", zap.String("name", metadata.Name), zap.String("infoHash", hex.EncodeToString(metadata.InfoHash)))
case <-interruptChan: case <-interruptChan:
trawlingManager.Terminate() trawlingManager.Terminate()