Skip to content

Commit

Permalink
style:优化日志输出
Browse files Browse the repository at this point in the history
  • Loading branch information
Akimio521 committed Oct 14, 2024
1 parent 7f9f601 commit a2bd508
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions cmd/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"MediaWarp/internal/router"
"fmt"

"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
Expand All @@ -12,12 +11,13 @@ import (
func SetUP() {
if isDebug {
logger.ServiceLogger.SetLevel(logrus.DebugLevel)
fmt.Println("已启用调试模式")
logger.ServiceLogger.Warning("已启用调试模式")
} else {
gin.SetMode(gin.ReleaseMode)
}

logger.ServiceLogger.Info("MediaWarp 监听端口:", cfg.Port)
ginR := router.InitRouter() // 路由初始化
fmt.Println("MediaWarp启动成功")
logger.ServiceLogger.Info("MediaWarp 启动成功")
ginR.Run(cfg.ListenAddr()) // 启动服务
}
4 changes: 2 additions & 2 deletions cmd/shutdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import "fmt"

// MidaWarp退出函数
func ShutDown() {
fmt.Println("MediaWarp正在关闭...")
fmt.Println("MediaWarp 正在关闭...")

// 其他操作...

fmt.Println("MediaWarp正常关闭")
fmt.Println("MediaWarp 正常关闭")
}
18 changes: 9 additions & 9 deletions internal/handler/emby.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ func (embyServerHandler *EmbyServerHandler) VideosHandler(ctx *gin.Context) {
// EmbyServer >= 4.9 ====> mediaSourceID = mediasource_31
mediaSourceID := ctx.Query("mediasourceid")

logger.ServiceLogger.Debug("请求ItemsServiceQueryItem:", mediaSourceID)
logger.ServiceLogger.Debug("请求 ItemsServiceQueryItem:", mediaSourceID)
itemResponse, err := embyServerHandler.server.ItemsServiceQueryItem(strings.Replace(mediaSourceID, "mediasource_", "", 1), 1, "Path,MediaSources") // 查询item需要去除前缀仅保留数字部分

if err != nil {
logger.ServiceLogger.Warning("请求ItemsServiceQueryItem失败:", err)
logger.ServiceLogger.Warning("请求 ItemsServiceQueryItem 失败:", err)
return
}
item := itemResponse.Items[0]
Expand All @@ -80,13 +80,13 @@ func (embyServerHandler *EmbyServerHandler) VideosHandler(ctx *gin.Context) {
if *mediasource.Protocol == emby.HTTP && cfg.HTTPStrm.Enable {
for _, prefix := range cfg.HTTPStrm.PrefixList {
if strings.HasPrefix(*item.Path, prefix) {
logger.ServiceLogger.Debug(item.Path, "匹配HTTPStrm路径:", prefix, "成功")
logger.ServiceLogger.Info("HTTP协议Strm重定向:", *mediasource.Path)
logger.ServiceLogger.Debug(item.Path, "匹配 HTTPStrm 路径:", prefix, " 成功")
logger.ServiceLogger.Info("HTTP 协议Strm 重定向:", *mediasource.Path)
ctx.Redirect(http.StatusFound, *mediasource.Path)
return
}
}
logger.ServiceLogger.Info("未匹配HTTPStrm路径:", *item.Path)
logger.ServiceLogger.Info("未匹配 HTTPStrm 路径:", *item.Path)
isRedirect = false // 未匹配到 HTTPStrm 路径,但未启用,不进行后续重定向
}

Expand All @@ -98,16 +98,16 @@ func (embyServerHandler *EmbyServerHandler) VideosHandler(ctx *gin.Context) {
alistServer := service.GetAlistServer(alistStrmConfig.ADDR)
fsGetData, err := alistServer.FsGet(*mediasource.Path)
if err != nil {
logger.ServiceLogger.Warning("请求FsGet失败:", err)
logger.ServiceLogger.Warning("请求 FsGet 失败:", err)
return
}
logger.ServiceLogger.Info("AlistStrm重定向:", fsGetData.RawURL)
logger.ServiceLogger.Info("AlistStrm 重定向:", fsGetData.RawURL)
ctx.Redirect(http.StatusFound, fsGetData.RawURL)
return
}
}
}
logger.ServiceLogger.Info("未匹配AlistStrm路径:", *item.Path)
logger.ServiceLogger.Info("未匹配 AlistStrm 路径:", *item.Path)
isRedirect = false // 未匹配到 AlistStrm 路径,但未启用,不进行后续重定向
}

Expand All @@ -123,7 +123,7 @@ func (embyServerHandler *EmbyServerHandler) VideosHandler(ctx *gin.Context) {
// 用于修改播放器JS,实现跨域播放Strm
func (embyServerHandler *EmbyServerHandler) ModifyBaseHtmlPlayerHandler(ctx *gin.Context) {
version := ctx.Query("v")
logger.ServiceLogger.Debug("请求basehtmlplayer.js版本:", version)
logger.ServiceLogger.Debug("请求 basehtmlplayer.js 版本:", version)

proxy := embyServerHandler.server.GetReverseProxy()
proxy.ModifyResponse = func(rw *http.Response) error {
Expand Down

0 comments on commit a2bd508

Please sign in to comment.