mirror of
https://github.com/AlistGo/alist.git
synced 2025-04-23 13:54:04 +08:00
feat: set gin log writer
This commit is contained in:
parent
fced60c2b5
commit
09616dbe25
@ -1,3 +0,0 @@
|
||||
What to do at startup, such as:
|
||||
- parse config
|
||||
- init store
|
@ -4,16 +4,18 @@ import (
|
||||
"github.com/alist-org/alist/v3/cmd/args"
|
||||
"github.com/alist-org/alist/v3/conf"
|
||||
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/sirupsen/logrus"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
func Log() {
|
||||
log.SetOutput(logrus.StandardLogger().Out)
|
||||
if args.Debug {
|
||||
log.SetLevel(log.DebugLevel)
|
||||
log.SetReportCaller(true)
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
logrus.SetReportCaller(true)
|
||||
}
|
||||
log.SetFormatter(&log.TextFormatter{
|
||||
logrus.SetFormatter(&logrus.TextFormatter{
|
||||
ForceColors: true,
|
||||
EnvironmentOverrideColors: true,
|
||||
TimestampFormat: "2006-01-02 15:04:05",
|
||||
@ -40,9 +42,9 @@ func Log() {
|
||||
)
|
||||
}
|
||||
if err != nil {
|
||||
log.Fatalf("failed to create rotate log: %s", err)
|
||||
logrus.Fatalf("failed to create rotate logrus: %s", err)
|
||||
}
|
||||
log.SetOutput(writer)
|
||||
logrus.SetOutput(writer)
|
||||
}
|
||||
log.Infof("init log...")
|
||||
logrus.Infof("init logrus...")
|
||||
}
|
||||
|
19
cmd/alist.go
19
cmd/alist.go
@ -6,6 +6,8 @@ import (
|
||||
"github.com/alist-org/alist/v3/bootstrap"
|
||||
"github.com/alist-org/alist/v3/cmd/args"
|
||||
"github.com/alist-org/alist/v3/conf"
|
||||
"github.com/gin-gonic/gin"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"os"
|
||||
)
|
||||
|
||||
@ -29,4 +31,21 @@ func Init() {
|
||||
}
|
||||
func main() {
|
||||
Init()
|
||||
if !args.Debug {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
}
|
||||
r := gin.New()
|
||||
r.Use(gin.LoggerWithWriter(log.StandardLogger().Out), gin.RecoveryWithWriter(log.StandardLogger().Out))
|
||||
// TODO: setup router
|
||||
base := fmt.Sprintf("%s:%d", conf.Conf.Address, conf.Conf.Port)
|
||||
log.Infof("start server @ %s", base)
|
||||
var err error
|
||||
if conf.Conf.Scheme.Https {
|
||||
err = r.RunTLS(base, conf.Conf.Scheme.CertFile, conf.Conf.Scheme.KeyFile)
|
||||
} else {
|
||||
err = r.Run(base)
|
||||
}
|
||||
if err != nil {
|
||||
log.Errorf("failed to start: %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
1
drivers/local/driver.go
Normal file
1
drivers/local/driver.go
Normal file
@ -0,0 +1 @@
|
||||
package local
|
@ -4,6 +4,7 @@ type Account struct {
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
VirtualPath string `json:"virtual_path"`
|
||||
Index int `json:"index"`
|
||||
Type string `json:"type"`
|
||||
Driver string `json:"driver"`
|
||||
Status string `json:"status"`
|
||||
Custom string `json:"custom"`
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user