mirror of https://github.com/Xhofe/alist
chore: set log structure first
parent
e3d2e6dd64
commit
e4b956b091
|
@ -1,26 +1,30 @@
|
||||||
package bootstrap
|
package bootstrap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/alist-org/alist/v3/cmd/args"
|
"github.com/alist-org/alist/v3/cmd/args"
|
||||||
"github.com/alist-org/alist/v3/conf"
|
"github.com/alist-org/alist/v3/conf"
|
||||||
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
||||||
"github.com/sirupsen/logrus"
|
"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() {
|
func Log() {
|
||||||
log.SetOutput(logrus.StandardLogger().Out)
|
log.SetOutput(logrus.StandardLogger().Out)
|
||||||
if args.Debug {
|
if args.Debug {
|
||||||
logrus.SetLevel(logrus.DebugLevel)
|
logrus.SetLevel(logrus.DebugLevel)
|
||||||
logrus.SetReportCaller(true)
|
logrus.SetReportCaller(true)
|
||||||
}
|
}
|
||||||
logrus.SetFormatter(&logrus.TextFormatter{
|
|
||||||
ForceColors: true,
|
|
||||||
EnvironmentOverrideColors: true,
|
|
||||||
TimestampFormat: "2006-01-02 15:04:05",
|
|
||||||
FullTimestamp: true,
|
|
||||||
})
|
|
||||||
logConfig := conf.Conf.Log
|
logConfig := conf.Conf.Log
|
||||||
if logConfig.Enable {
|
if logConfig.Enable {
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -3,13 +3,14 @@ package main
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/alist-org/alist/v3/bootstrap"
|
"github.com/alist-org/alist/v3/bootstrap"
|
||||||
"github.com/alist-org/alist/v3/cmd/args"
|
"github.com/alist-org/alist/v3/cmd/args"
|
||||||
"github.com/alist-org/alist/v3/conf"
|
"github.com/alist-org/alist/v3/conf"
|
||||||
_ "github.com/alist-org/alist/v3/drivers"
|
_ "github.com/alist-org/alist/v3/drivers"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
Loading…
Reference in New Issue