Sfoglia il codice sorgente

调整set tag log key

jiantaoli 4 anni fa
parent
commit
1675d1d6d2
3 ha cambiato i file con 5 aggiunte e 8 eliminazioni
  1. 3 6
      ads_handler.go
  2. 1 1
      adslib/device/device.go
  3. 1 1
      conf/config.toml

+ 3 - 6
ads_handler.go

@@ -38,7 +38,7 @@ func adsHandler(c *gin.Context) {
38 38
 
39 39
 	log.Printf("%+v", request)
40 40
 
41
-	// 放这里主要为了拿到reqeust id做日志记录
41
+	// 放这里主要为了拿到request id做日志记录
42 42
 	dspInfo := utils.DspParam{}
43 43
 	dspInfo.Init()
44 44
 
@@ -83,7 +83,7 @@ func adsHandler(c *gin.Context) {
83 83
 		c.String(404, "ip 2 region failed: %s", err)
84 84
 		return
85 85
 	}
86
-	fmt.Printf("ip 2 region: %s, %+v\n", ip, ipInfo)
86
+	log.WithField("request_id", dspInfo.RequestId).Infof("ip 2 region: %s, %+v", ip, ipInfo)
87 87
 
88 88
 	// 上報
89 89
 	if request.NewAdsFlag == 1 {
@@ -159,10 +159,8 @@ func adsHandler(c *gin.Context) {
159 159
 		// 需要凭空
160 160
 		log.WithField("request_id", dspInfo.RequestId).Infof("need control: %d", lastReqTime)
161 161
 		needControl = true
162
-		device.SetAdsTagLog(advertiser, request.ReqSource, "DS_FREQ_0", cityCode)
163 162
 	} else {
164 163
 		device.SetIpReqTime(ip, time.Now().Unix())
165
-		device.SetAdsTagLog(advertiser, request.ReqSource, "DS_FREQ_1", cityCode)
166 164
 	}
167 165
 
168 166
 	//### 检查是否是ip黑名单
@@ -173,7 +171,6 @@ func adsHandler(c *gin.Context) {
173 171
 		return
174 172
 	}
175 173
 	if isIpBlack {
176
-		graylog.LogApi("black_ip_list", ip, "", request.ReqSource)
177 174
 		device.SetAdsTagLog(advertiser, request.ReqSource, "DS_BLACK_IP", cityCode)
178 175
 	}
179 176
 
@@ -270,7 +267,7 @@ func adsHandler(c *gin.Context) {
270 267
 					IP           string `json:"ip"`
271 268
 					City         string `json:"city"`
272 269
 					CityCode     int    `json:"city_code"`
273
-					Province     string
270
+					Province     string `json:"province"`
274 271
 					HitFlag      int    `json:"hit_flag"`
275 272
 					LeftCnt      int    `json:"left_cnt"`
276 273
 					ReplaceUa    string `json:"replace_ua"`

+ 1 - 1
adslib/device/device.go

@@ -30,7 +30,7 @@ func setTagLog(key string) {
30 30
 	dateInt, _ := strconv.Atoi(time.Now().Format("20060102"))
31 31
 	k := fmt.Sprintf("{%s}___{%d}", key, dateInt)
32 32
 	_, _ = conn.Do("INCR", k)
33
-	_, _ = conn.Do("SADD", "fresh_all_keys", k)
33
+	_, _ = conn.Do("SADD", fmt.Sprintf("fresh_all_keys_%d", dateInt), k)
34 34
 }
35 35
 
36 36
 // 存储ip上一次请求时间

+ 1 - 1
conf/config.toml

@@ -12,7 +12,7 @@ ip2region_file = "../conf/ip2region_20200113.db"
12 12
 log_path = "../log"
13 13
 redis_host="r-wz9sbx1faq7j6zxxgt.redis.rds.aliyuncs.com:6379"
14 14
 redis_password="3iXAJFuI$J"
15
-log_level=trace
15
+log_level="trace"
16 16
 
17 17
 
18 18
 ## 流量占比控制