Skip to content

Commit 0232f52

Browse files
committed
log
1 parent 6efe13d commit 0232f52

File tree

11 files changed

+58
-53
lines changed

11 files changed

+58
-53
lines changed

cmd/open_im_api/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
apiThird "Open_IM/internal/api/third"
1212
"Open_IM/internal/api/user"
1313
"Open_IM/pkg/common/config"
14-
"Open_IM/pkg/common/constant"
1514
"Open_IM/pkg/common/log"
1615
"Open_IM/pkg/utils"
1716
"flag"
@@ -21,10 +20,11 @@ import (
2120

2221
"github.com/gin-gonic/gin"
2322
//"syscall"
23+
"Open_IM/pkg/common/constant"
2424
)
2525

2626
func main() {
27-
27+
log.NewPrivateLog(constant.LogFileName)
2828
gin.SetMode(gin.ReleaseMode)
2929
f, _ := os.Create("../logs/api.log")
3030
gin.DefaultWriter = io.MultiWriter(f)
@@ -136,7 +136,7 @@ func main() {
136136
officeGroup.POST("/get_send_tag_log", office.GetTagSendLogs)
137137
}
138138
apiThird.MinioInit()
139-
log.NewPrivateLog(constant.LogFileName)
139+
log.Info("", "MinioInit fin")
140140
ginPort := flag.Int("port", 10000, "get ginServerPort from cmd,default 10000 as port")
141141
flag.Parse()
142142
r.Run(":" + strconv.Itoa(*ginPort))

cmd/open_im_demo/main.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@ package main
22

33
import (
44
"Open_IM/internal/demo/register"
5-
"Open_IM/pkg/common/constant"
6-
"Open_IM/pkg/common/log"
75
"Open_IM/pkg/utils"
86
"flag"
97
"io"
108
"os"
119
"strconv"
1210

11+
"Open_IM/pkg/common/constant"
12+
"Open_IM/pkg/common/log"
1313
"github.com/gin-gonic/gin"
1414
)
1515

1616
func main() {
17+
log.NewPrivateLog(constant.LogFileName)
1718
gin.SetMode(gin.ReleaseMode)
1819
f, _ := os.Create("../logs/api.log")
1920
gin.DefaultWriter = io.MultiWriter(f)
@@ -29,7 +30,7 @@ func main() {
2930
authRouterGroup.POST("/login", register.Login)
3031
authRouterGroup.POST("/reset_password", register.ResetPassword)
3132
}
32-
log.NewPrivateLog(constant.LogFileName)
33+
3334
ginPort := flag.Int("port", 42233, "get ginServerPort from cmd,default 42233 as port")
3435
flag.Parse()
3536
r.Run(":" + strconv.Itoa(*ginPort))

cmd/open_im_msg_gateway/main.go

+3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ package main
22

33
import (
44
"Open_IM/internal/msg_gateway/gate"
5+
"Open_IM/pkg/common/constant"
6+
"Open_IM/pkg/common/log"
57
"flag"
68
"sync"
79
)
810

911
func main() {
12+
log.NewPrivateLog(constant.LogFileName)
1013
rpcPort := flag.Int("rpc_port", 10400, "rpc listening port")
1114
wsPort := flag.Int("ws_port", 17778, "ws listening port")
1215
flag.Parse()

cmd/open_im_msg_transfer/main.go

+3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ package main
22

33
import (
44
"Open_IM/internal/msg_transfer/logic"
5+
"Open_IM/pkg/common/constant"
6+
"Open_IM/pkg/common/log"
57
"sync"
68
)
79

810
func main() {
911
var wg sync.WaitGroup
1012
wg.Add(1)
13+
log.NewPrivateLog(constant.LogFileName)
1114
logic.Init()
1215
logic.Run()
1316
wg.Wait()

cmd/open_im_push/main.go

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package main
22

33
import (
44
"Open_IM/internal/push/logic"
5+
"Open_IM/pkg/common/constant"
6+
"Open_IM/pkg/common/log"
57
"flag"
68
"sync"
79
)
@@ -11,6 +13,7 @@ func main() {
1113
flag.Parse()
1214
var wg sync.WaitGroup
1315
wg.Add(1)
16+
log.NewPrivateLog(constant.LogFileName)
1417
logic.Init(*rpcPort)
1518
logic.Run()
1619
wg.Wait()

cmd/open_im_timer_task/main.go

+22-25
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ package main
22

33
import (
44
"Open_IM/pkg/common/constant"
5-
commonDB "Open_IM/pkg/common/db"
6-
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
75
"Open_IM/pkg/common/log"
8-
"time"
96
)
107

118
func main() {
@@ -40,27 +37,27 @@ func main() {
4037
// time.Sleep(time.Duration(sleepTime) * time.Second)
4138
// }
4239
//}
43-
for {
44-
uidList, err := im_mysql_model.SelectAllUserID()
45-
if err != nil {
46-
//log.NewError("999999", err.Error())
47-
} else {
48-
for _, v := range uidList {
49-
minSeq, err := commonDB.DB.GetMinSeqFromMongo(v)
50-
if err != nil {
51-
//log.NewError("999999", "get user minSeq err", err.Error(), v)
52-
continue
53-
} else {
54-
err := commonDB.DB.SetUserMinSeq(v, minSeq)
55-
if err != nil {
56-
//log.NewError("999999", "set user minSeq err", err.Error(), v)
57-
}
58-
}
59-
time.Sleep(time.Duration(100) * time.Millisecond)
60-
}
61-
62-
}
63-
64-
}
40+
//for {
41+
// uidList, err := im_mysql_model.SelectAllUserID()
42+
// if err != nil {
43+
// //log.NewError("999999", err.Error())
44+
// } else {
45+
// for _, v := range uidList {
46+
// minSeq, err := commonDB.DB.GetMinSeqFromMongo(v)
47+
// if err != nil {
48+
// //log.NewError("999999", "get user minSeq err", err.Error(), v)
49+
// continue
50+
// } else {
51+
// err := commonDB.DB.SetUserMinSeq(v, minSeq)
52+
// if err != nil {
53+
// //log.NewError("999999", "set user minSeq err", err.Error(), v)
54+
// }
55+
// }
56+
// time.Sleep(time.Duration(100) * time.Millisecond)
57+
// }
58+
//
59+
// }
60+
//
61+
//}
6562

6663
}

internal/api/third/minio_init.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,19 @@ var (
1515
)
1616

1717
func MinioInit() {
18-
log.NewInfo("", utils.GetSelfFuncName())
18+
operationID := utils.OperationIDGenerator()
19+
log.NewInfo(operationID, utils.GetSelfFuncName())
1920
minioUrl, err := url2.Parse(config.Config.Credential.Minio.Endpoint)
2021
if err != nil {
21-
log.NewError("", utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error())
22+
log.NewError(operationID, utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error())
2223
return
2324
}
2425
minioClient, err = minio.New(minioUrl.Host, &minio.Options{
2526
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
2627
Secure: false,
2728
})
2829
if err != nil {
29-
log.NewError("", utils.GetSelfFuncName(), "init minio client failed", err.Error())
30+
log.NewError(operationID, utils.GetSelfFuncName(), "init minio client failed", err.Error())
3031
return
3132
}
3233
opt := minio.MakeBucketOptions{
@@ -35,15 +36,15 @@ func MinioInit() {
3536
}
3637
err = minioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.Bucket, opt)
3738
if err != nil {
38-
log.NewInfo("", utils.GetSelfFuncName(), err.Error())
39+
log.NewInfo(operationID, utils.GetSelfFuncName(), err.Error())
3940
exists, err := minioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket)
4041
if err == nil && exists {
41-
log.NewInfo("", utils.GetSelfFuncName(), "We already own %s\n", config.Config.Credential.Minio.Bucket)
42+
log.NewInfo(operationID, utils.GetSelfFuncName(), "We already own %s\n", config.Config.Credential.Minio.Bucket)
4243
} else {
4344
if err != nil {
44-
log.NewError("", utils.GetSelfFuncName(), err.Error())
45+
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
4546
}
46-
log.NewError("", utils.GetSelfFuncName(), "create bucket failed and bucket not exists")
47+
log.NewError(operationID, utils.GetSelfFuncName(), "create bucket failed and bucket not exists")
4748
return
4849
}
4950
}
@@ -53,5 +54,5 @@ func MinioInit() {
5354
// log.NewError("", utils.GetSelfFuncName(), "SetBucketPolicy failed please set in web", err.Error())
5455
// return
5556
//}
56-
log.NewInfo("", utils.GetSelfFuncName(), "minio create and set policy success")
57+
log.NewInfo(operationID, utils.GetSelfFuncName(), "minio create and set policy success")
5758
}

internal/msg_gateway/gate/init.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ package gate
22

33
import (
44
"Open_IM/pkg/common/config"
5-
"Open_IM/pkg/common/constant"
6-
"Open_IM/pkg/common/log"
5+
76
"Open_IM/pkg/statistics"
87
"fmt"
98
"github.com/go-playground/validator/v10"
@@ -21,7 +20,7 @@ var (
2120

2221
func Init(rpcPort, wsPort int) {
2322
//log initialization
24-
log.NewPrivateLog(constant.LogFileName)
23+
2524
rwLock = new(sync.RWMutex)
2625
validate = validator.New()
2726
statistics.NewStatistics(&sendMsgCount, config.Config.ModuleName.LongConnSvrName, fmt.Sprintf("%d second recv to msg_gateway sendMsgCount", sendMsgCount), 300)

internal/msg_transfer/logic/init.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ package logic
22

33
import (
44
"Open_IM/pkg/common/config"
5-
"Open_IM/pkg/common/constant"
5+
66
"Open_IM/pkg/common/kafka"
7-
"Open_IM/pkg/common/log"
87
)
98

109
var (
@@ -14,7 +13,7 @@ var (
1413
)
1514

1615
func Init() {
17-
log.NewPrivateLog(constant.LogFileName)
16+
1817
persistentCH.Init()
1918
historyCH.Init()
2019
producer = kafka.NewKafkaProducer(config.Config.Kafka.Ms2pschat.Addr, config.Config.Kafka.Ms2pschat.Topic)

internal/push/logic/init.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"Open_IM/pkg/common/config"
1111
"Open_IM/pkg/common/constant"
1212
"Open_IM/pkg/common/kafka"
13-
"Open_IM/pkg/common/log"
1413
"Open_IM/pkg/statistics"
1514
"fmt"
1615
)
@@ -24,7 +23,7 @@ var (
2423
)
2524

2625
func Init(rpcPort int) {
27-
log.NewPrivateLog(constant.LogFileName)
26+
2827
rpcServer.Init(rpcPort)
2928
pushCh.Init()
3029
pushTerminal = []int32{constant.IOSPlatformID, constant.AndroidPlatformID}

pkg/common/db/model.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ package db
22

33
import (
44
"Open_IM/pkg/common/config"
5-
"Open_IM/pkg/common/constant"
6-
"Open_IM/pkg/common/log"
5+
//"Open_IM/pkg/common/log"
76
"Open_IM/pkg/utils"
87
"fmt"
98
"go.mongodb.org/mongo-driver/mongo/options"
@@ -34,7 +33,7 @@ func key(dbAddress, dbName string) string {
3433
}
3534

3635
func init() {
37-
log.NewPrivateLog(constant.LogFileName)
36+
//log.NewPrivateLog(constant.LogFileName)
3837
//var mgoSession *mgo.Session
3938
var mongoClient *mongo.Client
4039
var err1 error
@@ -54,15 +53,16 @@ func init() {
5453

5554
mongoClient, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
5655
if err != nil {
57-
log.NewError(" mongo.Connect failed, try ", utils.GetSelfFuncName(), err.Error(), uri)
56+
fmt.Println(" mongo.Connect failed, try ", utils.GetSelfFuncName(), err.Error(), uri)
5857
time.Sleep(time.Duration(30) * time.Second)
5958
mongoClient, err1 = mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
6059
if err1 != nil {
61-
log.NewError(" mongo.Connect retry failed, panic", err.Error(), uri)
60+
fmt.Println(" mongo.Connect retry failed, panic", err.Error(), uri)
6261
panic(err1.Error())
6362
}
6463
}
65-
log.NewInfo("0", utils.GetSelfFuncName(), "mongo driver client init success")
64+
fmt.Println("0", utils.GetSelfFuncName(), "mongo driver client init success")
65+
6666
DB.mongoClient = mongoClient
6767

6868
//mgoDailInfo := &mgo.DialInfo{

0 commit comments

Comments
 (0)