From 3e9c38697d297d2067508d4789950c733de2fb0d Mon Sep 17 00:00:00 2001 From: BoYanZh Date: Mon, 24 Oct 2022 23:33:57 +0800 Subject: [PATCH] fix: use `utils.Log` during static file router init (#2100) formerly the log is not in stderr --- server/static/static.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/static/static.go b/server/static/static.go index 7d566af5..9191e9cb 100644 --- a/server/static/static.go +++ b/server/static/static.go @@ -10,15 +10,18 @@ import ( "github.com/alist-org/alist/v3/cmd/flags" "github.com/alist-org/alist/v3/internal/conf" "github.com/alist-org/alist/v3/internal/setting" + "github.com/alist-org/alist/v3/pkg/utils" "github.com/alist-org/alist/v3/public" "github.com/gin-gonic/gin" - log "github.com/sirupsen/logrus" ) func InitIndex() { index, err := public.Public.ReadFile("dist/index.html") if err != nil { - log.Fatalf("failed to read index.html: %v", err) + if err == fs.ErrNotExist { + utils.Log.Fatalf("index.html not exist, you may forget to put dist of frontend to public/dist") + } + utils.Log.Fatalf("failed to read index.html: %v", err) } conf.RawIndexHtml = string(index) siteConfig := getSiteConfig() @@ -65,7 +68,7 @@ func Static(r *gin.Engine) { folder = "dist/" + folder sub, err := fs.Sub(public.Public, folder) if err != nil { - log.Fatalf("can't find folder: %s", folder) + utils.Log.Fatalf("can't find folder: %s", folder) } r.StaticFS(fmt.Sprintf("/%s/", folders[i]), http.FS(sub)) }