Skip to content

Commit

Permalink
🧑‍💻 不同等级日志分频道
Browse files Browse the repository at this point in the history
  • Loading branch information
phidiaLam committed May 20, 2024
1 parent 093eb50 commit 9b65478
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.vscode/
/conf/config.json
/main.exe
2 changes: 1 addition & 1 deletion Ceobe_Proto
2 changes: 1 addition & 1 deletion client_test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func main() {
conn, err := grpc.Dial("localhost:8000", grpc.WithInsecure())
conn, err := grpc.Dial("localhost:8003", grpc.WithInsecure())
if err != nil {
log.Fatal("连接 gPRC 服务失败,", err)
}
Expand Down
1 change: 1 addition & 0 deletions conf/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ type BotConfig struct {
AppId int64 `json:"app_id" env:"APP_ID,notEmpty" validate:"required"`
Token string `json:"token" env:"TOKEN,notEmpty" validate:"required"`
ChannelNotice string `json:"channel_notice" env:"CHANNEL_NOTICE,notEmpty" validate:"required"`
ChannelInfo string `json:"channel_info" env:"CHANNEL_INFO"`
}
7 changes: 6 additions & 1 deletion grpc_impl/log_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ func (l *LogServer) PushLog(ctx context.Context, in *pb.LogRequest) (*pb.LogResp
MsgID: "1000",
Content: content,
}
_, err := global.BOT_PROCESS.Api.PostMessage(ctx, conf.GetConfig().Bot.ChannelNotice, toCreate)
var err error
if (in.Level == pb.LogRequest_ERROR || in.Level == pb.LogRequest_WARN) || conf.GetConfig().Bot.ChannelInfo == "" {
_, err = global.BOT_PROCESS.Api.PostMessage(ctx, conf.GetConfig().Bot.ChannelNotice, toCreate)
} else {
_, err = global.BOT_PROCESS.Api.PostMessage(ctx, conf.GetConfig().Bot.ChannelInfo, toCreate)
}
if err != nil {
return &pb.LogResponse{Success: false}, nil
}
Expand Down

0 comments on commit 9b65478

Please sign in to comment.