diff --git a/cmd/cancel2FA.go b/cmd/cancel2FA.go index ef3bf970..d90a398e 100644 --- a/cmd/cancel2FA.go +++ b/cmd/cancel2FA.go @@ -1,12 +1,11 @@ /* Copyright © 2022 NAME HERE - */ package cmd import ( "github.com/alist-org/alist/v3/internal/db" - log "github.com/sirupsen/logrus" + "github.com/alist-org/alist/v3/pkg/utils" "github.com/spf13/cobra" ) @@ -18,11 +17,11 @@ var cancel2FACmd = &cobra.Command{ Init() admin, err := db.GetAdmin() if err != nil { - log.Errorf("failed to get admin user: %+v", err) + utils.Log.Errorf("failed to get admin user: %+v", err) } else { err := db.Cancel2FAByUser(admin) if err != nil { - log.Errorf("failed to cancel 2FA: %+v", err) + utils.Log.Errorf("failed to cancel 2FA: %+v", err) } } }, diff --git a/cmd/lang.go b/cmd/lang.go index 5fb8e51b..0610a4da 100644 --- a/cmd/lang.go +++ b/cmd/lang.go @@ -9,10 +9,8 @@ import ( "os" "strings" - "github.com/alist-org/alist/v3/internal/bootstrap/data" - log "github.com/sirupsen/logrus" - _ "github.com/alist-org/alist/v3/drivers" + "github.com/alist-org/alist/v3/internal/bootstrap/data" "github.com/alist-org/alist/v3/internal/conf" "github.com/alist-org/alist/v3/internal/operations" "github.com/alist-org/alist/v3/pkg/utils" @@ -90,7 +88,7 @@ var langCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { err := os.MkdirAll("lang", 0777) if err != nil { - log.Fatal("failed create folder: %s", err.Error()) + utils.Log.Fatal("failed create folder: %s", err.Error()) } generateDriversJson() generateSettingsJson() diff --git a/cmd/password.go b/cmd/password.go index 4c709e4c..42497ccf 100644 --- a/cmd/password.go +++ b/cmd/password.go @@ -1,12 +1,11 @@ /* Copyright © 2022 NAME HERE - */ package cmd import ( "github.com/alist-org/alist/v3/internal/db" - log "github.com/sirupsen/logrus" + "github.com/alist-org/alist/v3/pkg/utils" "github.com/spf13/cobra" ) @@ -18,9 +17,9 @@ var passwordCmd = &cobra.Command{ Init() admin, err := db.GetAdmin() if err != nil { - log.Errorf("failed get admin user: %+v", err) + utils.Log.Errorf("failed get admin user: %+v", err) } else { - log.Infof("admin user's password is: %s", admin.Password) + utils.Log.Infof("admin user's password is: %s", admin.Password) } }, } diff --git a/cmd/server.go b/cmd/server.go index 56e603eb..930258ab 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -48,7 +48,7 @@ the address is defined in config file`, err = srv.ListenAndServe() } if err != nil && err != http.ErrServerClosed { - utils.Log.Errorf("failed to start: %s", err.Error()) + utils.Log.Fatalf("failed to start: %s", err.Error()) } }() // Wait for interrupt signal to gracefully shutdown the server with diff --git a/internal/bootstrap/data/setting.go b/internal/bootstrap/data/setting.go index 9d9c1997..93dac96d 100644 --- a/internal/bootstrap/data/setting.go +++ b/internal/bootstrap/data/setting.go @@ -71,7 +71,7 @@ func InitialSettings() []model.SettingItem { {Key: conf.ApiUrl, Value: "", Type: conf.TypeString, Group: model.SITE}, {Key: conf.BasePath, Value: "", Type: conf.TypeString, Group: model.SITE}, {Key: conf.SiteTitle, Value: "AList", Type: conf.TypeString, Group: model.SITE}, - {Key: conf.Announcement, Value: "https://github.com/alist-org/alist", Type: conf.TypeString, Group: model.SITE}, + {Key: conf.Announcement, Value: "### repo\nhttps://github.com/alist-org/alist", Type: conf.TypeText, Group: model.SITE}, {Key: "pagination_type", Value: "all", Type: conf.TypeSelect, Options: "all,pagination,load_more,auto_load_more", Group: model.SITE}, {Key: "default_page_size", Value: "30", Type: conf.TypeNumber, Group: model.SITE}, // style settings diff --git a/internal/bootstrap/data/user.go b/internal/bootstrap/data/user.go index 20ce6a20..bcaee697 100644 --- a/internal/bootstrap/data/user.go +++ b/internal/bootstrap/data/user.go @@ -4,9 +4,9 @@ import ( "github.com/alist-org/alist/v3/cmd/flags" "github.com/alist-org/alist/v3/internal/db" "github.com/alist-org/alist/v3/internal/model" + "github.com/alist-org/alist/v3/pkg/utils" "github.com/alist-org/alist/v3/pkg/utils/random" "github.com/pkg/errors" - log "github.com/sirupsen/logrus" "gorm.io/gorm" ) @@ -27,7 +27,7 @@ func initUser() { if err := db.CreateUser(admin); err != nil { panic(err) } else { - log.Infof("Successfully created the admin user and the initial password is: %s", admin.Password) + utils.Log.Infof("Successfully created the admin user and the initial password is: %s", admin.Password) } } else { panic(err) diff --git a/pkg/utils/random/random.go b/pkg/utils/random/random.go index 6326c55c..65fbf14a 100644 --- a/pkg/utils/random/random.go +++ b/pkg/utils/random/random.go @@ -1,9 +1,10 @@ package random import ( - "github.com/google/uuid" "math/rand" "time" + + "github.com/google/uuid" ) var Rand *rand.Rand @@ -19,7 +20,7 @@ func String(n int) string { } func Token() string { - return uuid.NewString() + String(64) + return "alist-" + uuid.NewString() + String(64) } func RangeInt64(left, right int64) int64 {