Browse Source

调整set tag log key

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

+ 1 - 1
adslib/device/device.go

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

+ 1 - 1
conf/config.toml

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