소스 검색

wip:分类打印信息

wangkaiyue 2 년 전
부모
커밋
b4046ec126

+ 5 - 5
entity/activeUsers/groupSave.go

@@ -19,8 +19,8 @@ func SaveBatchGroup(userIds []string, groupType int, groupName, from string) {
 	now := time.Now().Format(date.Date_Full_Layout)
 	var finalCount int64 = 0
 	for i := 0; i < (arrLen/batchNum)+1; i++ {
-		start := batchNum * i
-		end := (batchNum + 1) * 100
+		start := i * batchNum
+		end := (i + 1) * batchNum
 		if end >= arrLen {
 			end = arrLen
 		}
@@ -32,12 +32,12 @@ func SaveBatchGroup(userIds []string, groupType int, groupName, from string) {
 			[]string{"user_mongoid", "group_type", "group_name", "source", "create_time"}, values); count > 0 {
 			finalCount += count
 		} else {
-			log.Printf("[ERROR] SaveBatchGroup index:%d value:%v error\n", i, values)
+			log.Printf("[MANAGER-ERR] SaveBatchGroup index:%d value:%v error\n", i, values)
 		}
 	}
 	if common.Int64All(arrLen) == finalCount {
-		log.Printf("[INFO] SaveBatchGroup save %v %s %s total %d finished:%d\n", common.If(groupType > 0, "定制化分析报告", "超前项目"), groupName, from, arrLen, finalCount)
+		log.Printf("[MANAGER-INFO] SaveBatchGroup save %v %s %s total %d finished:%d\n", common.If(groupType > 0, "定制化分析报告", "超前项目"), groupName, from, arrLen, finalCount)
 	} else {
-		log.Printf("[ERROR] SaveBatchGroup save %v %s %s total %d finished:%d\n", common.If(groupType > 0, "定制化分析报告", "超前项目"), groupName, from, arrLen, finalCount)
+		log.Printf("[MANAGER-ERR] SaveBatchGroup save %v %s %s total %d finished:%d\n", common.If(groupType > 0, "定制化分析报告", "超前项目"), groupName, from, arrLen, finalCount)
 	}
 }

+ 0 - 2
entity/mananger/aheadManager.go

@@ -8,7 +8,6 @@ import (
 	"leadGeneration/entity/search"
 	"leadGeneration/public"
 	"leadGeneration/vars"
-	"log"
 	"sort"
 	"sync"
 	"time"
@@ -107,7 +106,6 @@ func (this *AheadManager) UpdateUserGroupJob() {
 	this.Lock()
 	defer this.Unlock()
 	this.UserGroup = newMap
-	log.Printf("AheadManager NewGroup %v\n", newMap)
 }
 
 //getUserGroup 取用户

+ 10 - 7
entity/mananger/customManager.go

@@ -65,7 +65,7 @@ func (this *CustomManager) GetData(userId, keyWords string, isNew bool) map[stri
 	if bytes, err := redis.GetBytes(customCacheDb, fmt.Sprintf(customDataCacheKey, userId)); err == nil && bytes != nil {
 		rData := map[string]interface{}{}
 		if err := json.Unmarshal(*bytes, &rData); err != nil {
-			log.Printf("[ERROR]CustomManager %s GetData Error %v \n", userId, err)
+			log.Printf("[MANAGER-ERR]CustomManager %s GetData Error %v \n", userId, err)
 			return nil
 		}
 		return rData
@@ -112,7 +112,6 @@ func (this *CustomManager) UpdateUserGroupJob() {
 	defer this.Unlock()
 	this.UserGroup = newMap
 
-	log.Printf("CustomManager NewGroup %v\n", newMap)
 	go this.activityUserQueue(this.BatchFlag, userArr)
 }
 
@@ -120,6 +119,7 @@ func (this *CustomManager) getUserGroup() (userIds []string) {
 	//当前批次是否已有数据
 	rData := public.UserAnalyseDb.SelectBySql("SELECT user_mongoid AS uid FROM user_leadGeneration_group WHERE group_type = 1 AND group_name=?", this.BatchFlag)
 	if rData != nil || len(*rData) == 0 {
+		log.Printf("[MANAGER-INFO]CustomManager getUserGroup from Db Total is %d \n", len(*rData))
 		userIds = make([]string, 0, len(*rData))
 		for _, m := range *rData {
 			if uId, _ := m["uid"].(string); uId != "" {
@@ -129,6 +129,7 @@ func (this *CustomManager) getUserGroup() (userIds []string) {
 	}
 	//无数据则重新生成用户群组数据
 	if len(userIds) == 0 {
+		log.Printf("[MANAGER-INFO]CustomManager getUserGroup createNewGroup start\n")
 		var (
 			wg                            sync.WaitGroup
 			newActiveGroup, testUserGroup []string
@@ -142,7 +143,7 @@ func (this *CustomManager) getUserGroup() (userIds []string) {
 					testUserGroup = append(testUserGroup, uid)
 				}
 			}
-			activeUsers.SaveBatchGroup(newActiveGroup, 1, this.BatchFlag, "testUser")
+			activeUsers.SaveBatchGroup(testUserGroup, 1, this.BatchFlag, "testUser")
 		}()
 		//测试用户群组
 		go func() {
@@ -155,6 +156,8 @@ func (this *CustomManager) getUserGroup() (userIds []string) {
 		userIds = make([]string, 0, len(newActiveGroup)+len(testUserGroup))
 		userIds = append(userIds, newActiveGroup...)
 		userIds = append(userIds, testUserGroup...)
+
+		log.Printf("[MANAGER-INFO]CustomManager getUserGroup createNewGroup end Total %d\n", len(userIds))
 	}
 	return
 
@@ -164,18 +167,18 @@ func (this *CustomManager) getUserGroup() (userIds []string) {
 func (this *CustomManager) activityUserQueue(batchFlag string, userIds []string) {
 	for i, userId := range userIds {
 		if i%100 == 0 {
-			log.Printf("[INFO]CustomManager Batch %s Now(%d/%d)\n", batchFlag, len(userIds), i)
+			log.Printf("[MANAGER-INFO]CustomManager Batch %s Now(%d/%d)\n", batchFlag, i, len(userIds))
 		}
 		//当批次更新时,上批次停止
 		if this.BatchFlag != batchFlag {
-			log.Printf("[INFO]CustomManager Batch %s Is END At (%d/%d) \n", batchFlag, i, len(userIds))
+			log.Printf("[MANAGER-INFO]CustomManager Batch %s Is END At (%d/%d) \n", batchFlag, i, len(userIds))
 			break
 		}
 		activityUserQueue <- &SearchEntity{
 			UserId: userId,
 		}
 	}
-	log.Printf("[INFO]CustomManager Batch %s Is Finished !!!\n", batchFlag)
+	log.Printf("[MANAGER-INFO]CustomManager Batch %s Is Finished !!!\n", batchFlag)
 }
 
 // DoSearch 定制化分析报告查询队列
@@ -200,7 +203,7 @@ func (this *CustomManager) DoSearch() {
 		//查询结果处理
 		data := search.PotentialCustomizeAnalysis(obj.UserId, obj.Value)
 		if data == nil || len(data) == 0 {
-			log.Printf("[ERROR]CustomManager %s DoSearch %s Is Empty\n", obj.UserId, obj.Value)
+			log.Printf("[MANAGER-ERR]CustomManager %s DoSearch %s Is Empty\n", obj.UserId, obj.Value)
 			continue
 		}
 		//缓存结果

+ 5 - 5
entity/search/advancedProject.go

@@ -19,12 +19,12 @@ func AdvancedProject(userid, keyWord string) map[string]interface{} {
 	mae.Size = 2
 	mae.FormatParam.STime = time.Now().AddDate(0, -3, 0).Unix()
 	if !mae.KeyWordFormat(userid, keyWord) {
-		log.Printf("关键词格式化化失败 userid:%s,keyWord:%s", userid, keyWord)
+		log.Printf("[SEARCH-ERR]关键词格式化化失败 userid:%s,keyWord:%s", userid, keyWord)
 		return nil
 	}
-	log.Println("超前项目数据参数:", mae)
+	log.Println("[SEARCH-INFO]超前项目数据参数:", mae)
 	finalSql := fmt.Sprintf(mae.GetCommonQuerySqlWithAggs(), projectsNumber, mae.Size, projectsSortSource)
-	log.Println("超前项目es查询:", finalSql)
+	log.Println("[SEARCH-INFO]超前项目es查询:", finalSql)
 	res, _, data := public.GetAggs("bidding", "bidding", finalSql)
 	if res == nil || len(res) == 0 || data == nil || len(data) == 0 {
 		return nil
@@ -89,7 +89,7 @@ func AdvancedProject(userid, keyWord string) map[string]interface{} {
 		//id加密
 		resData[i]["_id"] = public.EncodeId(qutil.InterfaceToStr(resData[i]["_id"]))
 	}
-	log.Println("AdvancedProject redis data :", resData)
+	log.Println("[SEARCH-INFO]AdvancedProject redis data :", resData)
 	return map[string]interface{}{
 		"projectTop2":  resData,
 		"subTypeCount": redisData,
@@ -134,7 +134,7 @@ func (mae *MarketAnalysisEntity) KeyWordFormat(userid, keyWord string) (ret bool
 		dataType, _ := json.Marshal(aItems)
 		key := string(dataType)
 		if err := json.Unmarshal([]byte(key), &mae.FormatParam.KeysItems); err != nil {
-			log.Println("关键词格式化失败", aItems)
+			log.Println("[SEARCH-ERR]关键词格式化失败", aItems)
 			return false
 		}
 	}

+ 3 - 3
entity/search/customizedAnalysis.go

@@ -18,13 +18,13 @@ func PotentialCustomizeAnalysis(userid, keyWord string) map[string]interface{} {
 	aggs = append(aggs, aggs_buyerclass, buyer_procurement_scale, winner_procurement_scale)
 	mae.Types = 1
 	mae.FormatParam.STime = time.Now().AddDate(-1, 0, 0).Unix()
-	log.Println("定制化分析报告数据参数:", mae)
+	log.Println("[SEARCH-INFO]定制化分析报告数据参数:", mae)
 	if !mae.KeyWordFormat(userid, keyWord) {
-		log.Printf("关键词格式化化失败 userid:%s,keyWord:%s", userid, keyWord)
+		log.Printf("[SEARCH-ERR]关键词格式化化失败 userid:%s,keyWord:%s", userid, keyWord)
 		return nil
 	}
 	finalSql := fmt.Sprintf(mae.GetCommonQuerySqlWithAggs(), strings.Join(aggs, ","), mae.Size, "")
-	log.Println("定制化分析报告es查询:", finalSql)
+	log.Println("[SEARCH-INFO]定制化分析报告es查询:", finalSql)
 	res, _, _ := public.GetAggs("projectset", "projectset", finalSql)
 	if res == nil || len(res) == 0 {
 		return nil

+ 3 - 3
public/aggsSearchUtil.go

@@ -19,19 +19,19 @@ func GetAggs(index, itype, query string) (aggs elastic2.Aggregations, count int6
 	if client != nil {
 		defer func() {
 			if r := recover(); r != nil {
-				log.Println("[E]", r)
+				log.Println("[SEARCH-ERR]", r)
 				for skip := 1; ; skip++ {
 					_, file, line, ok := runtime.Caller(skip)
 					if !ok {
 						break
 					}
-					go log.Printf("%v,%v\n", file, line)
+					go log.Printf("[SEARCH-INFO]%v,%v\n", file, line)
 				}
 			}
 		}()
 		searchResult, err := client.Search().Index(index).Type(itype).Source(query).Do()
 		if err != nil {
-			log.Println("从ES查询出错", err.Error())
+			log.Println("[SEARCH-ERR]从ES查询出错", err.Error())
 		}
 		count = searchResult.Hits.TotalHits
 		hist = searchResult.Hits.Hits

+ 6 - 6
public/db.go

@@ -68,16 +68,16 @@ func init() {
 	if DbConf != nil {
 		if DbConf.Elasticsearch.Main != nil {
 			elastic.InitElasticSize(DbConf.Elasticsearch.Main.Address, DbConf.Elasticsearch.Main.Size)
-			log.Println("初始化 elasticsearch")
+			log.Println("[SYSTEM]初始化 elasticsearch")
 		}
 		//初始化redis
 		if DbConf.Redis.Main != nil {
-			log.Println("初始化 redis")
+			log.Println("[SYSTEM]初始化 redis")
 			redis.InitRedisBySize(DbConf.Redis.Main.Address, 100, 30, 300)
 		}
 		//
 		if DbConf.Mongodb.Main != nil {
-			log.Println("初始化 mongodb main")
+			log.Println("[SYSTEM]初始化 mongodb main")
 			MQFW = m.MongodbSim{
 				MongodbAddr: DbConf.Mongodb.Main.Address,
 				Size:        DbConf.Mongodb.Main.Size,
@@ -87,7 +87,7 @@ func init() {
 			MQFW.InitPool()
 		}
 		if DbConf.Mongodb.Log != nil {
-			log.Println("初始化 mongodb log")
+			log.Println("[SYSTEM]初始化 mongodb log")
 			Mgo_Log = m.MongodbSim{
 				MongodbAddr: DbConf.Mongodb.Log.Address,
 				Size:        DbConf.Mongodb.Log.Size,
@@ -100,7 +100,7 @@ func init() {
 		}
 
 		if DbConf.Mysql.Main != nil {
-			log.Println("初始化 main mysql")
+			log.Println("[SYSTEM]初始化 main mysql")
 			MainMysql = &mysql.Mysql{
 				Address:      DbConf.Mysql.Main.Address,
 				UserName:     DbConf.Mysql.Main.UserName,
@@ -113,7 +113,7 @@ func init() {
 		}
 
 		if DbConf.Mysql.Active != nil {
-			log.Println("初始化 active mysql")
+			log.Println("[SYSTEM]初始化 active mysql")
 			UserAnalyseDb = &mysql.Mysql{
 				Address:      DbConf.Mysql.Active.Address,
 				UserName:     DbConf.Mysql.Active.UserName,

+ 2 - 2
services/action.go

@@ -43,7 +43,7 @@ func (this *LeadGeneration) GetDate() {
 		return rData, nil
 	}()
 	if errMsg != nil {
-		log.Printf("%s LeadGeneration GetDate 异常:%s\n", userId, errMsg.Error())
+		log.Printf("[ACTION]%s LeadGeneration GetDate 异常:%s\n", userId, errMsg.Error())
 	}
 	this.ServeJson(NewResult(rData, errMsg))
 }
@@ -55,7 +55,7 @@ func (this *LeadGeneration) ClickRecord() {
 		return mananger.JyAheadManager.Click(userId), nil
 	}()
 	if errMsg != nil {
-		log.Printf("%s LeadGeneration ClickRecord 异常:%s\n", userId, errMsg.Error())
+		log.Printf("[ACTION]%s LeadGeneration ClickRecord 异常:%s\n", userId, errMsg.Error())
 	}
 	this.ServeJson(NewResult(rData, errMsg))
 }

+ 2 - 2
services/filter/logfilter.go

@@ -51,7 +51,7 @@ func SaveLogTask() {
 		tmp := arr
 		arr = make([]map[string]interface{}, 0)
 		go func() {
-			log.Println("timer..save..visit..log", len(tmp))
+			log.Println("[SYSTEM]timer..save..visit..log", len(tmp))
 			public.Mgo_Log.SaveBulk("jy_logs", tmp...)
 		}()
 	}
@@ -93,7 +93,7 @@ func (l *logFilter) addLog() {
 		tmp := arr
 		arr = make([]map[string]interface{}, 0)
 		go func() {
-			log.Println("save..visit..log", len(tmp))
+			log.Println("[SYSTEM]save..visit..log", len(tmp))
 			public.Mgo_Log.SaveBulk("jy_logs", tmp...)
 		}()
 	}