summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crawler/log.go17
-rw-r--r--crawler/sanitize.go6
-rw-r--r--crawler/shop_drankdozijn.go16
3 files changed, 28 insertions, 11 deletions
diff --git a/crawler/log.go b/crawler/log.go
index 26f4abd..111df53 100644
--- a/crawler/log.go
+++ b/crawler/log.go
@@ -53,6 +53,23 @@ func (offer Angebot) Debug(msg string) {
log.WithFields(offer.getFields()).Debug(msg)
}
+func Trace(err error, msg string) {
+ if err != nil {
+ log.WithFields(
+ log.Fields{
+ "error": err.Error(),
+ },
+ ).Trace(msg)
+ } else {
+ log.Trace(msg)
+ }
+}
+
+func (offer Angebot) Trace(msg string) {
+
+ log.WithFields(offer.getFields()).Trace(msg)
+}
+
func (offer Angebot) Warn(msg string) {
log.WithFields(offer.getFields()).Warn(msg)
diff --git a/crawler/sanitize.go b/crawler/sanitize.go
index 25e8a09..8eb9444 100644
--- a/crawler/sanitize.go
+++ b/crawler/sanitize.go
@@ -66,7 +66,7 @@ func sanitize_offer(angebote []Angebot, shop Shop, try int) []Angebot {
offer.Website = ""
if offer.Age == 0 {
- offer.Debug("GREP")
+ //offer.Trace("GREP")
}
W = append(W, offer)
@@ -272,7 +272,7 @@ func get_age_from_name(name string) int {
}
age_noisy := r_years.FindString(name)
if age_noisy == "" {
- log.Debug("get_age_from_name: No Age found in (" + name + ")")
+ log.Trace("get_age_from_name: No Age found in (" + name + ")")
return 0
}
@@ -292,7 +292,7 @@ func get_age_from_name(name string) int {
func sanitize_image_url(url string) error {
- log.Debugf("sanitize_image_url: Making HEAD request to %s \n", url)
+ log.Tracef("sanitize_image_url: Making HEAD request to %s \n", url)
resp, err := http.Head(url)
if err != nil {
return fmt.Errorf("sanitize_image_url: HEAD request failed. Got error: %s \n", err.Error())
diff --git a/crawler/shop_drankdozijn.go b/crawler/shop_drankdozijn.go
index 20018af..2383ec2 100644
--- a/crawler/shop_drankdozijn.go
+++ b/crawler/shop_drankdozijn.go
@@ -166,7 +166,7 @@ func (app *App) ScrapeDrankdozijn(shop Shop) []Angebot {
if "Champagner" == tmp_type {
if tmp_type != W.Spirit_type {
- W.Debug("Spirit Type Changed: " + W.Spirit_type + " -> " + tmp_type)
+ W.Trace("Spirit Type Changed: " + W.Spirit_type + " -> " + tmp_type)
W.Spirit_type = tmp_type
}
W.Spirit_type = tmp_type
@@ -175,19 +175,19 @@ func (app *App) ScrapeDrankdozijn(shop Shop) []Angebot {
switch W.Spirit_type {
case "Cognac":
if tmp_type != W.Spirit_type {
- W.Debug("Spirit Type Changed: " + W.Spirit_type + " -> " + tmp_type)
+ W.Trace("Spirit Type Changed: " + W.Spirit_type + " -> " + tmp_type)
W.Spirit_type = tmp_type
}
W.Spirit_type = tmp_type
case "Brandy":
if tmp_type != W.Spirit_type {
- W.Debug("Spirit Type Changed: " + W.Spirit_type + " -> " + tmp_type)
+ W.Trace("Spirit Type Changed: " + W.Spirit_type + " -> " + tmp_type)
W.Spirit_type = tmp_type
}
W.Spirit_type = tmp_type
case "Sherry":
if tmp_type != W.Spirit_type {
- W.Debug("Spirit Type Changed: " + W.Spirit_type + " -> " + tmp_type)
+ W.Trace("Spirit Type Changed: " + W.Spirit_type + " -> " + tmp_type)
W.Spirit_type = tmp_type
}
W.Spirit_type = tmp_type
@@ -195,28 +195,28 @@ func (app *App) ScrapeDrankdozijn(shop Shop) []Angebot {
retest_type := detect_spirit_type(W.Name)
if "Likör" != retest_type && "Verschiedenes" != retest_type {
if tmp_type != W.Spirit_type {
- W.Debug("Spirit Type Changed: " + W.Spirit_type + " -> " + retest_type)
+ W.Trace("Spirit Type Changed: " + W.Spirit_type + " -> " + retest_type)
W.Spirit_type = tmp_type
}
W.Spirit_type = detect_spirit_type(W.Name)
}
if "Tequila" == tmp_type {
if tmp_type != W.Spirit_type {
- W.Debug("Spirit Type Changed: " + W.Spirit_type + " -> " + tmp_type)
+ W.Trace("Spirit Type Changed: " + W.Spirit_type + " -> " + tmp_type)
W.Spirit_type = tmp_type
}
W.Spirit_type = tmp_type
}
if "Mezcal" == tmp_type {
if tmp_type != W.Spirit_type {
- W.Debug("Spirit Type Changed: " + W.Spirit_type + " -> " + tmp_type)
+ W.Trace("Spirit Type Changed: " + W.Spirit_type + " -> " + tmp_type)
W.Spirit_type = tmp_type
}
W.Spirit_type = tmp_type
}
if "Baijiu" == tmp_type {
if tmp_type != W.Spirit_type {
- W.Debug("Spirit Type Changed: " + W.Spirit_type + " -> " + tmp_type)
+ W.Trace("Spirit Type Changed: " + W.Spirit_type + " -> " + tmp_type)
W.Spirit_type = tmp_type
}
W.Spirit_type = tmp_type