禁用 gin 打印日志

This commit is contained in:
RockYang
2023-03-29 21:44:44 +08:00
parent bd41f742d2
commit d515e88d97
3 changed files with 5 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ import (
"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/cookie"
"github.com/gin-gonic/gin"
"io"
"io/fs"
"net/http"
logger2 "openai/logger"
@@ -71,6 +72,7 @@ func NewServer(configPath string) (*Server, error) {
func (s *Server) Run(webRoot embed.FS, path string, debug bool) {
s.DebugMode = debug
gin.SetMode(gin.ReleaseMode)
gin.DefaultWriter = io.Discard
engine := gin.Default()
if debug {
engine.Use(corsMiddleware())