alist/bootstrap/log.go

32 lines
802 B
Go
Raw Normal View History

2021-10-27 14:45:36 +00:00
package bootstrap
import (
"flag"
2021-10-27 14:45:36 +00:00
"github.com/Xhofe/alist/conf"
log "github.com/sirupsen/logrus"
)
2021-11-30 01:37:51 +00:00
// InitLog init log
2021-10-27 14:45:36 +00:00
func InitLog() {
if conf.Debug {
log.SetLevel(log.DebugLevel)
log.SetReportCaller(true)
}
log.SetFormatter(&log.TextFormatter{
//DisableColors: true,
ForceColors: true,
EnvironmentOverrideColors: true,
TimestampFormat: "2006-01-02 15:04:05",
FullTimestamp: true,
})
2021-11-30 01:37:51 +00:00
log.Infof("init log...")
2021-12-06 07:55:05 +00:00
}
func init() {
flag.StringVar(&conf.ConfigFile, "conf", "data/config.json", "config file")
flag.BoolVar(&conf.Debug, "debug", false, "start with debug mode")
flag.BoolVar(&conf.Version, "version", false, "print version info")
flag.BoolVar(&conf.Password, "password", false, "print current password")
flag.Parse()
2021-12-06 07:55:05 +00:00
InitLog()
2021-10-27 14:45:36 +00:00
}