feat: add trace log level (#10650)

reduce prompt log to trace level
This commit is contained in:
Michael Yang
2025-05-12 11:43:00 -07:00
committed by GitHub
parent 82a9e9462a
commit f95a1f2bef
13 changed files with 141 additions and 114 deletions

View File

@@ -17,7 +17,6 @@ import (
"net/netip"
"os"
"os/signal"
"path/filepath"
"regexp"
"slices"
"strings"
@@ -33,6 +32,7 @@ import (
"github.com/ollama/ollama/envconfig"
"github.com/ollama/ollama/fs/ggml"
"github.com/ollama/ollama/llm"
"github.com/ollama/ollama/logutil"
"github.com/ollama/ollama/model/models/mllama"
"github.com/ollama/ollama/openai"
"github.com/ollama/ollama/server/internal/client/ollama"
@@ -295,8 +295,6 @@ func (s *Server) GenerateHandler(c *gin.Context) {
prompt = b.String()
}
slog.Debug("generate request", "images", len(images), "prompt", prompt)
ch := make(chan any)
go func() {
// TODO (jmorganca): avoid building the response twice both here and below
@@ -1226,26 +1224,8 @@ func (s *Server) GenerateRoutes(rc *ollama.Registry) (http.Handler, error) {
}
func Serve(ln net.Listener) error {
level := slog.LevelInfo
if envconfig.Debug() {
level = slog.LevelDebug
}
slog.SetDefault(logutil.NewLogger(os.Stderr, envconfig.LogLevel()))
slog.Info("server config", "env", envconfig.Values())
handler := slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{
Level: level,
AddSource: true,
ReplaceAttr: func(_ []string, attr slog.Attr) slog.Attr {
if attr.Key == slog.SourceKey {
source := attr.Value.Any().(*slog.Source)
source.File = filepath.Base(source.File)
}
return attr
},
})
slog.SetDefault(slog.New(handler))
blobsDir, err := GetBlobsPath("")
if err != nil {
@@ -1521,8 +1501,6 @@ func (s *Server) ChatHandler(c *gin.Context) {
return
}
slog.Debug("chat request", "images", len(images), "prompt", prompt)
ch := make(chan any)
go func() {
defer close(ch)