Skip to content

Commit e4b956b

Browse files
committed
chore: set log structure first
1 parent e3d2e6d commit e4b956b

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

bootstrap/log.go

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
package bootstrap
22

33
import (
4+
"log"
5+
"time"
6+
47
"github.com/alist-org/alist/v3/cmd/args"
58
"github.com/alist-org/alist/v3/conf"
69
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
710
"github.com/sirupsen/logrus"
8-
"log"
9-
"time"
1011
)
1112

12-
func Log() {
13-
log.SetOutput(logrus.StandardLogger().Out)
14-
if args.Debug {
15-
logrus.SetLevel(logrus.DebugLevel)
16-
logrus.SetReportCaller(true)
17-
}
13+
func init() {
1814
logrus.SetFormatter(&logrus.TextFormatter{
1915
ForceColors: true,
2016
EnvironmentOverrideColors: true,
2117
TimestampFormat: "2006-01-02 15:04:05",
2218
FullTimestamp: true,
2319
})
20+
}
21+
22+
func Log() {
23+
log.SetOutput(logrus.StandardLogger().Out)
24+
if args.Debug {
25+
logrus.SetLevel(logrus.DebugLevel)
26+
logrus.SetReportCaller(true)
27+
}
2428
logConfig := conf.Conf.Log
2529
if logConfig.Enable {
2630
var (

cmd/alist.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ package main
33
import (
44
"flag"
55
"fmt"
6+
"os"
7+
68
"github.com/alist-org/alist/v3/bootstrap"
79
"github.com/alist-org/alist/v3/cmd/args"
810
"github.com/alist-org/alist/v3/conf"
911
_ "github.com/alist-org/alist/v3/drivers"
1012
"github.com/gin-gonic/gin"
1113
log "github.com/sirupsen/logrus"
12-
"os"
1314
)
1415

1516
func init() {

0 commit comments

Comments
 (0)