Skip to content
This repository has been archived by the owner on Apr 6, 2024. It is now read-only.

Commit

Permalink
fix(log): 🐛logger.Logger.Fatal->logger.Logger.err
Browse files Browse the repository at this point in the history
  • Loading branch information
aurorax-neo committed Jan 30, 2024
1 parent c01c475 commit 43b7528
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions bot/discord/discordBot.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (dcBot *DcBot) StartBot(ctx context.Context, proxyBot *ProxyBot) {
var err error
dcBot.Session, err = discordgo.New("Bot " + dcBot.BotToken)
if err != nil {
logger.Logger.Fatal(fmt.Sprint("error creating DcBot bot,", err))
logger.Logger.Error(fmt.Sprint("error creating DcBot bot,", err))
return
}
// 添加到数据库
Expand All @@ -51,7 +51,7 @@ func (dcBot *DcBot) StartBot(ctx context.Context, proxyBot *ProxyBot) {
// 打开websocket连接并开始监听
err = dcBot.Session.Open()
if err != nil {
logger.Logger.Fatal(fmt.Sprint("error opening DcBot connection,", err))
logger.Logger.Error(fmt.Sprint("error opening DcBot connection,", err))
return
}
// 注册消息处理函数
Expand All @@ -66,7 +66,7 @@ func (dcBot *DcBot) StartBot(ctx context.Context, proxyBot *ProxyBot) {
go func() {
<-ctx.Done()
if err := dcBot.Session.Close(); err != nil {
logger.Logger.Fatal(fmt.Sprint("error closing DcBot bot,", err))
logger.Logger.Error(fmt.Sprint("error closing DcBot bot,", err))
}
}()

Expand Down
4 changes: 2 additions & 2 deletions botTool/botTool.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (botTool *BotTool) __GetBots1BotFile() {
// 读取json文件内容
bytes, err := os.ReadFile(config.CONFIG.BotConfig)
if err != nil {
logger.Logger.Fatal(err.Error())
logger.Logger.Error(err.Error())
}

// Define a slice to hold the proxyBots
Expand All @@ -40,7 +40,7 @@ func (botTool *BotTool) __GetBots1BotFile() {
// Unmarshal the JSON data into the proxyBots slice
err = json.Unmarshal(bytes, &dcBots)
if err != nil {
logger.Logger.Fatal(err.Error())
logger.Logger.Error(err.Error())
}
botTool.ProxyBotPool = make(map[string]*ProxyBotDB)
// Get the context
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func main() {

go func() {
if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
logger.Logger.Fatal("failed to start HTTP server: " + err.Error())
logger.Logger.Error("failed to start HTTP server: " + err.Error())
}
}()

Expand All @@ -53,6 +53,6 @@ func main() {
defer cancelShutDown()

if err := srv.Shutdown(ctxShutDown); err != nil {
logger.Logger.Fatal("HTTP server Shutdown failed:" + err.Error())
logger.Logger.Error("HTTP server Shutdown failed:" + err.Error())
}
}
2 changes: 1 addition & 1 deletion v1/chat/gpt.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func gpt(c *gin.Context, apiReq *apireq.Req, bot *discord.ProxyBot) {

sentMsg, err := bot.SendMessage(newMessages)
if err != nil {
logger.Logger.Fatal(err.Error())
logger.Logger.Error(err.Error())
c.JSON(http.StatusInternalServerError, gin.H{
"detail": err.Error(),
})
Expand Down
2 changes: 1 addition & 1 deletion v1/chat/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func init() {
// gpt-3.5-turbo encoding
tke, err := tiktoken.GetEncoding("cl100k_base")
if err != nil {
logger.Logger.Fatal(err.Error())
logger.Logger.Error(err.Error())
}
Tke = tke

Expand Down
2 changes: 1 addition & 1 deletion v1/images/dalle3.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Dalle3RespData struct {
func dalle3(c *gin.Context, apiReq *Dalle3Req, bot *discord.ProxyBot) {
sentMsg, err := bot.SendMessage(apiReq.Prompt)
if err != nil {
logger.Logger.Fatal(err.Error())
logger.Logger.Error(err.Error())
c.JSON(http.StatusInternalServerError, gin.H{
"detail": err.Error(),
})
Expand Down

0 comments on commit 43b7528

Please sign in to comment.