Refactor log

This commit is contained in:
世界
2022-07-12 15:17:29 +08:00
parent b47f3adbb3
commit 4fc763cfa2
46 changed files with 760 additions and 457 deletions

View File

@@ -5,15 +5,9 @@ import (
"github.com/sagernet/sing-box/log"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
func init() {
logrus.StandardLogger().SetLevel(logrus.TraceLevel)
logrus.StandardLogger().SetFormatter(&log.LogrusTextFormatter{})
}
var (
configPath string
workingDir string
@@ -38,17 +32,14 @@ func init() {
func main() {
if err := mainCommand.Execute(); err != nil {
logrus.Fatal(err)
log.Fatal(err)
}
}
func preRun(cmd *cobra.Command, args []string) {
if disableColor {
logrus.StandardLogger().SetFormatter(&log.LogrusTextFormatter{DisableColors: true})
}
if workingDir != "" {
if err := os.Chdir(workingDir); err != nil {
logrus.Fatal(err)
log.Fatal(err)
}
}
}