Skip to content

Commit

Permalink
fix: use utils.Log in some places
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Aug 30, 2022
1 parent 615e5dd commit a6b9dbf
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 18 deletions.
7 changes: 3 additions & 4 deletions cmd/cancel2FA.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
*/
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"
)

Expand All @@ -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)
}
}
},
Expand Down
6 changes: 2 additions & 4 deletions cmd/lang.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down
7 changes: 3 additions & 4 deletions cmd/password.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
*/
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"
)

Expand All @@ -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)
}
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/bootstrap/data/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions internal/bootstrap/data/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions pkg/utils/random/random.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package random

import (
"github.com/google/uuid"
"math/rand"
"time"

"github.com/google/uuid"
)

var Rand *rand.Rand
Expand All @@ -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 {
Expand Down

0 comments on commit a6b9dbf

Please sign in to comment.