diff options
| author | horus_arch | 2018-02-17 12:06:05 +0100 |
|---|---|---|
| committer | horus_arch | 2018-02-17 12:06:05 +0100 |
| commit | 9ebf51364773dae6db4c0c47d77710c9f1a37b51 (patch) | |
| tree | f01ba3b503920ef3301cdae0ceeb402e294d0d83 /crawler/log.go | |
| parent | 13724d7e56299213e9b10eef6f315569127b53f2 (diff) | |
| download | alkobote-9ebf51364773dae6db4c0c47d77710c9f1a37b51.tar.gz | |
Minor refactoring. (crawler)
Diffstat (limited to 'crawler/log.go')
| -rw-r--r-- | crawler/log.go | 53 |
1 files changed, 23 insertions, 30 deletions
diff --git a/crawler/log.go b/crawler/log.go index 3a6afa0..7d8e707 100644 --- a/crawler/log.go +++ b/crawler/log.go @@ -45,21 +45,7 @@ func Println(err error, msg string) { func PrintlnOffer(offer Angebot, msg string) { - log.WithFields( - log.Fields{ - "Name": offer.Name, - "Shop": offer.Shop, - "ABV": offer.Abv, - "Volume": offer.Volume, - "Url": offer.Url, - "Original Price": offer.Original_price, - "Discounted Price": offer.Discounted_price, - "Base Price": offer.Base_price, - "Image_url": offer.Image_url, - "Spirit Type": offer.Spirit_type, - "Valid Until": offer.Valid_until, - }, - ).Println(msg) + log.WithFields(getFields(offer)).Println(msg) } func Debug(err error, msg string) { @@ -76,19 +62,26 @@ func Debug(err error, msg string) { func DebugOffer(offer Angebot, msg string) { - log.WithFields( - log.Fields{ - "Name": offer.Name, - "Shop": offer.Shop, - "ABV": offer.Abv, - "Volume": offer.Volume, - "Url": offer.Url, - "Original Price": offer.Original_price, - "Discounted Price": offer.Discounted_price, - "Base Price": offer.Base_price, - "Image_url": offer.Image_url, - "Spirit Type": offer.Spirit_type, - "Valid Until": offer.Valid_until, - }, - ).Debug(msg) + log.WithFields(getFields(offer)).Debug(msg) +} + +func WarnOffer(offer Angebot, msg string) { + + log.WithFields(getFields(offer)).Warn(msg) +} + +func getFields(offer Angebot) log.Fields { + return log.Fields{ + "Name": offer.Name, + "Shop": offer.Shop, + "ABV": offer.Abv, + "Volume": offer.Volume, + "Url": offer.Url, + "Original Price": offer.Original_price, + "Discounted Price": offer.Discounted_price, + "Base Price": offer.Base_price, + "Image_url": offer.Image_url, + "Spirit Type": offer.Spirit_type, + "Valid Until": offer.Valid_until, + } } |
