Skip to content

Commit

Permalink
-- FIX
Browse files Browse the repository at this point in the history
 - Remove useless log
 - Set logger color
  • Loading branch information
NoahAmethyst committed Apr 11, 2024
1 parent de1c89e commit 1dc8d63
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/NoahAmethyst/go-cqhttp/cmd/gocq"
"github.com/NoahAmethyst/go-cqhttp/util/cron"
"github.com/NoahAmethyst/go-cqhttp/util/top_list"
"github.com/sirupsen/logrus"
"time"

_ "github.com/NoahAmethyst/go-cqhttp/db/leveldb" // leveldb
Expand All @@ -18,7 +19,7 @@ import (
func main() {
var cstZone = time.FixedZone("CST", 8*3600) // 东八
time.Local = cstZone

logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true})
// Initialize grpc client
for _, rpcCli := range rpc.RpcCliList {
rpc.InitGrpcCli(rpcCli)
Expand Down
6 changes: 4 additions & 2 deletions util/ai_util/openai_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package ai_util

import (
"context"
"github.com/rs/zerolog/log"
"github.com/sashabaranov/go-openai"
log "github.com/sirupsen/logrus"
)

func GenerateImage(prompt, size string) (*openai.ImageResponse, error) {
Expand All @@ -21,6 +21,8 @@ func GenerateImage(prompt, size string) (*openai.ImageResponse, error) {
User: "",
},
)
log.Info().Msgf("收到openai响应:%+v", resp)

log.Infof("receive openai response:%+v", resp)

return &resp, err
}
9 changes: 5 additions & 4 deletions util/http_util/httpUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
log "github.com/sirupsen/logrus"
"io"

"io/ioutil"
Expand Down Expand Up @@ -107,7 +107,7 @@ func PostJSON(url string, params interface{}, headers map[string]string, ret int
b, err := Post(url, params, headers)

if err != nil {
log.Err(err)
log.Error(err)
return err
}

Expand Down Expand Up @@ -143,11 +143,12 @@ func PostForm(thisUrl string, params map[string]string, headers map[string]strin
if err != nil {
return err
}
log.Info().Fields(map[string]interface{}{

log.Infof("%+v", map[string]interface{}{
"action": "post form",
"url": thisUrl,
"response": result,
}).Send()
})

return err
}
4 changes: 2 additions & 2 deletions util/math_engine/math.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package math_engine

import (
"github.com/dengsgo/math-engine/engine"
"github.com/rs/zerolog/log"
log "github.com/sirupsen/logrus"
"strings"
)

Expand Down Expand Up @@ -32,7 +32,7 @@ func Calculate(expression string) (float64, error) {

r, err := engine.ParseAndExec(expression)
if err != nil {
log.Err(err)
log.Error(err)
}
return r, err
}
12 changes: 6 additions & 6 deletions util/top_list/daily_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (d *d36KrDailyRecord) Load() {
func (d *d36KrDailyRecord) Backup() {
d.RLock()
defer d.RUnlock()
log.Infof("backup 36kr daily record")
//log.Infof("backup 36kr daily record")
path := file_util.GetFileRoot()
_, _ = file_util.WriteJsonFile(d.data, path, "36kr", true)

Expand Down Expand Up @@ -160,7 +160,7 @@ func (d *wallStreetNewsDailyRecord) Load() {
func (d *wallStreetNewsDailyRecord) Backup() {
d.RLock()
defer d.RUnlock()
log.Infof("backup wallstreet news daily record")
//log.Infof("backup wallstreet news daily record")
path := file_util.GetFileRoot()
_, _ = file_util.WriteJsonFile(d.data, path, "wallstreet_news", true)
}
Expand Down Expand Up @@ -228,7 +228,7 @@ func (d *caixinnewsDailyRecord) Load() {
func (d *caixinnewsDailyRecord) Backup() {
d.RLock()
defer d.RUnlock()
log.Infof("backup caixin news daily record")
//log.Infof("backup caixin news daily record")
path := file_util.GetFileRoot()
_, _ = file_util.WriteJsonFile(d.data, path, "caixin_news", true)
}
Expand Down Expand Up @@ -296,7 +296,7 @@ func (d *weiboHotDailyRecord) Load() {
func (d *weiboHotDailyRecord) Backup() {
d.RLock()
defer d.RUnlock()
log.Infof("backup weibo hot daily record")
//log.Infof("backup weibo hot daily record")
path := file_util.GetFileRoot()
_, _ = file_util.WriteJsonFile(d.data, path, "weibo_hot", true)
}
Expand Down Expand Up @@ -365,7 +365,7 @@ func (z *zhihuHotDailyRecord) Load() {
func (d *zhihuHotDailyRecord) Backup() {
d.RLock()
defer d.RUnlock()
log.Infof("backup zhihu hot daily record")
//log.Infof("backup zhihu hot daily record")
path := file_util.GetFileRoot()
_, _ = file_util.WriteJsonFile(d.data, path, "zhihu", true)
}
Expand Down Expand Up @@ -433,7 +433,7 @@ func (z *sentCache) Load() {
func (d *sentCache) Backup() {
d.RLock()
defer d.RUnlock()
log.Infof("backup sent news cache")
//log.Infof("backup sent news cache")
path := file_util.GetFileRoot()
_, _ = file_util.WriteJsonFile(d.data, path, "sentNews", true)
}
Expand Down

0 comments on commit 1dc8d63

Please sign in to comment.