Go: move logger to common module (#14545)

### What problem does this PR solve?

As title

### Type of change

- [x] Refactoring

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-05-06 10:41:58 +08:00
committed by GitHub
parent 3a51c27a75
commit aa57b5bd8b
56 changed files with 628 additions and 717 deletions

View File

@@ -23,7 +23,7 @@ import (
"fmt"
"io"
"net/http"
"ragflow/internal/logger"
"ragflow/internal/common"
"strings"
"time"
)
@@ -285,7 +285,7 @@ func (z *AliyunModel) ChatStreamlyWithSender(modelName string, messages []Messag
scanner := bufio.NewScanner(resp.Body)
for scanner.Scan() {
line := scanner.Text()
logger.Info(line)
common.Info(line)
// SSE data line starts with "data:"
if !strings.HasPrefix(line, "data:") {

View File

@@ -23,7 +23,7 @@ import (
"fmt"
"io"
"net/http"
"ragflow/internal/logger"
"ragflow/internal/common"
"strings"
"time"
)
@@ -349,7 +349,7 @@ func (z *DeepSeekModel) ChatStreamlyWithSender(modelName string, messages []Mess
scanner := bufio.NewScanner(resp.Body)
for scanner.Scan() {
line := scanner.Text()
logger.Info(line)
common.Info(line)
// SSE data line starts with "data:"
if !strings.HasPrefix(line, "data:") {

View File

@@ -23,7 +23,7 @@ import (
"fmt"
"io"
"net/http"
"ragflow/internal/logger"
"ragflow/internal/common"
"strings"
"time"
)
@@ -84,7 +84,7 @@ func (z *GiteeModel) ChatWithMessages(modelName string, messages []Message, apiC
"content": msg.Content,
}
}
logger.Info(fmt.Sprintf("GiteeAPI messages: %+v", apiMessages))
common.Info(fmt.Sprintf("GiteeAPI messages: %+v", apiMessages))
// Build request body
reqBody := map[string]interface{}{
@@ -133,7 +133,7 @@ func (z *GiteeModel) ChatWithMessages(modelName string, messages []Message, apiC
return nil, fmt.Errorf("failed to marshal request: %w", err)
}
logger.Info(fmt.Sprintf("GiteeAPI request body: %s", string(jsonData)))
common.Info(fmt.Sprintf("GiteeAPI request body: %s", string(jsonData)))
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
if err != nil {
@@ -309,7 +309,7 @@ func (z *GiteeModel) ChatStreamlyWithSender(modelName string, messages []Message
scanner := bufio.NewScanner(resp.Body)
for scanner.Scan() {
line := scanner.Text()
logger.Info(line)
common.Info(line)
// SSE data line starts with "data:"
if !strings.HasPrefix(line, "data:") {

View File

@@ -19,7 +19,7 @@ package models
import (
"context"
"fmt"
"ragflow/internal/logger"
"ragflow/internal/common"
"google.golang.org/genai"
)
@@ -195,14 +195,14 @@ func (z *GoogleModel) ChatStreamlyWithSender(modelName string, messages []Messag
}
if responseContent != "" {
logger.Info(fmt.Sprintf("Thinking: %s", responseContent))
common.Info(fmt.Sprintf("Thinking: %s", responseContent))
if err = sender(nil, &responseContent); err != nil {
return err
}
}
if content != "" {
logger.Info(fmt.Sprintf("Answer: %s", content))
common.Info(fmt.Sprintf("Answer: %s", content))
if err = sender(&content, nil); err != nil {
return err
}

View File

@@ -23,7 +23,7 @@ import (
"fmt"
"io"
"net/http"
"ragflow/internal/logger"
"ragflow/internal/common"
"strings"
"time"
)
@@ -397,7 +397,7 @@ func (z *MinimaxModel) ChatStreamlyWithSender(modelName string, messages []Messa
scanner := bufio.NewScanner(resp.Body)
for scanner.Scan() {
line := scanner.Text()
logger.Info(line)
common.Info(line)
// SSE data line start with data:
if !strings.HasPrefix(line, "data:") {

View File

@@ -23,7 +23,7 @@ import (
"fmt"
"io"
"net/http"
"ragflow/internal/logger"
"ragflow/internal/common"
"strings"
"time"
)
@@ -292,7 +292,7 @@ func (k *MoonshotModel) ChatStreamlyWithSender(modelName string, messages []Mess
scanner := bufio.NewScanner(resp.Body)
for scanner.Scan() {
line := scanner.Text()
logger.Info(line)
common.Info(line)
// SSE data line starts with "data:"
if !strings.HasPrefix(line, "data:") {

View File

@@ -23,7 +23,7 @@ import (
"fmt"
"io"
"net/http"
"ragflow/internal/logger"
"ragflow/internal/common"
"strings"
"time"
)
@@ -310,7 +310,7 @@ func (z *SiliconflowModel) ChatStreamlyWithSender(modelName string, messages []M
scanner := bufio.NewScanner(resp.Body)
for scanner.Scan() {
line := scanner.Text()
logger.Info(line)
common.Info(line)
// SSE data line starts with "data:"
if !strings.HasPrefix(line, "data:") {

View File

@@ -23,7 +23,7 @@ import (
"fmt"
"io"
"net/http"
"ragflow/internal/logger"
"ragflow/internal/common"
"strings"
"time"
)
@@ -429,7 +429,7 @@ func (z *VllmModel) ChatStreamlyWithSender(modelName string, messages []Message,
scanner := bufio.NewScanner(resp.Body)
for scanner.Scan() {
line := scanner.Text()
logger.Info(line)
common.Info(line)
// SSE data line starts with "data:"
if !strings.HasPrefix(line, "data:") {

View File

@@ -23,7 +23,7 @@ import (
"fmt"
"io"
"net/http"
"ragflow/internal/logger"
"ragflow/internal/common"
"strings"
"time"
)
@@ -491,7 +491,7 @@ func (z *VolcEngine) ChatStreamlyWithSender(modelName string, messages []Message
scanner := bufio.NewScanner(resp.Body)
for scanner.Scan() {
line := scanner.Text()
logger.Info(line)
common.Info(line)
// SSE data line start with data:
if !strings.HasPrefix(line, "data:") {

View File

@@ -23,7 +23,7 @@ import (
"fmt"
"io"
"net/http"
"ragflow/internal/logger"
"ragflow/internal/common"
"strings"
"time"
)
@@ -297,7 +297,7 @@ func (z *ZhipuAIModel) ChatStreamlyWithSender(modelName string, messages []Messa
scanner := bufio.NewScanner(resp.Body)
for scanner.Scan() {
line := scanner.Text()
logger.Info(line)
common.Info(line)
// SSE data line starts with "data:"
if !strings.HasPrefix(line, "data:") {