Skip to content

Commit 09616db

Browse files
committed
feat: set gin log writer
1 parent fced60c commit 09616db

File tree

5 files changed

+31
-11
lines changed

5 files changed

+31
-11
lines changed

bootstrap/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

bootstrap/log.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ import (
44
"github.com/alist-org/alist/v3/cmd/args"
55
"github.com/alist-org/alist/v3/conf"
66
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
7-
log "github.com/sirupsen/logrus"
7+
"github.com/sirupsen/logrus"
8+
"log"
89
"time"
910
)
1011

1112
func Log() {
13+
log.SetOutput(logrus.StandardLogger().Out)
1214
if args.Debug {
13-
log.SetLevel(log.DebugLevel)
14-
log.SetReportCaller(true)
15+
logrus.SetLevel(logrus.DebugLevel)
16+
logrus.SetReportCaller(true)
1517
}
16-
log.SetFormatter(&log.TextFormatter{
18+
logrus.SetFormatter(&logrus.TextFormatter{
1719
ForceColors: true,
1820
EnvironmentOverrideColors: true,
1921
TimestampFormat: "2006-01-02 15:04:05",
@@ -40,9 +42,9 @@ func Log() {
4042
)
4143
}
4244
if err != nil {
43-
log.Fatalf("failed to create rotate log: %s", err)
45+
logrus.Fatalf("failed to create rotate logrus: %s", err)
4446
}
45-
log.SetOutput(writer)
47+
logrus.SetOutput(writer)
4648
}
47-
log.Infof("init log...")
49+
logrus.Infof("init logrus...")
4850
}

cmd/alist.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"github.com/alist-org/alist/v3/bootstrap"
77
"github.com/alist-org/alist/v3/cmd/args"
88
"github.com/alist-org/alist/v3/conf"
9+
"github.com/gin-gonic/gin"
10+
log "github.com/sirupsen/logrus"
911
"os"
1012
)
1113

@@ -29,4 +31,21 @@ func Init() {
2931
}
3032
func main() {
3133
Init()
34+
if !args.Debug {
35+
gin.SetMode(gin.ReleaseMode)
36+
}
37+
r := gin.New()
38+
r.Use(gin.LoggerWithWriter(log.StandardLogger().Out), gin.RecoveryWithWriter(log.StandardLogger().Out))
39+
// TODO: setup router
40+
base := fmt.Sprintf("%s:%d", conf.Conf.Address, conf.Conf.Port)
41+
log.Infof("start server @ %s", base)
42+
var err error
43+
if conf.Conf.Scheme.Https {
44+
err = r.RunTLS(base, conf.Conf.Scheme.CertFile, conf.Conf.Scheme.KeyFile)
45+
} else {
46+
err = r.Run(base)
47+
}
48+
if err != nil {
49+
log.Errorf("failed to start: %s", err.Error())
50+
}
3251
}

drivers/local/driver.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package local

internal/model/account.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ type Account struct {
44
ID uint `json:"id" gorm:"primaryKey"`
55
VirtualPath string `json:"virtual_path"`
66
Index int `json:"index"`
7-
Type string `json:"type"`
7+
Driver string `json:"driver"`
88
Status string `json:"status"`
9+
Custom string `json:"custom"`
910
}

0 commit comments

Comments
 (0)