From e4b956b091dfb6443a356f191bfa2dd263b23fdd Mon Sep 17 00:00:00 2001 From: Noah Hsu Date: Tue, 14 Jun 2022 17:18:58 +0800 Subject: [PATCH] chore: set log structure first --- bootstrap/log.go | 20 ++++++++++++-------- cmd/alist.go | 3 ++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/bootstrap/log.go b/bootstrap/log.go index c64e7353..52838fad 100644 --- a/bootstrap/log.go +++ b/bootstrap/log.go @@ -1,26 +1,30 @@ package bootstrap import ( + "log" + "time" + "github.com/alist-org/alist/v3/cmd/args" "github.com/alist-org/alist/v3/conf" rotatelogs "github.com/lestrrat-go/file-rotatelogs" "github.com/sirupsen/logrus" - "log" - "time" ) +func init() { + logrus.SetFormatter(&logrus.TextFormatter{ + ForceColors: true, + EnvironmentOverrideColors: true, + TimestampFormat: "2006-01-02 15:04:05", + FullTimestamp: true, + }) +} + func Log() { log.SetOutput(logrus.StandardLogger().Out) if args.Debug { logrus.SetLevel(logrus.DebugLevel) logrus.SetReportCaller(true) } - logrus.SetFormatter(&logrus.TextFormatter{ - ForceColors: true, - EnvironmentOverrideColors: true, - TimestampFormat: "2006-01-02 15:04:05", - FullTimestamp: true, - }) logConfig := conf.Conf.Log if logConfig.Enable { var ( diff --git a/cmd/alist.go b/cmd/alist.go index 0b6c41f9..3faa3576 100644 --- a/cmd/alist.go +++ b/cmd/alist.go @@ -3,13 +3,14 @@ package main import ( "flag" "fmt" + "os" + "github.com/alist-org/alist/v3/bootstrap" "github.com/alist-org/alist/v3/cmd/args" "github.com/alist-org/alist/v3/conf" _ "github.com/alist-org/alist/v3/drivers" "github.com/gin-gonic/gin" log "github.com/sirupsen/logrus" - "os" ) func init() {