2025-08-12 22:15:25 +08:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2025-08-13 10:03:22 +08:00
|
|
|
"context"
|
|
|
|
|
2025-08-12 22:15:25 +08:00
|
|
|
"github.com/OpenListTeam/OpenList/v5/cmd/flags"
|
|
|
|
"github.com/OpenListTeam/OpenList/v5/internal/bootstrap"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
2025-08-13 10:03:22 +08:00
|
|
|
func Init(ctx context.Context) {
|
|
|
|
if flags.Dev {
|
|
|
|
flags.Debug = true
|
|
|
|
}
|
|
|
|
initLogrus()
|
2025-08-12 22:15:25 +08:00
|
|
|
bootstrap.InitConfig()
|
2025-08-13 19:04:38 +08:00
|
|
|
bootstrap.InitDriverPlugins()
|
2025-08-12 22:15:25 +08:00
|
|
|
}
|
|
|
|
|
2025-08-13 10:03:22 +08:00
|
|
|
func Release() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2025-08-12 22:15:25 +08:00
|
|
|
func initLog(l *logrus.Logger) {
|
2025-08-13 10:03:22 +08:00
|
|
|
if flags.Debug {
|
2025-08-12 22:15:25 +08:00
|
|
|
l.SetLevel(logrus.DebugLevel)
|
|
|
|
l.SetReportCaller(true)
|
|
|
|
} else {
|
|
|
|
l.SetLevel(logrus.InfoLevel)
|
|
|
|
l.SetReportCaller(false)
|
|
|
|
}
|
|
|
|
}
|
2025-08-13 10:03:22 +08:00
|
|
|
func initLogrus() {
|
2025-08-12 22:15:25 +08:00
|
|
|
formatter := logrus.TextFormatter{
|
|
|
|
ForceColors: true,
|
|
|
|
EnvironmentOverrideColors: true,
|
|
|
|
TimestampFormat: "2006-01-02 15:04:05",
|
|
|
|
FullTimestamp: true,
|
|
|
|
}
|
|
|
|
logrus.SetFormatter(&formatter)
|
|
|
|
initLog(logrus.StandardLogger())
|
|
|
|
}
|